Create a database, fill in data, query, and create at lest a stored procedure or more.
Database schema is provided.
Now populate the tables of the database with dummy data. You may enter in whatever data you like, but must ensure that the following is true:
- There is a book called 'The Lost Tribe'.
- There is a library branch called 'Sharpstown' and one called 'Central'.
- There are at least 20 books in the BOOK table.
- There are at least 10 authors in the BOOK_AUTHORS table.
- Each library branch has at least 10 book titles, and at least two copies of each of those titles.
- There are at least 8 borrowers in the BORROWER table, and at least 2 of those borrowers have more than 5 books loaned to them.
- There are at least 4 branches in the LIBRARY_BRANCH table.
- There are at least 50 loans in the BOOK_LOANS table.
- There must be at least one book written by 'Stephen King'
Next, query the following:
- How many copies of the book titled The Lost Tribe are owned by the library branch whose name is"Sharpstown"?
- How many copies of the book titled The Lost Tribe are owned by each library branch?
- Retrieve the names of all borrowers who do not have any books checked out.
- For each book that is loaned out from the "Sharpstown" branch and whose DueDate is today, retrieve the book title, the borrower's name, and the borrower's address.
- For each library branch, retrieve the branch name and the total number of books loaned out from that branch.
- Retrieve the names, addresses, and number of books checked out for all borrowers who have more than five books checked out.
- For each book authored (or co-authored) by "Stephen King", retrieve the title and the number of copies owned by the library branch whose name is "Central"
Next, create a stored procedure:
Then create at least one stored procedure (two or more) based from above queries.
- Create database
- Create tables with columns (make sure to add keys like Primary Keys, auto increment according to SQL standards) *Book: BookId, Title, PublisherName *Book_Authors: BookId, AuthorName *Publisher: Name, Address, Phone *Book_Copies: BookId, BranchId, No_Of_Copies *Book_Loans: BookId, BranchId, CardNo, DateOut, DueDate *Library_Branch: BranchId, BranchName, Address *Borrower: CardNo, Name, Address, Phone
- Insert records according to the requirements above
- Run queries as per above's requirements
- Create a stored procedure
- Run the "generatedbscript.sql" which will create the dB, tables, columns, keys and records
- Run each queries against the database (see query-**.sql)
- Create and run stored procedure (see stored-procedure.sql)