Final Project Database
Final Project Database
INTERNATIONAL SCHOOL
----------------------
Final Project
DATABASE SYSTEMS
Lecturer’s name: Truong Cong Doan
Class: INS208002
January, 2023
INS208002
Table of Contents
V) Member’s Works............................................................................................. 19
1|Page
INS208002
CHAPTER I: INTRODUCTION
The Showroom Management System will help the business in tracking the inventory
movements in the warehouse by item, serial number. A Showroom Management
Solution is extremely critical to ensure smooth running of your retail business. A
Showroom Management Solution should be adaptable and secure to convey the right
client service. These systems must be driven by access to real-time client data. At
exactly that point can retailers convey customized offers and services that are up to
the moment and targeted to each individual. The effectiveness of database
administration to manage data has been recognized by organizations. Data
management is often critical to management decisions, and the success of
management decisions is critical to strengthening business organizations.
2|Page
INS208002
This database system includes seven relations.
The Employee relation gives the FirstName, LastName, ID, Date of birth and
Gender various Employees. For convenience, we assume that Employee IDs are
unique to all Employees.
The Address relation gives essential information about the Employee,
including their ID, Address, Hometown, City, Nationality, Email, and Phone
Number.
The Salary relation provides the salary Employees will be gotten, including
ID, Attendance, Position, Basic Salary.
The Product table, which displays information about the Product ID, Product
Name, Quantity, Cost, Origin. We also assume Product ID is unique to easily
supervise.
The Supplier relation tells about Product ID, Supplier Name, Supplier ID,
Number product supplied.
The Customer table gives essential information about the Customers of
Showroom including Customer ID, Customer Name, Customer Address and their
Phone Number. It can convey customized offers and services that are up to the
moment and targeted to each individual.
The Order relation displays Order ID, Customer ID, Product ID, Number
product.
3|Page
INS208002
4|Page
INS208002
5|Page
INS208002
6|Page
INS208002
7|Page
INS208002
8|Page
INS208002
9|Page
INS208002
III) Normal Forms of Database system
- Employee (FirstName, LastName, ID, Dob, Gender)
- Address (ID, Address, Hometown, City, Email,Phone)
- Salary (ID, Attendance, Position, Basic_Salary)
- Product (Prod_ID, Prod_Name, Quantity, Cost, Origin)
- Supplier (Prod_ID, Sup_Name, Sup_ID, Number_prod_supplied)
- Customer (Cus_ID, Cus_Name, Cus_Address, Cus_phone)
- Order (Order_ID, Cus_ID, Prod_ID, Number_prod)
IV) Code SQL
CREATE DATABASE FINAL
USE FINAL
GO
10 | P a g e
INS208002
11 | P a g e
INS208002
);
12 | P a g e
INS208002
(5,'29 Chinh Huu, Son Tra District','Quang Nam','Da
Nang','[email protected]','098 0931 413'),
(6,'95 Doi Can, Cam Le District','Quang Nam','Da
Nang','[email protected]','098 2732 494'),
(7,'20 Cao Ba Dat, Hoa Vang District','Hue','Da
Nang','[email protected]','093 3492 403'),
(8,'19 Pham Tu, Son Tra District','Ha Tinh','Da Nang','[email protected]','072 4283
050'),
(9,'50 Pham Cu Luong, Son Tra District','Da Nang','Da
Nang','[email protected]','072 0842 421'),
(10,'255 My Khe 2, Son Tra District','Quang Ngai','Da
Nang','[email protected]','093 5825 588');
13 | P a g e
INS208002
('TL73','Toilet table AC900VRN', 23, 5500000,'Thailand'),
('TL75','Toilet table AC504VAN', 0, 5000000,'Malaysia');
14 | P a g e
INS208002
('H103','Vu Minh Huy','95 Vo Chi Cong, Cam Le District','034 7117 672'),
('DN104','Dien Nam Dien Ngoc Industrial Zone','W7P4+CQG, ĐT607, Dien Nam Trung,
Hoi An City, Quang Nam','098 8338 292'),
('L105','Le Van Lam','593 Le Van Hien, Ngu Hanh Son District','072 4953 049'),
('DN106','Dien Nam Dien Ngoc Industrial Zone','W7P5+CQG, ĐT608, Dien Nam Trung,
Hoi An City, Quang Nam','098 8338 292'),
('T107','Nguyen Van Thanh','405 Ho Xuan Huong, Ngu Hanh Son District','016 9292
929'),
('N108','Nguyen Nhat Nam','23 Me Thu, Cam Le District','093 1220 201'),
('H109','Ha Thi Hong','21 Con Dau, Cam Le District','048 8393 312');
--1
--View employee information, employee's address--
SELECT Employee.ID, Employee.FirstName,
Employee.LastName,Address.Email,Address.Phone,Address.Address,Address.City
FROM Employee, Address
WHERE Employee.ID=Address.ID
--2
--Calculate avg, max, min, sum of employee's basic salary--
SELECT AVG(Basic_Salary) AS Average_of_Salary, MAX(Basic_Salary) AS
Max_of_Salary, MIN(Basic_Salary) AS Min_of_Salary, SUM(Basic_Salary) AS
Total_Salary
FROM Salary
--3
--Add new employee information--
CREATE TRIGGER Insert_new_employee
on Employee
FOR INSERT
AS
BEGIN
DECLARE @insertedrow INT
SELECT @insertedrow=count(*)
FROM inserted
PRINT CAST(@insertedrow AS VARCHAR(30))+ 'Row are inserted'
END
15 | P a g e
INS208002
INSERT INTO Employee(FirstName,LastName,ID,Dob,Gender)
VALUES('Nguyen Quang','Tuan Anh','11','1992-08-10','Male')
SELECT * FROM Employee
--4
--Find products under 5 million VND--
--5
--Add new product--
CREATE TRIGGER Insert_new_product
on Product
FOR INSERT
AS
BEGIN
DECLARE @insertedrow INT
SELECT @insertedrow=count(*)
FROM inserted
PRINT CAST(@insertedrow AS VARCHAR(30))+ 'Row are inserted'
END
INSERT INTO Product(Prod_ID,Prod_Name,Quantity,Cost,Origin )
VALUES('WS16','Wash_stand','11','1500000','Japan')
SELECT * FROM Product
--6
--Delete 1 product when out of stock--
CREATE TRIGGER Out_of_product
ON Product
FOR DELETE
AS
BEGIN
DECLARE @deletedrow int
SELECT @deletedrow =count(*)
16 | P a g e
INS208002
FROM deleted
PRINT CAST(@deletedrow as nvarchar(10))+ 'Out of product'
END
DELETE FROM Product WHERE Quantity= '0';
SELECT * FROM Product
--7
--Find the supply chain in order from most to least--
SELECT * FROM Supplier
ORDER BY Number_prod_supplied DESC
--8
--Find Customer IDs to buy tiles 80x80--
SELECT Cus_ID,Prod_ID,Order_ID,Number_prod
FROM Orders
GROUP BY Cus_ID,Prod_ID,Order_ID,Number_prod
HAVING Prod_ID ='TL73'
SELECT * FROM Orders
--9
--Find customer information by order ID--
SELECT Customer.Cus_ID,
Customer.Cus_Name,Customer.Cus_phone,Customer.Cus_Address
FROM Customer
JOIN Orders ON Orders.Cus_ID = Customer.Cus_ID
WHERE Order_ID = '100'
ORDER BY Customer.Cus_Name
--10
--Find the name of the employee who is not on leave--
SELECT Employee.LastName, Employee.ID
FROM Employee
JOIN Salary ON Employee.ID = Salary.ID
WHERE Attendance = 'Full_time'
ORDER BY Salary.Attendance;
17 | P a g e
INS208002
--11
--Count the number of male and female employees in the company--
SELECT Gender, count(*) AS Total from Employee
GROUP BY Gender;
--12
--Count the number of employees in the company--
SELECT count(ID) as NumberOfEmps
FROM Employee;
--13
--Find supplier information by product--
SELECT Supplier.Sup_Name, Supplier.Prod_ID
FROM Supplier
JOIN Product ON Supplier.Prod_ID = Product.Prod_ID
WHERE Product.Prod_ID = 'E173'
ORDER BY Supplier.Sup_Name
--14
--Delete products originating from Japan--
DELETE
FROM Product
WHERE Origin='Japan'
SELECT * FROM Product
--15
--List all products originating from China--
SELECT Prod_Name, Prod_ID, Origin
FROM Product
WHERE Origin='China';
18 | P a g e
INS208002
V) Member’s Works
Member Work
+ Support
+ Create table
+ Present
+ Support
19 | P a g e
INS208002
- Second, we learned how to apply SQL Server tools to enhance data presentation
and analysis performance.
- Moreover, we learned how to work as a team, improve our thinking, and reflect
on database problems.
Therefore, we believe that they will help us in the future learning process.
20 | P a g e