comp306-spring2024-PSweek3
comp306-spring2024-PSweek3
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 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.