0% found this document useful (0 votes)
13 views3 pages

Nguyen Thi An

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Nguyen Thi An

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Lab 1 : Algebraic query language

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)

Write expressions of relational algebra to answer the following queries:


a. Find name and sell price of televisions supplied by Samsung.
Name,SellPrice(type= ’TV’ and supplierName= ‘Samsung’(Product ⋈ Supplier)

b. Find name and address of all suppliers who supply television product.
suplier name(type = ‘TV’(Product ⋈ Supplier)

c. Find name of all employee who were born in 1983.


fullName(BirthDate >=’1/1/1983’ and BirthDate <=’31/12/1983’(Employee))

d. Find name and type of all products sold in ‘23/05/2018’.


Name,Type(sellDate=’23/05/2018’((InvoiceLine⋈ Inovice) ⋈ Product)

e. Find name of female employees who sold televisions.


fullName(gender=’female’ and type=’TV’(((InvoiceLine⋈Inovice)⋈ Product) ⋈Employee)

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.

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

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

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

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

f. There is no invoice without product.

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.

i. The gender of an employee should be “Nam” or “Nữ”.

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.

ABS: tính trị tuyệt đối

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy