hw2 Fall22
hw2 Fall22
Homework 2
Due: October 10, Monday till midnight
You will use the Moodle course page for submission of this assignment
Q.1 [60 points] Draw an ER diagram to create a library database. The following information
should be captured in your model:
The library has two types of resources: books and periodicals. Each resource is identified by
an ISBN number, and the publisher and publication year of it are also maintained in the
database. The books additionally have a title, author, category, price and the number of
copies. The periodicals, on the other hand, have a name, volume and issue.
Each library resource is supplied from a certain supplier whose unique supplier id, name and
address are captured in the database. The supply date of the supplied resource are kept for
each supply transaction.
Customers of the library can be either registered and unregistered. For all the customers we
keep their unique TCK number, email address and birth date. Additionally, the phone
numbers of registered customers are also maintained.
Customers are allowed to buy books from the library. The date of the purchase is captured in
the database.
Only registered customers are allowed to borrow the library resources. The date of borrowal
and the return date are kept for each borrow transaction. Registered customers can have
dependents who are allowed to borrow only books by capturing the date of borrowal and the
return date. The name of the dependents is maintained in the database.
The library has storage areas that can be rented by only registered customers. For each
storage area a unique id and a price are maintained. Only one area can be rented by a
registered customer, and a rented area cannot be shared by different customers.
Q.2 [25 pts] Translate the E/R diagrams of the previous question into the relational model
(i.e., give the relation schemas for each case specifying the table names, together with the
attributes, and primary key and foreign key constraints).
Q.3 [15 pts] Give an E/R diagram with 3 entity sets that captures the following schema:
Customer (cno, name, address, phone)
Hotel (hno, name, city, rating)
Reserve (hno, start-date, cno, end-date, price)
hno Foreign Key references Hotel
cno Foreign Key references Customer