You are on page 1of 2

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)

a.      The sell price must be higher than the purchase price.

σSellprice <= PurchasePrice(Product) = Ф

b.      A product of Samsung must be television, mobile or tablet.

R1 ← πType, SupplierName (σSupplierName = Samsung (Product ⋈ Supplier))


σType ≠ television ᴧ Type ≠ mobile ᴧ Type ≠ tablet = ∅

c.       No supplier of mobile’s or tablet’s may also supply food.

R1 ← πSupplierName (σType = mobile , Type = tablet(Product ⋈ Supplier)) R1 ←


πSupplierName (σType = food(Product ⋈ Supplier)) R1 - R2 = ∅

d.      No product may appear more than one time in an invoice.

R1 = πProductCode, InvoiceID, Quantity (InvoiceLine)


R2 = πProductCode, InvoiceID, Quantity (InvoiceLine)

e.      The quantity of each product in each invoice should be greater than 0.

σQuantity<=0 (InvoiceLine) = ∅

f.       There is no invoice without product.

R1 ← σ InvoiceID.Invoice = InvoiceID.InvoiceLine(Invoice ⋈ InvoiceLine)

R2 ← σ InvoiceLine.ProductCode = Product.ProductCode (InvoiceLine ⋈ Product)

R1 ∩ R2

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.

σSellprice >= 2*PurchasePrice (Product) = Ф


i.       The gender of an employee should be “Nam” or “Nữ”.
R1 ← π Employee.Gender = ‘Nam’ (Employee)

R2 ← π Employee.Gender = ‘Nữ’(Employee)

R1 ∩ R2 = Ф
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.

R1 = σPurchasePrice, SellPrice (Product)


R1 = σPurchasePrice, SellPrice (Product)
σR1.ProductCode ≠ R2.ProductCode  R1.PurchasePrice = R2.PurchasePrice  (R1.SellPrice – R2.SellPrice >

R1.PurchasePrice/2  R2.SellPrice – R1.SellPrice > R1.PurchasePrice/2 ) (R1 x R2) = ∅

You might also like