Question

In: Computer Science

Database Schema: Book(bookID, ISBN, title, author, publish-year, category) Member(memberID, lastname, firstname, address, phone-number, limit) CurrentLoan(memberID, bookID,...

Database Schema:

Book(bookID, ISBN, title, author, publish-year, category)

Member(memberID, lastname, firstname, address, phone-number, limit)

CurrentLoan(memberID, bookID, loan-date, due-date)

History(memberID, bookID, loan-date, return-date)

Members can borrow books from the library. The number of books they can borrow is limited by the “limit” field of the Member relation (it may differ for different members). The category of a book includes fiction, non-fiction, children’s and reference. The CurrentLoan table represents the information about books that are currently checked out. When the book is returned to the library, the record will be removed from CurrentLoad relation, and will be inserted into History relation with the return-date. A library may have more than one copy of the same book, in which case each copy has its own bookID, but all copies share the same ISBN.

Write SQL statements for each of the following questions.

(1) (16 pts) Create all the relations listed above. Make sure to indicate the primary key and the foreign keys (if any) in your statements.

(2) (10 pts) Insert at least 5 members, 10 books, and enough tuples in the CurrentLoan and History relation. Add tuples as needed to be able to test the following queries for different test cases.

(3) (8 pts) Find the book ID, title, author, and publish-year of all the books with the words “XML” and “XQuery” in the title. These two keywords can appear in the title in any order and do not have to be next to each other. Sort the results by publish year in descending order.

(4) (8 pts) Find the book ID, title, and due date of all the books currently being checked out by John Smith.

(5) (8 pts) Find the member ID, last name, and first name of the members who have never borrowed any books in the past or currently.

Note:

• Please put all the SQL statements in a single file and name it as hw2_yourPirateID.sql.

• Remember to change all the dash “-” in attribute names to underscore “_”.

• For the ease of testing, please add the “drop table” statements at the beginning of your file to drop all the tables.

• Remember to add “commit;” after your last “insert” statement.

• Comment your code as needed. You can use /* … */ to have multi-line comments or use double hyphen (--) for single line commenting. You may use PROMPT … to print any message to the screen. For example, you may use PROMPT Answer for Question 3 (before the query for question 3).

• For this assignment, you need to test your solutions in Oracle and submit your .sql file

Solutions

Expert Solution


Related Solutions

Consider the following schema: Publisher (name, phone, city), PK: name. Book (ISBN, title, year, published_by, previous_edition,...
Consider the following schema: Publisher (name, phone, city), PK: name. Book (ISBN, title, year, published_by, previous_edition, price), PK: ISBN, FK: published_by refs Publisher, previous_edition refs Book. Author (SSN, first_name, last_name, address, income), PK: SSN. Write (aSSN, bISBN), PK: (aSSN, bISBN), FK: aSSN refs Author, bISBN refs Book. Editor (SSN, first_name, last_name, address, salary, works_for, book_count), PK: SSN, FK: works_for refs Publisher. Edit (eSSN, bISBN), PK: (eSSN, bISBN), FK: eSSN refs Editor, bISBN refs Book. Author_Editor (aeSSN, hours), PK: aeSSN, FK:...
Consider the following schema: Publisher (name, phone, city), PK: name. Book (ISBN, title, year, published_by, previous_edition,...
Consider the following schema: Publisher (name, phone, city), PK: name. Book (ISBN, title, year, published_by, previous_edition, price), PK: ISBN, FK: published_by refs Publisher, previous_edition refs Book. Author (SSN, first_name, last_name, address, income), PK: SSN. Write (aSSN, bISBN), PK: (aSSN, bISBN), FK: aSSN refs Author, bISBN refs Book. Editor (SSN, first_name, last_name, address, salary, works_for, book_count), PK: SSN, FK: works_for refs Publisher. Edit (eSSN, bISBN), PK: (eSSN, bISBN), FK: eSSN refs Editor, bISBN refs Book. Author_Editor (aeSSN, hours), PK: aeSSN, FK:...
A person has a firstname, lastname, ID, and email. A phone number is of the form...
A person has a firstname, lastname, ID, and email. A phone number is of the form countrycode, number. A person may have several related telephone numbers, and a telephone number may be associated with multiple people. The possible relationships are: home, work, and mobile. A person may have at most one phone number for each type of relationship. Draw schema diagram and define and create the tables that implement the model and enforce the given constraints.
Using C++ Design a class named PersonData with the following member variables: lastName firstName address city...
Using C++ Design a class named PersonData with the following member variables: lastName firstName address city state zip phone and at a minimum the following member functions: A class constructor - which initializes all the member variables above a display() function - which ONLY displays all the person's data to the console Also write the appropriate accessor/mutator functions for the member variables Write a NewPersonData function. This is a stand-alone function that you can use in your main to generates...
Database Normalize the relations to BCNF: Member- (MemID, dateJoined, firstName, lastName, street, city, state, zip, areaCode,...
Database Normalize the relations to BCNF: Member- (MemID, dateJoined, firstName, lastName, street, city, state, zip, areaCode, phoneNumber, currentOfficeHeld) Play- (title, author, numberOfActs, setChanges) Sponsor- (sponID, name, street, city, state, zip, areaCode, phoneNumber) Subscriber- (subID, firstName, lastName, street, city, state, zip, areaCode, phoneNumber) Production- (prodyear, seasonStartDate, seasonEndDate, title) Performance – (perfyear,perfdate, time, seasonStartDate) TicketSale- (saleID, saleDate, totalAmount, perfyear, perfdate,subID) DuesPayment- (MemID, duesYear, amount, datePaid) Donation – (sponID, donationDate, donationType, donationValue, prodYear, seasonStartDate) Ticket- (saleID, seatLocation, price, type) Member - Production-(MemID, prodYear,...
Tables CUSTOMER CustomerID FirstName LastName Address Phone LicenseNo 1 David Hacker 101 Yammba road, Rockhampton 0749008877...
Tables CUSTOMER CustomerID FirstName LastName Address Phone LicenseNo 1 David Hacker 101 Yammba road, Rockhampton 0749008877 089 777 123 2 Tony Morrison 98 South street, Melbourne 0490787772 088777555 3 Issac Newton 90 Heaven road, Sydney 0299001122 099 776 123 4 James Farrell 101 St Lucia Garden, Brisbane 0733099000 090 566 777 5 David Land 345 Illinois road, Brisbane 0739000554 456 000 999 6 Peter Garry 201 South port road, Gold Coast 0745676766 234 090 767 RENTAL RentalID CustomerID RegoNo StartDate...
Write the following queries using the schema below Class (Number, Department, Term, Title) Student (Username, FirstName,...
Write the following queries using the schema below Class (Number, Department, Term, Title) Student (Username, FirstName, LastName, Year) Takes (Username, Department, Number, Term, Grade) [clarification] In Student, Year is an integer. A student can be a 2nd year student. In that case, Year value would be 2. For the Takes relation: ·         Grade is NA for current semester students ·         Username is foreign key to Student ·         (Department, Number, Term) is foreign key to Class a)       Write an SQL query that returns the Term...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT