0% found this document useful (0 votes)
1 views6 pages

Lab 9

The document outlines a series of exercises for a DBMS lab, focusing on creating and manipulating database tables related to courses, semesters, and programs. It includes tasks such as creating replicas of tables, inserting records, updating values, and handling foreign key constraints. The document emphasizes the importance of referential integrity when performing updates and deletions in the database.

Uploaded by

razaannas7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views6 pages

Lab 9

The document outlines a series of exercises for a DBMS lab, focusing on creating and manipulating database tables related to courses, semesters, and programs. It includes tasks such as creating replicas of tables, inserting records, updating values, and handling foreign key constraints. The document emphasizes the importance of referential integrity when performing updates and deletions in the database.

Uploaded by

razaannas7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

DBMS LAB # 9

Name: Saad Bin Munir


Enrollment No: 02-134222-026
Section: BSCS 4-B

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.

6. Insert a new record into Course using following values:


CourseName = ‘CP, CreditHrsTheory = 3, CreditHrsLab = 1, ProgID=10,SemID=3. Find the error
and give the reason for the error.
The error likely occurs due to foreign key constraints referencing ProgID in other tables. Inserting
ProgID 10 violates referential integrity, causing the error.
7. Insert A new record in Prog table using following values:
ProgName=’MSIT’,CreditHrs=36

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy