You are on page 1of 3

Lab1:

Ex1:
a. R := π(Name, SellPrice) (σ(SuplierName = ”Samsung” && type = ”television” )
(Product ⋈ Supplier))
b. R := π(SuplierName, Address) (σ(type = ”television” ) (Product ⋈
Supplier))
c. R := π(FullName) (σ(BirthDate ≥ 01/01/1983 && BirthDate ≤ 31/12/1983)

(Employee))
d. R := π(Name, Type) (σ(SellDate = 23/05/2018) ((InvoiceLine ⋈
Invoice) ⋈ Product))
e. R := π(FullName) (σ(Gender = “female” && Type = “television”)
((InvoiceLine ⋈ Invoice) ⋈ Product) ⋈ Employee))
f. R1 := π(SupplierName, Address) (σ(Type = “television” (Product ⋈
Supplier))
R2 := π(SupplierName, Address) (σ(Type = “mobile” ) (Product ⋈
Supplier))
 R := R1 ⋂ R2
g. R := π(Name, Price) (σ(FullName = “Nguyễn Văn A” && SellDate ≥ 1/4/2018 &&
SellDate ≤ 30/4/2018) (((InvoiceLine ⋈ Invoice) ⋈ Product) ⋈

Employee))
h. R := π(Name, Price) (σ(Type = “mobile” && Supplier = “Samsung” && SellDate ≥
1/4/2018 && SellDate ≤ 30/4/2018) ((InvoiceLine ⋈ Invoice) ⋈

Product))
i. R1 : = ρ(Product)
R2 : = ρ(Product)
R3 := σR1(R1 ⋈ϴ R2)
ϴ = R1.SellPrice < R2.SellPrice
 R := R1 – R3
j. R := π(amount = Quantity*SellPrice) (σ(SellDate = 30/4/2018)

((InvoiceLine ⋈ Invoice) ⋈ Product))


Ex2:
a. σ(SellPrice ≤ PurchasePrice) (Product) = ∅
b. σ(SupplierName = “Samsung” && Type <> “television” && Type <> “mobile” && Type
<> “tablet” ) (Product ⋈ Supplier) = ∅

c. R1 := π(SupplierCode) (σ(Type = “mobile” || Type = “tablet”) (Product))


R2 := π(SupplierCode) (σ(Type = “food” ) (Product))
 R1 ⋂ R2 = ∅
d. R1 := ρ(InvoiceLine)
R2 := ρ(R1)
σ(R1.ProductCode = R2.ProductCode && R1.InvoiceID = R2.InvoiceID && R1.Quantity <>
R2.Quantity) (R1 x R2) = ∅

e. σ(Quantity) ≤ 0 (InvoiceLine) = ∅
f. (π(InvoceID) (Invoice) – π(InvoiceID) (InvoiceLine) = ∅)
&& (π(ProductCode) (InvoiceLine) – π(ProductCode) (Invoice)
=∅)
g. σ(PurchasePrice < 500000 && SellPrice > 9000000) (Product) = ∅
h. σ(SellPrice > 2*PurchasePrice) (Product) = ∅
i. σ(Gender <> “Nam” && Gender <> “Nữ”) (Employee) = ∅
j. R1 := ρ(Product)
R2 := ρ(R1)
σ(R1.PurchasePrice = R2.PurchasePrice && |R1.SellPrice – R2.SellPrice| >

0,5*R1.PurchasePrize) (R1 x R2) = ∅

You might also like