0% found this document useful (0 votes)
257 views2 pages

Assignment 2

This document contains questions about querying relational databases based on different schemas. It includes questions about retrieving counts, names, and other data fields based on joins between tables and filtering on attributes like branch name, date, quantity, and more. Relational algebra expressions and extensions to relational calculus are also discussed to enable additional query capabilities like aggregation, outer joins, and recursion.

Uploaded by

Swasti Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
257 views2 pages

Assignment 2

This document contains questions about querying relational databases based on different schemas. It includes questions about retrieving counts, names, and other data fields based on joins between tables and filtering on attributes like branch name, date, quantity, and more. Relational algebra expressions and extensions to relational calculus are also discussed to enable additional query capabilities like aggregation, outer joins, and recursion.

Uploaded by

Swasti Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Database Management Systems

Assignment – 2

Q.1 Consider the LIBRARY relational database schema shown in Figure 6.14, which is used to keep
track of books, borrowers, and book loans. Referential integrity constraints are shown as directed arcs.
Write down relational expressions for the following queries:

a. How many copies of the book titled The Lost Tribe are owned by the library branch whose name is
‘Sharpstown’?
b. How many copies of the book titled The Lost Tribe are owned by each library branch?
c. Retrieve the names of all borrowers who do not have any books checked out.
d. For each book that is loaned out from the Sharpstown branch and whose Due_date is today, retrieve
the book title, the borrower’s name, and the borrower’s address.
e. For each library branch, retrieve the branch name and the total number of books loaned out from
that branch.
f. Retrieve the names, addresses, and number of books checked out for all borrowers who have more
than five books checked out.
g. For each book authored (or coauthored) by Stephen King, retrieve the title and the number of copies
owned by the library branch whose name is Central.
Q.2 Suggest extensions to the relational calculus so that it may express the following types of
operations that were discussed in Section 6.4: (a) aggregate functions and grouping; (b) OUTER JOIN
operations; (c) recursive closure queries.

Q.3 Consider the following MAILORDER relational schema describing the data
for a mail order company.
PARTS(Pno, Pname, Qoh, Price, Olevel)
CUSTOMERS(Cno, Cname, Street, Zip, Phone)
EMPLOYEES(Eno, Ename, Zip, Hdate)
ZIP_CODES(Zip, City)
ORDERS(Ono, Cno, Eno, Received, Shipped)
ODETAILS(Ono, Pno, Qty)

Qoh stands for quantity on hand: the other attribute names are self-explanatory. Specify and execute
the following queries using the RA interpreter on the MAILORDER database schema.
a. Retrieve the names of parts that cost less than $20.00.
b. Retrieve the names and cities of employees who have taken orders for
parts costing more than $50.00.
c. Retrieve the pairs of customer number values of customers who live in
the same ZIP Code.
d. Retrieve the names of customers who have ordered parts from employees
living in Wichita.
e. Retrieve the names of customers who have ordered parts costing less than
$20.00.
f. Retrieve the names of customers who have not placed an order.
g. Retrieve the names of customers who have placed exactly two orders.

Q.4 . Consider a database that consists of the following relations.


SUPPLIER(Sno, Sname)
PART(Pno, Pname)
PROJECT(Jno, Jname)
SUPPLY(Sno, Pno, Jno)
The database records information about suppliers, parts, and projects and
includes a ternary relationship between suppliers, parts, and projects. This
relationship is a many-many-many relationships. Specify and execute the following queries using the RA
interpreter.
a. Retrieve the part numbers that are supplied to exactly two projects.
b. Retrieve the names of suppliers who supply more than two parts to project ‘J1’.
c. Retrieve the part numbers that are supplied by every supplier.
d. Retrieve the project names that are supplied by supplier ‘S1’ only.
e. Retrieve the names of suppliers who supply at least two different parts
each to at least two different projects.

You might also like