The database system will support the management of transactions such as product orders, customer invoices, and information customers.. Vietnam Tea Coffee Service Trading Joint Stock Comp
Trang 1VIETNAM NATIONAL UNIVERSITY, HANOI INTERNATIONAL SCHOOL
Subject: DATABASES REPORT FINAL EXAM
Nguyen Anh Tu — 20070998 Dang Thi Hien — 20070927 Doan Minh Hieu — 21070813
Hanoi, 12" December, 2022
Trang 2
MEMBERS’ CONTRIBUTION
1 Nguyen Anh Tu
20070992
2 Dang Thi Hien
20070927
3 Doan Minh Hieu
21070813
4 Le Thi Huyen Trang
20070992
Trang 3
TABLE OF CONTENTS
CHAPTER 1: INTRODUCTION uu ccssccsscssscsecscecserssesseersenecencetsensccnsenecesessensecacencertsenceecenecenace 6
1, Abouf the (QPQGHỈ2GfÍOH, TH ch nh gà” 6
2 Ñ€QHITCHICHÍ SDGCÍÍÏCŒÍ[OH, HH ĐH ĐT ĐT Hoá ngà 6 2.1 Methods for investigating business rules -. - - -< «=5 =2 *>
2.2 Business NarrAafÏV on nọ ng nh no Ki Ki Hi on Bi Bi in Bi
CHAPTER 2: ANALYSIS 1ND DESIGNING D/1LLB/4SEX cằSeSeSssce, 8
3 Some reql dadfq qHd SỢT sCFIDES - on kg nh nh ve
1 Đesigrn some usefMI reporfs qnd tƒ0rmufion 0F redl Hsdg 10
3 Soluffoms for the abOV€ F€DOFÍS HH HT HH nọ hp 15
Trang 4
ABSTRACT
Coffee is a drink of people who go to work, and office people, but recently coffee is also loved by young people Besides, the demand for people is increasing compared to the business of opening more coffee shops This report is investigating the direct sales system of The Coffee House at 47 Nguyen Tuan, Thanh Xuan District, Hanoi
Opening a coffee shop needs many factors: finance, facilities, and favorable geography for business development Besides, how to manage your cafe is also a big question to be solved
So how to quickly manage and save a significant amount of time? Therefore, our group has researched and designed a database system for The Coffee House cafe based on the knowledge
we have gained when researching this topic
The database system will support the management of transactions such as product orders, customer invoices, and information customers Maintained databases typically containing order details, product details, and employee information We use SQL Server to connect to the database and perform various operations This will help the system management of The Coffee House become more optimal, the management easier and more convenient
Trang 5CHAPTER 1: INTRODUCTION
1 About the Organization
With the “invasion” of many famous international coffee brands, the Vietnamese startup
brand has only appeared in the past few years but has achieved great results in business, which is the coffee chain The coffee House - the dream "Coffee house" in the heart of the city
Vietnam Tea Coffee Service Trading Joint Stock Company - also known as The Coffee House is a Vietnamese coffee brand chain formed in 2014 by Nguyen Hai Ninh (currently the Vice President of the company) ) The Coffee House is aimed at young customers who prefer a luxurious space to work and play at a mid-range price (30 000 — 60 000 VND) Currently, The Coffee House has appeared in many big cities across the three regions such as Ho Chi Minh, Hanoi, and Da Nang, along with about 160 stores, serving more than 40,000 customers per day Becoming the leading coffee brand chain in Vietnam and reaching out to the world Combining traditional and modern design, creating the unique essence of The Coffee House The Coffee House will be the convergence of coffee lovers and enthusiasts The Coffee House along with its mission that when working with all sincerity and respecting the original values of each employee as well as the customer, everyone will receive joy small, get better and make others better day by day
2 Requirement Specification:
2.1 Methods for investigating business rules:
a Interview
Our team approached this topic through a team member who was an employee of The Coffee House so we were able to understand the topic well and decided to research it
News/Web
The Coffee House owns its own online website to expand its clientele Its website has all the information about other facilities of the system nationwide, product information on the online menu, without having to go to their store In addition, we also learn about The Coffee House
through social networking sites Besides, The Coffee House has launched its own mobile
application, bringing interesting technology experiences to users
b Observation
The coffee house is a brand favored by young people and we are its customers, so it is easy to access information about The Coffee House through store management and draw the following conclusions:
« Simplify the bookkeeping information by storing it in the computer system
* Help to manage the system of the restaurant more optimally, the management is easy and convenient
2.2 Business Narrative:
All The Coffee House products have a ProductID and other stored information
This is the process of the direct sales system at The Coffee House:
Process 1: Direct sales
Trang 6- Products order: Based on The Coffee House's menu, guests will order products according to their needs and record them by the cashier on the Order_Detail
Process 2: Payment
Create invoices: The cashier will create an Invoice based on the actual quantity that the guests have ordered in the Order_Detail and collect the exact amount that they have to pay
There are two options for payment: Cash / Credit Card
Guest can choose between two options for ways for the cashier to draft the Invoice
- Customers will receive invoices
— Finish the payment and receive products
In order to maintain track of staff working with invoices, each person's information will be kept
on the system is Staff: which includes Staff ID, Staff name, Staff phone
CHAPTER 2: Analyzing and Designing the Databases
1 ERD:
Address ` J
\ -
chuyền
—
Category
Has
— ( Orden ` |
Product
eo”
( Title Sm =
( PriceTotal `
( CategoryID ) /
2 Relational Schema:
fF ullName )
ID
F—— ‹ oe )
Customer
J aS
es =
| PhoneNumber )
| ZL
Ằ% ¡ PrcsTotal )
~ \ A
( Orderpate ) ~~
| ⁄
⁄ Own
— À— =7 _L < ProductiD )
Trang 7
Address Gender
PhoneNumber
Category (ID, Name )
PRIMARY KEY(D)
Product (ID, Title, Price, Category_ID)
PRIMARY KEY(ID)
FOREIGN KEY (Category_ID) REFERENCES Category(ID)
Staff (ID, FullName, Address, Gender, Birthday, PhoneNumber)
PRIMARY KEY(D)
Customer (ID, FullName, Gender, Birthday, PhoneNumber)
PRIMARY KEY(D)
Orders (ID, CustomerID, StaffID, PriceTotal, OrderDate)
PRIMARY KEY(D)
FOREIGN KEY (CustomerID) REFERENCES Customer(ID)
FOREIGN KEY (StaffID) REFERENCES Staff(D)
OrderDetail (ID, OrderID, ProductID, Price, Num, PriceTotal)
PRIMARY KEY(ID)
FOREIGN KEY (OrderID) REFERENCES Orders(ID)
FOREIGN KEY (ProductID) REFERENCES Product(ID)
3 Some real data and SQL scripts :
Here is some sql script data of Category table
Trang 8ID int primary key identity(1,1),
Name nvarchar(5@) not null
)
Go
=\Insert into Category(Name) values
(‘Coffee’),
(‘Tea’),
(‘Freeze’),
(‘Juice’),
| ("Smoothie")
Go
Here is some sql script data of Product table
=\Create table Product(
ID int primary key identity(1,1),
Title nvarchar(5@) not null,
Price float,
Category_ID int references Category(ID)
)
Go
(‘Latte’,'65000','1'),
(‘Espesso' ,'45000','1"),
(‘Mocha' ,'45000",'1'),
(‘Oolong Tea’ ,'45000','2')
(‘Matcha Freeze’ ,'55000','3'),
(‘Chocolate Freeze’, '55000','3'),
(‘Caramel Freeze’ ,'55000','3'),
(‘Coffee Freeze’ ,'55000','3'),
(‘Apple Juice’ ,'40000",'4'),
(‘Orange Juice’, '40000','4'),
(‘Watermelon Juice’, *40000','4'),
(‘Guava Juice’ ,'40000','4'),
(‘Strawberry Smoothie’ ,'55000",'5'),
(‘Blueberry Smoothie’ ,'55000','5'),
(‘Mango Smoothie’ ,"55000",'5"),
| (‘Apple Smoothie’ ,'55000",'5")
Go
Here is some sql script data of Staff table
Trang 9ID int primary key identity(1,1),
FullName nvarchar(5@) not null,
Address nvarchar(2090),
Gender nvarchar(20),
Birthday date,
PhoneNumber nvarchar(2@)
)
Go
=Insert into Staff(FullName,Gender ,Birthday,PhoneNumber, Address) Values (‘Le Ha Nam', ‘Male’, 2000/12/30" , '@392433993",'Ha Noi’),
(‘Ho Tu Tai’, ‘Male’ ,'2002/12/09' ,'@34922899','Ha Nam'),
(‘Ngo Thu Huong", ‘Female’ ,' 2002/09/24" ,'@816788344','Lao Cai'), (‘Do Hai Nam', ‘Male’ ,' 2000/03/12", '0914789345','Ha Noi‘),
(‘Phi Phuong Anh", ‘Female’ ,'2001/11/03' ,'@379147896', ‘Hai Phong’),
(‘Hoang Hai Nam', 'Male' , '2991/03/29', '9372467957', "Ha Noi"),
('Bui Thi Ha', 'Female' , '2992/06/03', '0392433879', 'Ha Noi"),
('Ngo Thu Hue', 'Female" , '2992/09/22',, '9816788346', 'Lao Cai"),
(‘Phi Phuong An", 'Female`' , "2901/11/13", '9379147891', 'Hai Phong")
GO
Here is some sql script data of Customer table
=Create table Customer (
ID int primary key identity(1,1),
FullName nvarchar(5@) not null,
Gender nvarchar(2@),
Birthday date,
PhoneNumber nvarchar(20)
)
Trang 10(‘Ngo Huy Hoang", ‘Male' ,'1998/07/16' , '0369773476'),
('Ta Huy Anh" , ‘Male’ ,' 2000/10/12" ,'@915289765'),
(‘Ly Binh", ‘Male’ ,'1990/05/27' ,'0816788377'),
(‘Nguyen Hoai An', ‘Female’ ,' 2000/10/12" ,'@987652345'),
(‘Ha Anh Tu’, ‘Female’ ,' 2000/11/23" ,'@813987267'),
(‘Le Ngoc Quynh", ‘Female’ ,' 2000/11/12" ,'0384726846'),
("Ho Huy Hoang", 'Male' ,'1999/0@3/12" ,'@983648652'),
(‘Bui Nam Dang’, ‘Male’, '1992/@9/21' , '@359228367'),
(‘Ta Huy An', 'Male",'2001/10/12' , '0915289231'),
(‘Le Mai Hoa’, Female’ ,'1996/01/20" , '@976752672'),
(‘Tran Ly Bang’, ‘Male’ , "1995/05/20" , '@816788717' )
Go
Here is some sql script data of Orders table
=\Create table Orders(
ID int primary key identity(1,1),
CustomerID int references Customer(ID),
StaffID int references Staff(ID),
PriceTotal float,
OrderDate datetime
)
Go
=1Insert into Orders(CustomerID,StaffID,PriceTotal,OrderDate) Values (12,1,65000, '2022/12/01'),
(13,2,65000, '2022/12/01'),
(14, 3,130000, '2022/12/02'),
(15,4,65000, '2022/12/02'),
(16,5, 130000, '2022/12/03'),
(18,7,45000, '2022/12/04'),
(19,8,55000, '2022/12/02"),
(20,9,55000, '2022/12/05"),
(21,10, 45000, '2022/12/01"),
(22,11,90000, '2022/12/03'),
(23,12,90000, '2022/12/02'),
(24,13 ,110000, '2022/12/01'),
Go
Here is some sql script data of OrderDetail table
Trang 11ID int primary key identity(1,1),
OrderID int references Orders(ID),
ProductID int references Product(ID),
Price float,
Num int,
PriceTotal float,
Go
=Insert into
(17,2,65000,
(18,3 ,65000,
(19,3,65000,
(20,2,65000,
(21,2,65000,
(22,4,45000,
(23,5,45000,
(24,8,55000,
(25,9,55000,
(26,7,45000,
(27,6,45000,
(28,7,45000,
(29,9,55000,
(30,2,65000,
OrderDetail(OrderID,ProductID,Price,Num,PriceTotal
,65000),
,65000),
, 130000),
,65000),
, 130000),
,45000),
,45000),
, 55000),
, 55000) ,
,45000),
, 90000),
; 90009),
, 110000),
,65000),
1
1
2
1
2
1
1
1
1
1
2
2
2
1
(31,15,55000,1,55000
Go
CHAPTER 3:
INFORMATION
1 Design some useful reports and information for real usage
2 Based on the designed database for Highlands Coffee’s direct sales management, we
Values
SOME USEFUL REPORT AND
assign some questions to test the effectiveness of the system as well as
List of 10 questions:
10 Calculate sales revenue per day
Show list information of all products
Sort the product list descending by price
Display a list of drinks by category
Create a view to getting customer phone number information
Display product categories in an order
Find receipts for at least 2 different products
Total bill number 23
Top 3 customers who buy the most products
List of customers who purchased goods on December 1, 2022
Trang 123 Solutions for the above reports/information
1 Show list information of all products
/*1 Show list information of all products*/
=select * from Product
fi Results gi Messages
2 Sort the product list descending by price
/*2 Sort the product list descending by price*/
=jselect * from Product
order by Price desc
& Results ei Messages
Trang 133, Display a list of drinks by category
/*3 Display a list of drinks by category*/
=)Select Category.Name ‘Category Name’, Product.Title ‘Product Name’, Product.Price
=Create proc Proc view product by category
@categoryID int
as
~begin
from Category join Product on Category.ID=Product.Category_ID
where category ID=-@categoryID
end
Exec Proc_view_product_by category 1
4, Create a view to getting customer phone number information
lia, Create a view to getting customer phone number information*/
=create view TTSDT
as
select FullName,PhoneNumber from Customer
go
=select * from TTSDT
E8 Resulls z8 Messages
5 Display product categories in an order
Trang 14=select Orders.ID, staff.FullName 'Tên nhân viên', Customer.FullName 'rên khách hang’, Product.Title ‘Tén sản phẩm', Category.Name 'Danh mục sản phẩm', Orders.0rderDate, OrderDetail.Price, OrderDetail.Num,
OrderDetail.Price * OrderDetail.Num 'Téng tién'
From Orders, Staff, Customer, OrderDetail, Product, Category
where Customer.ID - Orders.CustomerID
and Staff.ID -0rders.StaffTD
and_0rders 1D=0rderDetai].0rder1D
and _OrderDetail.ProductTD-Product 1D
Go
/*5 Display product categories in an order*/
=Select Orders.ID, Staff.FullName ‘Tén nhân viên', Customer.FullName 'ïên khách hàng', Product.Title ‘Tén sản pham', Category.Name 'Danh mục sản phấm', Orders.OrderDate, OrderDetail.Price, OrderDetail.Num,
OrderDetail.Price * OrderDetail.Num ‘Tong tiền”
From Orders, Staff, Customer, OrderDetail, Product, Category
Where Customer.ID = Orders.CustomerID
and staff.ID =0rders.Staff1D
and Orders.T1D-0rderDetaiÌ OrderID
and _OrderDetail.ProductTD-Product 1D
and Product.Category_T1D-Category 1D
6o
6 Find receipts for at least 2 different products
/*6 Find receipts for at least 2 different products*/
=|Select * from Orders
where ID in ( Select ID from OrderDetail where Num >=2)
EB Results gl Messages
ID- CustomerID StafflD PriceTotal OrderDate
2 5 1 4 65000 NULL
7 Total bill number 23
/*7 Total bill number 23*/
=lcreate procedure Tonghoadon @mahd int, @tong float output
as
=begin
select @tong=sum(PriceTotal) from OrderDetail where OrderID=@mahd
end
go
=\declare @tong float
exec Tonghoadon 23,@tong output
print @tong
el Messages
45000
Completion time: 2023-01-11T16:50:12.9447090+07:00
8 Top 3 customers who buy the most products