National University of Computer and Emerging Sciences, Lahore Campus
Course: Database Systems
Program: BS(Computer Science)
Instructor: Muhammad Ishaq Raza
Practice Problem: Relational Model (3)
Consider the following relational database state. Primary keys (PKs) are underlined and foreign keys (FKs) are in italic font.
Assume referential integrity constraint(RIC) on FKs (Sites.ownerID and Entries.siteID) are ON DELETE CASCADE and ON UPDATE
SET NULL.
Users Sites Entries
userID popularity name siteID siteName ownerID viewCount entryID siteID rating createdDate tag
23 4 Isbah 3 FAN 22 200 1 3 5 2018-05-11 BP
31 1 Izaan 5 W3Schools 13 400 2 3 10 2018-08-11 Views
13 4 Tahreem 6 Online DB 22 300 3 5 15 2018-05-11
22 5 Khadija 8 SQL Guru 23 250 4 8 10 2018-07-11
5 6 19 2018-05-11 FR
6 8 4 2018-05-17 Views
Q. Apply following operations on the above database. State if the operation would be carried out successfully or not. Explain
your answer briefly. In case of successful operation indicate the changes that will be made to the above database and in case of
Reject state the error that occurred. Please note that all operations are independent.
a. UPDATE users SET userID=55 WHERE popularity=4;
Accept Explain:
Reject
b. UPDATE entries SET siteID = 1 WHERE rating=10;
Accept Explain:
Reject
c. DELETE FROM entries WHERE siteID=3;
Accept Explain:
Reject
d. DELETE FROM sites WHERE ownerID=22
Accept Explain:
Reject
e. INSERT INTO entries VALUES (6,7 ,5, 2012-05-11, 115);
Accept Explain:
Reject
Department of Computer Science Page 1 of 1