Professional Documents
Culture Documents
PART A: Refer to text( worth 4 marks) Chaper 8: Questions 1, 2 Chapter 9: 1 and 2 Chapter 10: 1, 2, 3, 4 ====================================================== Part B :( worth 10 marks) Refer to Chapter 11. Create the Library database given on your recent Mid-Term TestLibrary Database: -- First hand-sketch this database diagram and once it has been DDL-created generate the diagram. PKs are highlighted and FKs are shown in parentheses. You will
need to come up with your own data. AUTHOR Au-Bk BOOK AuthorID (AuthorID ISBN-No ALName BookTitle ISBN-No) AFName (AuthorID) Copies (PublisherID) Note: AuthorID and ISBN-No are also foreign keys Generate PK start at 10 with increments of 5 1:M with Au-Bk See Author and Book Generate PK Start at 1000 with increments of 1 BOOKCOPY CallNum (ISBN-No) Condition Status LOAN LoanID (MemberID) LoanDate LOANDETAILS *(LoanID+ CallNum) DueDate ReturnDate Note: LoanID and CallNum are also Foreign Keys PUBLISHER PublisherID PublisherName MEMBER MemberID MLName MFName Address Status Membership Date
1: 0 or 1 with LOANDETAILS
See Bookcopy
Generate PK Generate PK Start with 1 and Start with increment by 1 10000 and increment by 100 1:M with 1:M with BOOK LOAN
CXCP 216 Intro to SQL FINAL EXERCISE SET -4 Worth 20 Marks Two Parts A & B Insert 5 records Insert 10 records Insert 10 records Insert 15 records
Insert 5 records
Insert 15 records
Insert 5 records
Insert 5 records
a. Required : Use SQL DDL statements to create the library database ( LibraryDB). Assume Null and Non-Null fields. Set any Default values and constraints. Create at least 8 indexes. Generate the database diagram. b.
(i) Write a SELECT statement that returns THREE columns that show the author by Lastname, FirstName,. Group and Count number of titles for a given author. Order appropriately.
(ii)
Write a SELECT Statement that groups Members and their Loans and LoanDetails ( show also the titles that they have borrowed)
(iii)
Make up your own Query question ( different from (i) & (ii) ) with joins of 3 or more tables code and show the results.
c.