Lab : Algebraic query language We have the database consist of relations



tải về 14.05 Kb.
Chuyển đổi dữ liệu15.01.2024
Kích14.05 Kb.
#56328
Lab 1 RA


Lab 1 : Algebraic query language

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)

Exercise 1: Write expressions of relational algebra to answer the following queries:

  1. Find name and sell price of televisions supplied by Samsung.

  2. Find name and address of all suppliers who supply television product.

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

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

  5. Find name of female employees who sold televisions.

  6. Find name and address of suppliers who supply both television and mobile.

  7. List name and price of all product sold by employee “Nguyễn Văn A” in April 2018.

  8. Find name and price of all mobile products of Samsung sold in April 2018.

  9. Find the product with highest SellPrice.

  10. Find the amount (quantity * sellPrice) of each invoice line of product sold in 30/04/2018.


Exercise 2: Use Relational Algebra to express following constraints:

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

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

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

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

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

  6. There is no invoice without product.

  7. If purchase price is less than 500.000 VND, the sell price could not be greater than 9.000.000 VND.

  8. The sell price could not be greater than 2 times the purchase price.

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

  10. 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.

tải về 14.05 Kb.

Chia sẻ với bạn bè của bạn:




Cơ sở dữ liệu được bảo vệ bởi bản quyền ©hocday.com 2024
được sử dụng cho việc quản lý

    Quê hương