Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Dbms Lab Lab Assignments: Week 5

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

DBMS Lab

Lab Assignments
Week 5

► Defining constraints + NOT NULL constraint + UNIQUE constraint +


PRIMARY KEY constraint + FOREIGN KEY constraint + CHECK constraint

1. Create the table MYEMP1 (with the following structure) in Oracle RDBMS.
Column ENO ENAME PAN JOB MGR SAL DNO
Name
Data Type Numeric Alphanumeric Alphanumeric Alphanumeric Numeric Numeric Numeric
Maximum 4 20 10 4 5 2
Width
Nullity No No No Yes Yes Yes Yes
Primary Yes - - - - - -
Key
Check No No No No No Yes No
Unique - - Yes - - - -

a) Add bonus Column to myemp1 table. Take bonus as of type number with size 10.
b) Alter table to add check constraint. Example: Add check constraint with name
bonus_ck to check bonus given to every employee should not exceed salary.

2. a) Create a table Depart with the columns dept_id, dept_name, location_name where
dept_id is primary key.
b) Create another table Employ with the columns empid, name, salary, address,
hire_date, department_no where empid is primary key.

 Make a referential integrity between department_no and dept_id. Also make sure that
salary must contain some values in all rows and each department’s name is different.
 Give appropriate names to all the constraints being imposed on both the tables. Insert
at least 3 rows in departments table. Insert at least 5 rows in the employees table with
different department names.

3. a) Create a table Departments with the columns dept_id, dept_name, loc_name where
dept_id is primary key.
b) Create other table locations with the columns location_id, location_name, area where
location_id is primary key.

 Ensure that location_name acts as another candidate key of the locations table. Make
a referential integrity between loc_name of departments table and location_name of
locations table.
 Ensure that dept_name should starts with ‘C’
 Give appropriate names to all the constraints being imposed on the tables. Insert at
least three rows in both the tables.
4. a) Create a table Employees with the columns empid, name, salary, address, hire_date,
mgr_no,dept_name where empid is primary key.

 Make a referential integrity between emp_id and mgr_no.


 Give appropriate names to all the constraints being imposed on the tables. Insert at
least 10 rows in the employees table with different department names (Make one
department name BCA).

You might also like