Lab 9
Lab 9
Exercises
Using the Course,Semester and Prog table, apply the following queries:
1. Create a new table Course replica of Course table with no records in it.
Create a new table Semester replica of Semester table with all records in it.
Create a new table Prog replica of Prog table with all the records in it.
Create a primary foreignkey relationship between Course and Prog tables,Semester tables.
2. Insert following records into Course using following values:
CourseName = ‘DBMS’, CreditHrsTheory = 3, CreditHrsLab = 1, ProgID=1,SemID=4.
CourseName = ‘OOP’, CreditHrsTheory = 3, CreditHrsLab = 1, ProgID=2,SemID=3.
CourseName = ‘NLP’, CreditHrsTheory = 3, CreditHrsLab = 0, ProgID=2,SemID=5.
CourseName = ‘DSA’, CreditHrsTheory = 3, CreditHrsLab = 0, ProgID=2,SemID=5.
3. Change the record inserted in question 2 from CourseName ‘NLP to ‘AI’ and
CreditHrsLabs to 1
4. Remove all the records from Course table having CreditHrsLab = 0.
5. Try to update the table Prog and change the value of ProgID from 4 to 10. Find the error and give the
reason for the error.
The error likely occurs due to foreign key constraints referencing ProgID in other tables. Updating
ProgID from 4 to 10 violates referential integrity, causing the error.
8. Change the record in Course table and set the ProgID for the CourseName=’AI’ as the
progid of record added in task 7
9. Delete the record from Prog table that was added in task 7 . Note the error and give reason
fro the error.
The error likely occurs due to foreign key constraints referencing ProgID in other tables. Deleting
ProgID 0 violates referential integrity, causing the error.
10. Delete the record of ‘AI’ course from the Course table
11. Repeat the task 9 and note the results and see what happens and provide appropriate
reasoning fro the results.
When there is data in the table which have foreign key to the another table It cannot be
deleted when there is no data of that foreign key then data can be deleted