RickyD
November 24th, 2007, 10:09 PM
The exercise is to store the following fields for a library database: AuthorCode, AuthorName, BookTitle, BorrowerAddress, BorrowerAddress, BorrowerName, BorrowerCardNumber, CopiesOfBook, ISBN, LoanDate, PublisherCode, PublisherName, and PublissherAddress. A one to many relationship exists between the publishers and books and many to many relationship exists between authors and books and between borrowers and books. Tables need to be in third normal form
I came up with 6 tables
Author (AuthorCode, AuthorName)
PK AuthorCode
AK AuthorName
Borrower (BorrowerCardNumber, BorrowerName, BorrowerAddress)
PK BorrowerCardNumber
SK BorrowerName
BorrowedBooks (BorrowerCardNumber, BookID, LoanDate)
PK BorrowerCardNumber
PK BookID
AuthorsBooks (AuthorCode, ISBN)
PK AuthorCode
PK ISBN
Book (BookID, ISBN, BookTitle, CopiesOfBook, PublisherCode)
PK BookID <--- created a artificial key because ISBN could be repeating with more than 1 copy
AK ISBN
SK BookTitle
FK PublisherCode --> Publisher
Publisher (PublisherCode, PublisherName, PublisherAddress)
PK PublisherCode
SK PublisherName
I came up with 6 tables
Author (AuthorCode, AuthorName)
PK AuthorCode
AK AuthorName
Borrower (BorrowerCardNumber, BorrowerName, BorrowerAddress)
PK BorrowerCardNumber
SK BorrowerName
BorrowedBooks (BorrowerCardNumber, BookID, LoanDate)
PK BorrowerCardNumber
PK BookID
AuthorsBooks (AuthorCode, ISBN)
PK AuthorCode
PK ISBN
Book (BookID, ISBN, BookTitle, CopiesOfBook, PublisherCode)
PK BookID <--- created a artificial key because ISBN could be repeating with more than 1 copy
AK ISBN
SK BookTitle
FK PublisherCode --> Publisher
Publisher (PublisherCode, PublisherName, PublisherAddress)
PK PublisherCode
SK PublisherName