1. Trang chủ
  2. » Luận Văn - Báo Cáo

final assignment projects name vinamilk store database management

15 0 0
Tài liệu được quét OCR, nội dung có thể không chính xác
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

Trang 1

INTERNATIONAL SCHOOL VIETNAM NATIONAL UNIVERSITY

Trang 2

Table of Content

1 Collecting informafion nh nh nh nh kg 111111111 11111 kg 3

3 INfPOMUCTION ADOUT OUP PLOjSCt 0 rdaaáảäắä44 3

Trang 3

| Introduction 1 Collecting information

Currently, the demand for nutritional supplements is increasing, causing the number of customers looking for milk to increase So, our team collected data on the business performance of a dairy store

We collect information through interview method

Step 1: We prepare questions about business performance to interview sellers These questions relate to:

+/ List of buyers and personal information of some customers, list of milk, order details and ingredients therein (With a commitment not to use for bad purposes)

+/ See product price list

Step 2: We go to this store and ask the salesperson there During the interview process, our group had a member write down key information about the store's operations At the same time, we also used a tape recorder to record the entire interview process and a camera to take some necessary photos

Step 3: We screen essential ideas and start working on our project Overall, the scope of this project involves sales activities at the dairy store

2 Business narratives

First, when a customer comes to buy for the first time, the payment counter will take the customer's information including: Name, Date of Birth, Gender, Phone Number, Email and save a unique ID to avoid duplicates Repeat with others Next, the salesperson and customer will discuss with each other about the customer's needs and offer suitable products An order will contain 1 or more different types of milk depending on the buyer's needs

3 Introduction about our project

Analytical tools allow store owners to create customized treatment plans to suit their store The effectiveness of database administration for data management has been recognized by organizations Data management is often critical to management decisions and the success of management decisions is critical to enhancing the business organization.

Trang 4

For your convenience, we have created a Management System on a specifically written Dairy Store Database Design

The main goal of this project is to create a database program for dairy stores This data is useful for any or all of the following reasons:

+/ Want to get off to a good start with your new way of exercising +/ There is a need to buy an existing practice shop

+/ Want to develop and expand the scale of your operations effectively

Il DATABASE SYSTEM IMPLEMENTATION

1 Entity-relationship diagram

maHD masP maKH

Trang 5

+/ Second, CHITIETHOADON provides more quantity, price and total compared to HOADON

+/ The third object is SANPHAM, which provides information such as: product code, product name, unit and price

+/ Next is the entity This provides employee code, employee name, store name

+/ Then, the 5th object is KHACHHANG including customer code, customer name and phone number

2 High level database model

NghanhHang

2.2 Explain the relationship between tables

Additionally, we have 5 entities in the ERD corresponding to 5 tables Among the entities that appear linked is 1 — Many.

Trang 6

1 — Many

To represent a 1-to-many relationship in a database, take the primary key on the "One" side of the relationship, then add that key as one or more additional fields to the table on the "Many" side of the relationship relationship

3 Relational schema

NHANVIEN (employee code, employee name and store name)

HOADON (Invoice code, Customer code, employee code, product code, date of sale and payment)

CHITIETHOADON(Invoice code, Customer code, product code, quantity, price,

promotion, total, payment)

KHACHHANG (customer code, customer name, phone number) SANPHAM (product code, product name, unit, retail price, product line 4 Code SQL

NhanVien

CREATE TABLE NhanVien (

maNV VARCHAR(255) PRIMARY KEY NOT NULL, TenNV VARCHAR (255),

TenCH VARCHAR(255) )›

KhachHang

CREATE TABLE KhachHang (

maKH VARCHAR(255) PRIMARY KEY, TenKH VARCHAR(255) ,

SDT VARCHAR(15)

)3

SanPham

Trang 7

CREATE TABLE SanPham (

maSP VARCHAR(255) PRIMARY KEY, TenSP VARCHAR(255),

DonVi VARCHAR(255), GiaBanLe FLOAT,

NganhHang VARCHAR(255)

)3

HoaDon

CREATE TABLE HoaDon (

maHD VARCHAR(255) PRIMARY KEY, maKH VARCHAR(255) ,

maNV VARCHAR(255) , maSP VARCHAR(255) , NgayBan DATE,

ThanhToan VARCHAR(255),

FOREIGN KEY (maKH) REFERENCES KhachHang (maKH),

FOREIGN KEY (maNV) REFERENCES NhanVien(maNV) ,

FOREIGN KEY (maSP) REFERENCES SanPham(maSP )

)3

ChiTietHoaDon

CREATE TABLE ChiTietHoaDon ( maHD VARCHAR(255) , maSP VARCHAR(255) , SoLuong INT, Gia FLOAT, TongCong FLOAT, KhuyenMai FLOAT, ThanhToan FLOAT,

PRIMARY KEY (maHD, maSP),

FOREIGN KEY (maHD) REFERENCES HoaDon(maHD) , 7

Trang 8

FOREIGN KEY (maSP) REFERENCES SanPham(maSP)

Insert data into KhachHang table

INSERT INTO KhachHang (maKH, TenKH, SDT)

VALUES

('CUS.NG10833.01675', ‘Nguyen Thi Huong’, '@123456789'),

('CUS.NG10033.00219', ‘Chi Thuy’, '@987654321'), ('CUS.NG1@@33.01673', 'Nhung Mui', '@123456789'), ('CUS.NG1@@33.01678', 'Yen E Viet', '@987654321'), ('CUS.NG1@@33.0@752', 'Nguyen Thi Thu', '@123456789'), ('CUS.NG10@33.00@120', ‘Cu Sinh', '@987654321'), ('CUS.NG1@@33.00655', 'Em Duong', '@123456789'),

('CUS.NG10@33.00414', ‘Nguyen Thi Ngoc Anh', '@987654321'),

('CUS.NG1@@33.01679', 'Ngoc Thuy', '@123456789'),

('CUS.NG19@33.01293', ‘Nguyen Thi Von Anh', '@987654321'), ('CUS.HA10051.00828', 'Nguyen Thi My Hoa', '@123456789'),

('CUS.NG10@33.0@309', ‘Chi Phuong Hoa', '@987654321'), ('CUS.NG1@@33.0@274', 'Cu Minh', '@123456789'), ('CUS.NG1@@33.01449', 'Do Thi Lan', '@987654321'), ('CUS.NG10@33.@1292', ‘Anh Duc’, '@123456789'),

('CUS.NG10033.00021', 'Ngu Tuyet Nhung', '9987654321'),

('CUS.HA19951.00946', 'Canh Thi Phuong', '@123456789'), ('CUS.NEW@@1.0@1', ‘Minh Hieu', '@9876543210'),

8

Trang 9

('CUS ('CUS ('CUS ('CUS ('CUS ('CUS ('CUS

Insert

NEW@@2.0@2', ‘Chu Viet Dung’, '@1234567890'), NEWQ@3.003', ‘Nguyen Bang Qua’, '@4567890123'), HA10@51.@1078', ‘Quynh Anh', ‘'@123456789'), NG10@33.01688', ‘Boc Tuan’, '9987654321'), HA10@52.00780', ‘Nguyen Mai Lion', '@123456789'), NG10031.00207', 'Bá Thi Hien', '9987654321'), NG10@33.01076', ‘Bui Doon Hung’, '9123456789'); data into SanPham table

INSERT INTO SanPham (maSP, TenSP, DonVi, GiaBanLe, NganhHang)

VALUES

('@2ED11', 'SB VNM Sure Diecerna HT9@@g', NULL, 599422, 'A'), ('@4CI1@', 'SDD co duong VNM ADM 18@ml', NULL, 7355, 'C'), ('AQ1264', 'Tyi nhua tai che thon thien moi truong loai to', NULL, NULL, 'G'),

('@2HO15', 'SUDD Optimum Gold 18@ ml.', NULL, 14807, 'A'), ('@4EC12', 'STTT socola VNM 18@ml.', NULL, 8197, 'C'),

('@2HL34', 'SUDD Dielac Grow Plus 11@ml (Sua non).', NULL, 8648, 'A'), ('@7UR11', 'SCU Probi duong 65m1l', NULL, 4998, 'D'),

('@4US38', 'TU Sua Sucula Lua Mach Vinamilk Susu hop 110ml - KM’, NULL, 4374, 'A'),

('@7ND10', ('87UC18", ('@2HO35', ('81TD68', (‘@4LL11', ('ô4EDô2', ('@4ED32', ('@4ED12', ('@45S87', 3996, 'A')

'SCA VNM nha dam 199g", NULL, 7693, 'D'),

'SCU Probi Pedia+ huong cam 65m1', NULL, 5695, 'D'), 'SUDD Optimum Gold 116 m1.', NULL, 9189, 'A'),

"SDCD ong Tho do tuyp 165g', NULL, 18695, 'B'),

"SDD khong lactoza-Flex 18@ml', NULL, 7884, 'C'), 'STTT co duong VNM 1L.', NULL, 35867, 'C'), 'STTT co duong VNM 11@ml.', NULL, 5184, 'C'), 'STTT co duong VNM 18@ml.', NULL, 8197, 'C'),

"TU Sua Socola Lua Mach Vinamilk Susu chai 8@ml -KM', NULL,

Trang 10

('@9CC25', ‘Kem Socola H.nhon Delight Vinamilk 8@ml (12C/T)', NULL,

10407, 'G'),

('@7PR5@', 'SCA Probi co duong 199g', NULL, 7538, 'D'),

('@7UL3@', 'SCU Probi Happy co duong vi Luu Do 13@ml', NULL, 9698,

'D),

('@4EI32', 'STTT co duong VNM 110m1.', NULL, 5184, 'C');

Insert data into HoaDon

INSERT INTO HoaDon (maHD, maKH, maNV, maSP, NgayBan, ThanhToan) VALUES

('SAL.NG109833231201000901', 'CUS.NG10933.01675', 'NG1@@33', '@2ED11', ‘2023-12-01 @8:37:58', '1,114,925'),

('SAL.NG10983323120200903', 'CUS.NG10933.01673', 'NG10033', '02HO15", ‘2023-12-02 16:57:37", '118,456'),

('SAL.NG10983323120200904', 'CUS.NG10933.01678', 'NG10033', '04EC12"', '2023-12-02 18:57:51', '90,495'),

('SAL.NG10983323120200906"', 'CUS.NG10033.00120', 'NG10033', '07UR11"', ‘2023-12-02 19:28:07", '149,700'),

('SAL.NG10@3323120300008', ‘CUS.NG10@33.00655', 'NG10033', '04US38"', ‘2023-12-03 16:34:40', '15,746'),

('SAL.NG10983323120400001', ‘CUS.NG10033.00414', 'NG1@@33', '@7ND10', ‘2023-12-04 @7:40:46', '332,@99'),

('SAL.NG10@3323120400005', 'CUS.NG10933.01678', 'NG1@@33', '@7UC10', ‘2023-12-04 18:17:25', '28,025'),

('SAL.NG10983323120400006"', 'CUS.NG10933.01679', 'NG10033', '04ED12", ‘2023-12-04 18:37:30', '241,320'),

('SAL.NG10983323120400012', 'CUS.NG10933.01293', 'NG10033', '02HO35", '2023-12-04 20:55:59', '73,440'),

('SAL.NG10@3323120500001', 'CUS.HA10951.00828', 'NG10033', '01TD69", '2023-12-05 @8:56:13', '2,422,872'),

10

Trang 11

('SAL.NG1983323120509006', 'CUS.NG19033.00309', 'NG19633', '04LL11", '2023-12-@5 14:06:03', '696,864'),

('SAL.NG10@33231206000@6', 'CUS.NG1@@33.00274', 'NG1@@33', '@7UR11', '2023-12-@6 17:22:24', '49,90@'),

('SAL.NG10@33231207@00@3', 'CUS.NG1@@33.01449', 'NG1@@33', ‘@4EDe2', '2023-12-@7 14:58:51', '374,523'),

('SAL.NG10@3323120700012', 'CUS.NG10@33.01292', 'NG1@@33', '@4ED32', '2023-12-@7 15:09:35', '11@,751'),

('SAL.NG10@3323120700032', 'CUS.NG10@33.00021', 'NG1@@33', '@4ED12', '2023-12-@7 15:26:11', '401,316'),

('SAL.NG10@33231208000@8', 'CUS.HA1@@51.00940', 'NG1@@33', '@45S87', '2023-12-@8 20:12:10', '7,193'),

('SAL.NG10@33231212@00@8', 'CUS.HA1@@51.01078', 'NG1@@33', '@9CC25', '2023-12-12 16:46:03', '8,846'),

('SAL.NG10@3323121400019', 'CUS.NG10@33.01688', 'NG1@@33', '@7PR5Q', '2023-12-14 19:33:27', '83,22@'),

('SAL.NG10@3323121400028', 'CUS.HA1@@52.00780', 'NG1@@33', '@7UL30', '2023-12-14 20:06:15', '186,2@2'),

('SAL.NG10@33231220@00@2', 'CUS.NG10@31.00207', 'NG10@33', '‘@4EI32', "2023-12-20 11:29:12', '241,367'),

('SAL.NG10@33231221000@3', 'CUS.NG1@@33.01076', 'NG10@33', ‘'@4ED12', "2023-12-21 13:24:32', '381,652');

Insert data into ChiTietHoaDon

INSERT INTO ChiTietHoaDon (maHD, maSP, SoLuong, Gia, TongCong,

KhuyenMai, ThanhToan)

VALUES

('SAL.NG1993323120109001', '92ED11', 2, 599422, 1198844, 77703, 1114925),

('SAL.NG1993323129209903', '02HO15', 8, 14867, 118456, NULL, 118456), 11

Trang 12

('SAL.NG1003323120200004', '@4EC12', ('SAL.NG10@3323120200006', '@7UR11', ('SAL.NG1003323120300008', '@4US38', ('SAL.NG1003323120490001', '@7ND10', ('SAL.NG10@3323120400005', '@7UC10', ('SAL.NG1983323120409906', '94ED12', ('SAL.NG1983323120409012', '92H035", ('SAL.NG1983323128509901', '91TD69', 2422872) ,

('SAL.NG10@332312@500006', '94LL11', ('SAL.NG100332312@600006', '@7UR11', ('SAL.NG10@3323120700003', '@4EDe2", 374523),

('SAL.NG10@3323120700012', '@4ED32', ('SAL.NG10@3323120700032', '@4ED12', ('SAL.NG1003323120800008', '@4SS87', ('SAL.NG10@3323121200008', '@9CC25', ('SAL.NG10@3323121400019', '@7PR5Q', ('SAL.NG10@3323121400028', '@7UL30', ('SAL.NG10@3323122000002', '@4EI32', ('SAL.NG10@3323122100003', '@4ED12',

5 Queries and Solution

12, 8197, 98364, 7286, 90495), 38, 4990, 149700, NULL, 149706), 4, 4374, 17496, 1628, 15746),

48, 7693, 364944, 30413, 332099), 5, 5695, 28025, NULL, 28025), 32, 8197, 262394, 19439, 241320), 8, 9180, 73440, NULL, 73449), 144, 18695, 2692080, 249264, 96,

10, 12,

24, 55,

7884, 4990,

756864, 55556, 696864), 49999, NULL, 49989), 35867, 430404, 51742,

5184,

2, 3996, 7992, 740, 7193), 1, 10497,

12, 24, 48, 48,

7538, 9698, 5184, 8197,

10407, 1445, 8846), 90456, 6701, 83220), 232752, 43104, 1862@2), 248832, 6912, 241367), 393456, 10930, 381652);

wWhat are the top-selling products in terms of quantity sold?

SELECT maSP, TenSP, SUM(SoLuong) AS TotalQuantity

12

Trang 13

FROM DuLieuThang12 GROUP BY maSP, TenSP ORDER BY TotalQuantity DESC;

How many products of each category have been sold?

SELECT NghanhHang, COUNT(*) AS TotalProductsSold

FROM DuLieuThang12 GROUP BY NghanhHang;

what is the total revenue for each day in the month of December?

SELECT NgayBan, SUM(TongCong) AS TotalRevenue

FROM DuLieuThang12 WHERE NgayBan LIKE '12/%' GROUP BY NgayBan;

What is the total number of customers in the database?

SELECT distinct COUNT(*) AS TotalCustomers

wWhat is the total revenue for each product?

SELECT maSP, TenSP, SUM(TongCong) AS TotalRevenue

FROM DuLieuThang12 GROUP BY maSP, TenSP;

what is the average quantity sold per order?

SELECT AVG(SoLuong) AS AverageQuantitySold

Trang 14

wWhat is the average price of each product category?

SELECT NghanhHang, AVG(Gia) AS AveragePrice

FROM DuLieuThang12 GROUP BY NghanhHang;

Sort sales revenue by date from high to low

SELECT NgayBan, SUM(TongCong) AS TotalRevenue

FROM DuLieuThang12 GROUP BY NgayBan

ORDER BY TotalRevenue DESC

Write sql code show the purchaser form high to low

SELECT maKH, TenKH, SUM(TongCong) AS TotalPurchases

FROM DuLieuThang12 GROUP BY maKH, TenKH

ORDER BY TotalPurchases DESC;

Sort sales of each product from high to low

SELECT maSP, TenSP, SUM(SoLuong) AS TotalSales

FROM DuLieuThang12 GROUP BY maSP, TenSP ORDER BY TotalSales DESC;

14

Trang 15

6 Member’s works

+ Queries and solution

+ Relational schema

Nguyễn Gia Quang Minh (Leader) | + Code SQL

+ High-level database model

+ Queries and solution

Conclusion

Through the course, we self-assess what we have learned:

e« Second, we learned how to apply SQL Server tools to enhance data presentation and

analysis performance

+ Overview of databases, definitions of database structures + Learn and grasp about Relational Database Modeling

+ Understand The Database Language SQL

problems

Therefore, we believe that they will help us in the future learning process 15

Ngày đăng: 08/08/2024, 18:33