Question

Consider the following table schemas (primary keys are underlined): Book (BookId, Title, Publishername)  Book_Authors (BookId, AuthorName)  Publisher...

Consider the following table schemas (primary keys are underlined): 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) Write SQL statements for the following queries: List the number of copies of the book titled “The Lost Tribe” owned by each library branch and the corresponding library branch name. List the names and addresses of all borrowers who have borrowed more than 5 books that are published by “ABC”. List the name and the phone number of the borrower who borrowed the book authored by “Stephen King” on date “2017-03-05”. List the library branch name where the number of copies of the book titled “The Spring” is greater than the number of copies of the book titled “The Pleasure of Coding”.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. List the number of copies of the book titled "The Last Tribe" owned by each library branch and the corresponding library branch name.

select bookcopies.No_Of_Copies, library.BranchName
from Book_Copies bookcopies, Library_Branch library
where bookcopies.BookId = library.BranchId and bookcopies.BookId = ( select BookId
from Book where Title="The Lost Tribe");

2. List the names and address of all borrowers who have borrowed more than 5 books that are published by "ABC".

select Name, Address from Borrower
inner join Book_Loans on Borrower.CardNo = Book_Loans.CardNo
inner join Book_Copies on Book_Loans.BookId = Book_Copies.BookId
inner join Book on Book_Copies.BookId =Book.BookId
where Book.Publishername = 'ABC' and Book_Copies.No_Of_Copies > 5;


3. List the name and phone number of the borrower who borrowed the book authored by "Stephen King" on date "2017-03-05".

select Name, Phone
from Borrower
where CardNo = ( select CardNo from Book_Loans
where DateOut = '2017-03-05' and BookId = (select BookId from Book_Authors
where AuthorName = "Stephen King");


4. List the library branch name where the number of copies of the book titled "The Sping" is greater than the number of copies of the book titled "The Pressure of Coding".

select BranchName from Library
where BranchId = (select BranchId from Book_Copies where BookId = (select BookId from Book
where Title = "The Spring" and No_Of_Copies>(select No_Of_Copies from Book_Copies
where BookId = (select BookId from where BookId = (select BookId from Book
where Title = "The Pressure of Coding")))));

Add a comment
Know the answer?
Add Answer to:
Consider the following table schemas (primary keys are underlined): Book (BookId, Title, Publishername)  Book_Authors (BookId, AuthorName)  Publisher...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 3. (20 POINTS) Consider the LIBRARY relational database schema below to write down the relational algebra...

    3. (20 POINTS) Consider the LIBRARY relational database schema below to write down the relational algebra expressions for the following two queries. No SQL statements are required. BOOK Bookid Title Publisher name BOOK AUTHORS Book id Author name PUBLISHER Name Address Phone BOOK COPIES Book d Branch Id No o copies BOOK LOANS Book Branch Id Card no Date out Due date LIBRARY BRANCH Branch Branch name Address BORROWER Card Name Address Phone 3.A.) (10 POINTS) Let the number of...

  • The primary keys are underlined. The foreign keys are denoted by asterisks (*). Description of the...

    The primary keys are underlined. The foreign keys are denoted by asterisks (*). Description of the schema: • person — keeps track of the people who borrow books from the library. The attributes contain personal and contact information. • author — keeps track of personal information about authors. • publisher — keeps track of the publisher information. To keep it simple, most of the attributes have been truncated in the sample database. 1 trivial dependencies are things like X→X or...

  • c) Write an ER Diagram for the following Library database. Identify all the Entities, Relationships and Attributes. Underline the primary keys and mark the different constraints. You can add an I att...

    c) Write an ER Diagram for the following Library database. Identify all the Entities, Relationships and Attributes. Underline the primary keys and mark the different constraints. You can add an I attribute as a primary key for an entity to make t unique if necessary. Library has a number of branches in the city, each branch having a name, address and librarian. Books have title, authors and publisher. A book can have multiple authors but a single publisher. Note that same...

  • Specify relational calculus expression for the following descriptions on the Library database schema shown in Figure...

    Specify relational calculus expression for the following descriptions on the Library database schema shown in Figure 4.6. a) Retrieve Publishers’ name and phone number whose books where borrowed from Baltimore Branch. b) List the book title, book id and branch name with less than 10 copies c) List customer card number, customer name, branch name and book title for books which are currently on loan. BOOK Book id Title Publisher_name BOOK_AUTHORS Book idAuthor name PUBLISHER Name Address Phone BOOK COPIES...

  • Design an ER diagram for a library management system. The library manages books, members, and books...

    Design an ER diagram for a library management system. The library manages books, members, and books borrowed by members.  The library has several branches around the city. Each branch has a name and address and is identified by a branch ID.  Each book in the system is identified by a unique ISBN along with its title, author(s), and publisher.  A publisher is identified by its name, address, and phone. Note that publishers may be based anywhere around...

  • Design an ER diagram for a library management system. The library manages books, members, and books...

    Design an ER diagram for a library management system. The library manages books, members, and books borrowed by members.  The library has several branches around the city. Each branch has a name and address and is identified by a branch ID.  Each book in the system is identified by a unique ISBN along with its title, author(s), and publisher.  A publisher is identified by its name, address, and phone. Note that publishers may be based anywhere around...

  • Author(name, address, URL) Book(ISBN, title, year, price,         publisher_Name) WrittenBy(name, address, ISBN) Publisher(name, address, phone, URL)...

    Author(name, address, URL) Book(ISBN, title, year, price,         publisher_Name) WrittenBy(name, address, ISBN) Publisher(name, address, phone, URL) Warehouse(code, phone, address) Stocks(ISBN, WH_code, number) Shopping-Basket(basketID, email) basketContains(ISBN, basketID, number) Customer(email, name, address, phone) Referring to the relational model in slide 15 in"ER-mapping" (about author, publisher, shopping-basket, provide the algebraic pressing for the following queries Q1: Report the book title, and year for the books that have been written by exactly 2 authors, one of them is Mark Smith" Q2: For each customer,...

  • Consider the following relation tables (fields with underline is primary keys): Author(Name, Country) Book(ISBN, Title, Publisher,...

    Consider the following relation tables (fields with underline is primary keys): Author(Name, Country) Book(ISBN, Title, Publisher, Subject) Writes(Name, ISBN) Write the relational algebra for the following query: a. (2 points) Give the titles of all books with "Art" subject Solution: b. (2 points) Give the name of all authors who publish with "Harding" Solution: (2 points) Give the name of all authors who have written books with "Science" subject Solution: c. d. (3 points) Give the titles of all books...

  • Valley View Town Library has grown to a stage where, due to the increased number of...

    Valley View Town Library has grown to a stage where, due to the increased number of loans, it is becoming increasingly difficult to maintain accurate records manually. Your company has been approached to design a suitable system to handle the required functionality of this system. Discussions with the head librarian, Mr. Lachlan Ward have resulted in the specific requirements of this system which have been detailed in the following paragraphs. Before people can borrow books from the library, they must...

  • Given the following relational database schema (primary keys are bold and underlined). Answer questions 2.1 to 2.4 Orde...

    Given the following relational database schema (primary keys are bold and underlined). Answer questions 2.1 to 2.4 Orders(orderld, customerld, dateOrdered, dateRequired, status) Customer(customerld, customerLastName, customerStreet, customerCity, customerState, customer Lip OrderDetails(orderld.productld, quantity, lineNumber, amount) Products(productld, name, description, quantity, unitPrice) Account(accountNumber, customerld, dateOpened, creditCard, mailingStreet, mailingCity, mailingState, mailingZip) 2.1 (2 Points) List all possible foreign keys. For each foreign key list both the referencing and referenced relations. 2.2 (2 Points) Devise a reasonable database instance by filling the tables with data of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT