In: Computer Science
Given the following 7 relations:
MIScompany (name, address, phone, email, FedTaxId, StaTaxId)
branch (branchId, name, address, phone, email, FedTaxId, StaTaxId)
employee (empId, driverId, ssno, name, branchId)
customer (custId, name, address, driverId, ssno, FedTaxId, StaTaxId)
equipment (equipId, name, type, upc, purchaseDate, year, manufacturId, cost, rentFee, branchId )
manufacturer (manufacturId, name, FedTaxId, StaTaxId, phone, email)
rental (rentalId, equipId, custId, rentDate&time, returnDate&time, empId)
1. Use relational algebra to retrieve every customer that has not rented any equipment in September 2020. The report should contain custId and customer name.
R1 ← π custId, name (σ rentDate&Time≥date('2020-09-01') and rentDate&Time≤date('2020-09-30') (RENTAL ⨝ CUSTOMER))
R2 ← π custId, name (CUSTOMER)
RESULT ← R2 - R1
2. Use relational algebra to list every manufacturer that only makes an electric cleaning tool (a type of equipment). The report should contain manufacturId and manufacturer name
π manufacturId, MANUFACTURER.name (σ EQUIPMENT.name='Electric Cleaning Tool' (MANUFACTURER ⨝ EQUIPMENT))
3. Use relational algebra to list the number of rentals that is handled by each employee yesterday. The report should contain empId, employee name, and the number of rentals handled by the employee (rented yesterday).
R1 ← emp_id γ count(*) as no_of_rentals (σ rentDate&time=date(2020-10-04) (RENTAL))
RESULT ← π emp_id, name, no_of_rentals (R1 ⨝ EMPLOYEE)
4. Use relational algebra to list all equipment in detail, including the name of the customer if the equipment is rented out yesterday.
R1 ← π equip_id, cust_id (σ rentDate&Time=date('2020-10-04') (RENTAL))
R2 ← π cust_id, name (CUSTOMER ⨝ R1)
R3 ← π equip_id, EQUIPMENT.name, type, upc,purchaseDate, year, manufacturId, cost, rentFee, branchId, cust_id, R2.name (EQUIPMENT ⨝ R2)