161k views
1 vote
Consider the LIBRARY relational database schema description provided below which is used to keep track of books, borrowers, and book loans. The relations are: • BOOK (BookID, Title, PublisherName) • BOOK_AUTHORS (BookID, AuthorName) • PUBLISHER (Name, Address, Phone) • BOOK_COPIES (BookID, BranchID, NumberOfCopies) • BOOK_LOANS (BookID, BranchID, CardNumber, DateOut, DueDate) • LIBRARY_BRANCH (BranchID, BranchName, Address) • BORROWER (CardNumber, Name, Address, Phone) 1. Consider the schema given above: (a) (5 points) Give a primary key for each relation. Are there any relations for which there is an alternate candidate key that you have not chosen as the primary key? If yes, mention the relations, candidate keys and the reason (if any) for your choice of the primary key. (b) (10 points) State all referential integrity constraints that should hold on these relations.

User MAV
by
4.3k points

1 Answer

5 votes

Answer:

1) Yes, Publisher relation should have a publisherID primary key.

2) NOT NULL and UNIQUE for the BookID, BranchID, CardNumber and name of the borrower in the Book, Book_Copies, Library_branch, and Borrower relations respectively. The DueDate field of the book_loan relation must be a time constraint. The BookID of the Book relation must be serial number for automatic addition and update of bookid across the database.

Step-by-step explanation:

The Publisher relation should have primary key publisherID which should replace the publisherName in the Book relation to easily make a join query and attain a third-level database model.

User Vlad From Moscow
by
4.1k points