Nguyen Thi An
Nguyen Thi An
EX1
We have the database consist of 5 relations:
Product (ProductCode, Name, PurchasePrice, SellPrice, Type, SupplierCode)
Supplier (SupplierCode, SupplierName, Address)
Employee (EmloyeeID, FullName, Gender, BirthDate, Address)
Invoice (InvoiceID, SellDate, EmployeeID)
InvoiceLine (ProductCode, InvoiceID, Quantity)
b. Find name and address of all suppliers who supply television product.
suplier name(type = ‘TV’(Product ⋈ Supplier)
f. Find name and address of suppliers who supply both television and mobile.
suplier name,address(type = ‘TV’(Product ⋈ Supplier) suplier name,address(type = ‘TV’(Product ⋈
Supplier)
g. List name and price of all product sold by employee “Nguyễn Văn A” in April
2018.
Name,sellPrice(Fullname = ’NguyenVanA’ (SellDate>=’1/4/2018’ and SellDate <=’30/4/2018’)(Employee)
h. Find name and price of all mobile products of samsung sold in April 2018.
Name,sellPrice(Supplier = LG and name = mobile, TV (saleDate>=1/4/2018.and.sellDate<=30/4/2018)
(((InvoiceLine⋈Invoice)
⋈Product) ⋈Employee)
i. Find the product with highest SellPrice.
name,Type,ProductCode,sellPrice(sellPrice>=all(sellPrice(Product) (Product)
j. Find the amount (quantity * sellPrice) of each invoice line of product sold in
30/04/2018.
((Quantity*SellPrice)Amount(SellDate=’30/04/2018’(((InvoiceLine⋈Invoice) ⋈ Product)).
EX2
Use Relational Algebra to express following constraints:
a. The sell price must be higher than the purchase price.
g. If purchase price is less than 500.000 VND, the sell price could not be greater
than 9.000.000 VND.
h. The sell price could not be greater than 2 times the purchase price.
j. With the same purchase price, the sell price of two products could not have
the difference more than 0.5 times of the purchase price.