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,...

  • This project supposed to develop a database system for a library for a university. The system...

    This project supposed to develop a database system for a library for a university. The system contains information about books, book authors, students, and faculty. Students and faculty are allowed to borrow books from the library. You should design the system to contain entities and attributes to store data that makes the system able to report the requested information by executing the queries. SQL Queries: 1. List the names and email for students who borrowed books along with the number...

  • 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...

  • Suppose a database has the following three relations. Movie (mid: integer, title: string, director: string, releaseDate:...

    Suppose a database has the following three relations. Movie (mid: integer, title: string, director: string, releaseDate: date) PlaysAt (theaterID: integer, movieId: integer, showDate: date) Theater (tID: integer, name: string, phone: string, screencount: integer) "movieID" in PlaysAt is a foreign key referencing "mid" in Movie. "theaterID" in PLaysAt is a foreign key referencing "tID" in Theater. Write the following queries in both relational algebra and SQL. Find the titles of movies playing on 2 / 26 / 2019 and the IDs...

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
ADVERTISEMENT