Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Assignment-2

Course Name: RDBMS (CS2202)

Topic: Relational Algebra and SQL


Release Date: 22th March 2024 Submission Date: 16th February 2024
--------------------------------------------------------------------------------------------------------------------------------------
Instruction: Do this assignment in earlier made register / notebook for solving assignment
problems in handwritten format. Upload the scan copy of the solution in MS Teams, link of
which will be shared by course instructor. At the end of the semester, submit the
register/notebook to the course instructor. You can get back it from course instructor after
his/her signature at the end of CWS evaluation.

Q1. Write the Relational Algebra and SQL for the following Query and databases.

• Retrieve the names of all employees in department 5 who work more than 10 hours
per week on the ProductX project.
• List the names of all employees who have a dependent with the same first name as
themselves.
• Find the names of all employees who are directly supervised by ‘Franklin’ Wong’.
• For each project, list the project name and the total hours per week (by all employees)
spent on that project.
• Retrieve the names of all employees who work on every project.
• Retrieve the names of all employees who do not work on any project.
• For each department, retrieve the department name and the average salary of all
employees working in that department.
• Retrieve the average salary of all female employees.
• Find the names and addresses of all employees who work on at least one project
located in Houston but whose department has no location in Houston.
• List the last names of all department managers who have no dependents.
Q.2 Write the Relational Algebra and SQL for the following Query and databases

• 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 who’s Due_date 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 coauthored) by Stephen King, retrieve the title and the
number of copies owned by the library branch whose name is Central.

Q.3 Consider the following relations and write the relational algebra and tuple calcus for
the following query
Customer (Cust_ID, Cust_Name)
// Keeps the customer information.
Product (Prd_ID, Prd_Name, Ava_Qty, Price)
/* keeps the product information like product id, product name, available quantity of
product and price of particular product *\
Order (Ord_ID, Cust_ID, Ord_Date)
// keeps the order id, customer id, order date.
Order_Line (Ord_ID, Prd_ID, Ord_Qty)
// each row in this table represents one line item of an order because an order (invoice)
can have multiple items. This relation keeps the information of order id, product id and
order quantity.

• Make the list of customer name that has placed an order of every product.
• Print the product name that has maximum price.
• Make the list of product ID that has been ordered between 24/2/2017 and 12/2/2017,
both dates are inclusive.
• List customer id that has placed the order of product id ‘p1’ or ‘p2’.
• List customer id that has placed the order of product id ‘p1’ and ‘p2’

You might also like