Uploaded by Đạt Nguyễn

Lap 1 - Relational Algebra

advertisement
I. Given the following database tables:
N
o
I
1
2
Products Table
ProductID
ProductName
3
NumInStock
II
1
2
3
III
1
2
3
IV
1
2
3
4
Products Table
Product code
Product's name
Quantity of products in
stock
Bảng Sản phẩm
Mã sản phẩm
Tên sản phẩm
Số lượng sản phẩm tồn
kho
Customers Table
CustomerID
CustomerName
CustomerAddress
Customers Table
Customer's code
Customer name
Customer's address
Bảng khách hàng
Mã Khách hàng
Tên khách hàng
Địa chỉ của khách hàng
Invoice Table
InvoiceID
DateInvoice
CustomerID
Invoice table
Invoice code
Date of invoice
Customer's code
Bảng hóa đơn
Mã hóa đơn
Ngày xuất hóa đơn
Mã Khách hàng
InvoiceDetails Table
Bảng Chi tiết hóa đơn
Invoice code
Product code
Number of products sold
Unit price
Mã hóa đơn
Mã sản phẩm
Số lượng sản phẩm đã bán
Đơn giá
InvoiceDetails
Table
InvoiceID
ProductID
NumSold
PriceUnit
II. Information and data of Database tables
Products
ProductID
P01
P02
ProductName
Dell computers
Canon printer
NumInStoc
k
578
752
P03
Panasonic projector
463
P04
HP Computer
916
Customers
CustomerID
CustomerName
C01
C02
C03
C04
Tran Bao Minh
Le Nam Giang
Nguyen Bich Ngoc
Mac Dinh Minh
CustomerAddres
s
Ha Noi
Nam Dinh
Son La
Hai Phong
Invoice
InvoiceID
DateInvoice
I01
I02
I03
I04
CustomerID
11-09-23
12-09-23
13-09-23
14-09-23
C02
C04
C03
C01
InvoiceDetails
InvoiceID
I01
I02
I03
I04
ProductID
P01
P02
P03
P04
NumSold
25
30
15
40
PriceUnit
22.000.000
7.000.000
8.000.000
17.000.000
III. Using relational algebra expression to answer below queries
1. List customer codes and customer addresses in the customer table
2. List the product name and product quantity in the product table
3. List product codes and product names with a quantity of products in stock
greater than 500 products.
4. Find out the customer code and Invoice date of the customer with an address
in Nam Dinh.
5. List names of customers who had purchase invoices on 12-09-2023.
6. List product codes and product names with unit prices greater than
10.000.000
7. Find out the name of the customer with an address in Son La with a purchase
invoice on 13-09-2023
8. List product codes and product names sold on 14-09-2023.
9. List product codes that have never been sold
10. List customer codes that have never made a purchase on 11-09-2023
Download