0% found this document useful (0 votes)
17 views

comp306-spring2024-PSweek3

Uploaded by

emrekursun4
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)
17 views

comp306-spring2024-PSweek3

Uploaded by

emrekursun4
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/ 2

COMP 306: Database Management Systems

PS Questions: Relational Model + ER to Relational Conversion

Use the following relational database schema and state to answer Questions 1-3. The database
consists of 4 relations:
• Customer(CID, Cname, Phone, City)
• Item(Item ID, QuantityOnHand, UnitPrice)
• Order(OID, CID, Date, TotalAmount)
• OrderDetail(OID, Item ID, QuantityOrdered)
Primary keys are underlined above. CID is a foreign key in Order referencing the Customer relation,
Item ID is a foreign key in OrderDetail referencing the Item relation, and OID is a foreign key in
OrderDetail referencing the Order relation.

Question 1. True or False?


[T/F] OID is both a superkey and a key of the Order relation.
[T/F] If we assume each customer can make at most one order per day, {CID, Date} would be
a candidate key of the Order relation.
[T/F] Given that the current state of the Customer relation is valid, we can say for certain that
Cname is a key of Customer.
[T/F] Given that the current state of the Customer relation is valid, we can say for certain that
City is not a candidate key of Customer.

Question 2. Consider that the customer with CID = 101 is deleted from the Customer relation. If
deletions are cascaded throughout the entire database, how would the other relations be impacted?

1
COMP 306 Relational Model + ER to Relational Conversion

Question 3. Recall the 4 types of integrity constraints in the relational model: domain constraint,
key constraint, entity integrity constraint, referential integrity constraint. For each of the following
actions, decide whether they violate any of the constraints; if so, which one and why?
(i) Insert tuple < NULL, “Jason”, “125-111-9999”, “Athens” > into Customer
(ii) Insert tuple < 107, “Smith”, “770-333-1111”, “Paris” > into Customer
(iii) Insert tuple < 40, 3, 1 > into OrderDetail
(iv) Insert tuple < 45, 103, “2015-05-21”, 300 > into Order

Question 4. Here is a slightly modified version of one of the ER diagrams we designed in the
previous PS. Convert this ER diagram to the relational model using the conversion algorithm from
the lecture. Your answer should consist of the CREATE TABLE statements necessary to create
the appropriate relations. Make sure you specify all primary keys and foreign keys.

Question 5. Here is another ER diagram. Similar to Q4, convert it to the relational model.

You might also like