relational database 5

Detailed instructions are attached.


Question 1:(25 Points)

The diagram below (also attached in DBST651_final_part2_ERD.png ) is an ERD for a public library database.

NOTE: There are two types of catalog items – Book and DVD. A customer can check out one item at a time.

Study the ERD and answer the following questions:

  1. Identify all relationships and specify cardinality and business rules. For example: 1:M between Library and Branch: a library has many branches; a branch belongs to one and only one library.
  2. For each entity, identify primary key and foreign key, if any. For foreign key, also specify parent entity and matching attribute in parent entity.
  3. Write SQL DDL statements to create tables in Oracle and also implement primary key, foreign key, and NOT NULL constraint. Include all columns listed with the correct data type. This step is important, as in Question 2 you will run INSERT statements to populate the tables you created and then write SELECT statement to query those tables.

  1. Write SQL statement for the following scenario:
    1. Add a new customer Eric Short with Customer_ID 10 and Customer_Zip 23456.
    2. Save changes permanently.
    3. Change customer Eric Short zip from 23456 to 20231.
    4. Cancel the change made in step c, restore data to its original status prior to step c.
    5. Delete customer Eric Short.
    6. Save changes permanently.

For SQL code, submit both source statements and results of running your statements.