Ex05 SQL Stationery Management System
Ex05 SQL Stationery Management System
STAFF
StaffID Fullname PhoneNumber StartDate
NV01 Nguyễn Văn 098765431 04/09/2002
A
NV02 Nguyễn Văn B 098765432 07/06/2002
NV03 Nguyễn Văn C 098765433 26/04/2001
NV04 Nguyễn Văn 098765434 07/12/1997
D
NV05 Nguyễn Văn E 098765435 20/08/2002
Customer
Custom FullName Address PnoneNum Date of Revenue Registration
erID ber Birth Date
KH01 Trần Nhật Hoàng Khánh Hải - Ninh Hải - Ninh Thuận 091812345 03-01-98 14000000 20/12/2002
KH02 Phạm Minh Hoàng Lương Ngọc Quyến, Phủ Hà, Phan Rang 091234551 05-01-99 33250000 15/05/2002
KH03 Hứa Ngọc Huân Ký túc xá đại học FPT 031234225 05-01-97 12350000 16/10/2002
KH04 Lê Thanh Huấn Phú Hoà, Ninh Hoà, Khánh Hoà 078512345 06-01-98 12350000 06/07/2001
KH05 Vũ Chí Hùng Thôn Đắc Nhơn 3, Ninh Sơn, Ninh Thuận 091234587 16-01-98 9500000 11/02/2001
KH06 Ngô Văn Hưng Võ Trứ, Mỹ Bình, Phan Rang 037123450 07-01-98 7500000 12/08/2002
Product
ProductID ProductName UniTofMeasure CountryOfOrigin Price
BD Băng dính cuộn Anh 20000
BG Bảng ghim hộp Pháp 25000
BKDN Băng keo dán nền hộp Mỹ 17000
BKD Băng keo đục cái VN 30000
BKG Băng keo giấy cái VN 25000
BKHM Băng keo hai mặt hộp Pháp 17000
BKT Băng keo trong cái Mỹ 20000
BKV Băng keo vải cái VN 25000
BKVP Băng keo văn phòng cái Pháp 17000
BKX Băng keo xốp cái Pháp 19000
Invoice
InvoiceID InvoiceDate CustomerI StaffID InvoiceValue
D
1001 12-06-19 KH01 NV01 20000000
1002 29-03-19 KH02 NV02 25000000
1003 27-03-19 KH03 NV03 17000000
1004 28-03-19 KH04 NV04 30000000
1005 30-03-19 KH05 NV05 25000000
1006 07-01-19 KH06 NV01 17000000
1007 06-03-19 KH07 NV02 20000000
1008 06-07-19 KH08 NV03 25000000
1009 06-11-19 KH09 NV04 17000000
1010 20-04-19 KH10 NV05 20000000
InvoiceDetail
InvoiceID ProductID Quantity
1001 BD 10
1001 BKG 43
1002 BG 12
1002 BKDN 47
1003 BKG 14
1003 BKDN 51
1004 BKD 16
1004 BKG 55
1005 BKHM 18
1005 BKG 59
1006 BKHM 20
1006 BKHM 63
1007 BKHM 22
1007 BKT 67
1008 BKV 13
1008 BKHM 71
1009 BKVP 17
1009 BKVP 75
1010 BKX 21
1010 BKT 79
1. Create relationships and declare primary and foreign keys of the relationships.
2. Add the Note attribute with data type nvarchar(20) to the Product relationship.
3. Add the CustomerType attribute with data type tinyint to the Customer relationship.
4. Update name "Nguyễn Văn B" for Customer data with code KH01
5. Update the name “Nguyễn Văn Hoàn” for Customer data with code KH09 and registration year
2007
6. Change the data type of the Note attribute in the Product relation to varchar(100).
7. Delete the Note attribute in the Product relation.
8. Delete the CustomerType attribute in the Customer relation
9. Insert data into the tables
10. Show the information relevant to the customers in Ninh Thuận with information such as Customer
Code, Full name, address, phone number, date of birth (displayed by day/month/year).
11. Shows a list of customers whose last name is "Lê" including information about Customer Code,
Full Name, Address, Phone Number.
12. Shows the total value of goods sold in the months including information: Month, Total value
13. Shows the average amount of sales per month
14. Show what items the customer “Phạm Minh Hoàng” bought at the store. Information includes
Product code, quantity, total price.