Professional Documents
Culture Documents
Tutorial # 2
Choose a database application with which you are familiar. Design a schema
and show a sample database for that application, using the notation of Figures
1.2 and 2.1. What types of additional information and constraints would you
like to represent in the schema? Think of several users of your database, and
design a view for each.
Schema:
BOOK
ISBN Title Publisher
BOOK_AUTHORS
ISBN Name
BOOK_COPIES
ISBN Branch_ID No_of_Copies
BOOK_LOANS
ISBN Branch_ID Card_No Date_Out Due_Date
LIBRARY_BRANCH
Branch_ID Branch_Name Address
BORROWER
Card_No Name Address Phone
1
Sample Database:
BOOK
ISBN Title Publisher
123456 Paper Towns Pub1
334455 The Last Leaves Falling Pub4
997545 The Art of Being Normal Pub1
BOOK_AUTHORS
ISBN Name
334455 Lisa Wang
334455 John Bradley
997545 Ed Thomson
123456 Eric Raymond
BOOK_COPIES
ISBN Branch_ID No_of_Copies
123456 11 6
123456 12 10
997545 14 2
334455 11 1
BOOK_LOANS
ISBN Branch_ID Card_No Date_Out Due_Date
334455 11 903 11/9/2015 11/10/2015
123456 11 915 9/3/2015 9/4/2015
123456 12 920 1/1/2015 1/2/2015
997545 14 920 13/4/2015 13/5/2015
LIBRARY_BRANCH
Branch_ID Branch_Name Address
11 Main Branch Olaya St
12 Rabwa Branch Malaz
14 Rawdah Branch Makkah Rd
15 Dariyah Branch Prince Turki
BORROWER
Card_No Name Address Phone
903 John Smith 123 F St 555-4987
915 Susan Benson 490 Main St 555-2222
920 Richard Wily 111 Maple St 498-0000
2
Constraints:
These are examples of constraints. Students may suggest different ones.
The following fields (columns) or combination of fields should have unique values
within their tables:
BOOK (ISBN)
BOOK_AUTHORS (ISBN,Name)
BOOK_COPIES (ISBN, Branch_ID)
BOOK_LOANS (ISBN, Branch_ID, Card_No)
LIBRARY_BRANCH (Branch_ID)
BORROWER (Card_No)
The values in the following fields in their tables should have matching values in the
corresponding tables: