Relational Model- Practice Problem1-Sol
Relational Model- Practice Problem1-Sol
Question 1:
Question 3:
Page 1 of 7
R
A B C D E
F G H I
A F H I
Page 2 of 7
Question 4:
Employee Department
Page 3 of 7
ID Department_ Name Location
1 CS London
2 EE NULL
4 Sam 60000 NULL 4 Other Department Sydney
5 Todd 70000 2
6 Neil 10000 NULL
Page 4 of 7
i. Delete the department whose location is New York.
Operation not allowed since there are two employees who have this
department id.
2. For Insert
a. Assume that foreign key with cascading option is implemented.
i. Insert <NULL, ‘Physics’, ‘Tokyo’> into Department.
Operation not allowed since the primary key cannot be null.
ii. Insert <7, ‘George’, 54000, 6> into Employee.
Operation not allowed since referential integrity constraint is being violated.
iii. Insert <8, ‘John’, 60000 > into Employee.
Operation will be allowed. The department id of the employee will be set to NULL.
NO change in the department table.
Page 5 of 7
Operation allowed. Character type will be converted to integer by sql.
3. For Update
a. Assume that foreign key with cascading option is implemented
i. For the department having id=4, change the id to 3.
Operation not allowed since primary key constraint is being violated.
ii. For the department having id=1, change the location to Karachi.
The location of department will be changed from Sydney to Karachi. No change
in the employee table.
iii. For the employee having id=1, change the id to 8.
The id of the employee will be changed from 1 to 8. No change in the department
table.
Page 6 of 7
ID Department_ Name Location
1 CS London
2 EE NULL
10 BBA New York
4 Other Department Sydney
iii. For the department having name=’BBA’, change the name to ‘Mathematics’.
The name will be changed. No change in the Employee table.
iii. For department having department id= 1, update the department id to 10.
Operation not allowed since there is an employee whose department id is 1.
Page 7 of 7