Export slip information is stored in the Sales Voucher database - Payment process The accounting department transfers order information to issues invoices to customers - Delivery and pr
Trang 1VIETNAM NATIONAL UNIVERSITY HO CHI MINH CITY
UNIVERSITY OF ECONOMICS AND LAW
PROJECT REPORT
Subject: Databases
Subject name:
Market Online Management Project
Lecturers: Lam Hong Thanh
TP.HCM, Tháng 05 Năm 2021
Trang 2MEMBERS OF GROUP
1 Phạm Gia Hoài An K194060840 Leader
2 Trần Thị Diệu Ái K194060842 Member
3 Trần Thị Hà Ly K194060854 Member
4 Nguyễn Mạnh Quang K194060865 Member
5 Nguyễn Thu Vân K194060880 Member
Trang 3
TABLE OF CONTENTS
ABSTRACT 4
CHAPTER I: OVERVIEW OF THE TOPIC 5
I WHY CHOOSING THIS SUBJECT? 5
II PROJECT OBJECTIVES 5
III EXPECTED RESULTS 6
IV PRACTICAL SIGNIFICANCE 6
1 For users 6
2 For my team 6
CHAPTER II: INTRODUCTION 7
I MODEL PARTICIPANT 7
II GENERAL DESCRIPTION OF THE COMPANY 7
III GENERAL BUSINESS PROCESS 7
1 Import process 7
2 Sales process 8
IV MAIN FUNCTION OF THE BUSINESS MODEL 8
1 Import process 8
2 Sales process 10
V MAIN FUNCTION OF APP 12
CHAPTER III: ENTITY RELATIONSHIP DIAGRAM 14
I IDENTIFIES ENTITIES AND ATTRIBUTES 14
II RELATIONSHIP OF ENTITIES 17
III ENTITY RELATIONSHIP DIAGRAM (ERD) 21
CHAPTER IV: LOGICAL DATABASE MODEL 23
CHAPTER V: PHYSICAL DATABASE MODEL 24
I DATA TYPES 24
II DATABASE CREATION STATEMENT 35
1 Command to create database 35
2 Create a foreign key 83
CHAPTER VI: SQL QUERY 85
Trang 4ABSTRACT
The demand of manage information is highly in every organization Management information effectively help reduce cost, time and avoid redundancy data To understand deeply how benefit a database can bring to an organization and the process
to build a database, we decided to build a Market Online Management Project With the aim to help clinics easily in managing their business, take care of customers, … We know within building this project, there will be mistakes that we can solve but it is the chance for us to achieve knowledge and skills which are precious tools in the future and
we will make this project as good as we can
Trang 5
CHAPTER I: OVERVIEW OF THE TOPIC
I WHY CHOOSING THIS SUBJECT?
In the past, most of us would buy food mainly from wholesale markets, buying agents in big centers or in markets and department stores Today, the development of the digital economy has changed the business perception of the whole society It can be seen that all products and services can be introduced and "sold" on the Internet Moreover, customers increasingly need to know information about the origin and origin
of agricultural products that ensure quality and safety for health or not? Therefore, in addition to improving food quality, brand communication, and packaging improvement
to affirm quality reputation, managers need a more effective communication channel and app design is the ultimate solution selected best Owning a sales app will help businesses attract more potential customers through the internet According to the latest statistics, Vietnam currently has about 41 million internet users, accounting for about 45% of the country's population, most of which are young people with high shopping needs Moreover, nowadays, the online trend is developing day by day and is buying by many users About one third of the population uses the internet to search and look up information about services and products Therefore, when you have a sales app, your business has attracted a number of customers on the internet Without the app, you would have lost an opportunity to sell and give that opportunity to competitors
II PROJECT OBJECTIVES
Promote sales activities anytime, anywhere Customers will not have to come directly to the store or purchase according to the store's operating hours but can buy at any time This helps to maximize sales opportunities, boost sales and facilitate customers to shop, making them more satisfied
Reduce business costs Having a sales app will help save a lot of costs for store rental, warehouse and human resource costs In addition, having a sales app also makes the payment of customers convenient and easier Customers can pay via ATM cards, through electronic payment methods
Trang 6Having a separate sales app for the business will also help improve the reputation and brand value of the business The face of a business on the internet is the app and the colors, features and information on the app will fully reflect the image of the business with the customer, contributing to affirm the company's brand value in the hearts of the public
III EXPECTED RESULTS
Design database for the application of ordering products through the app
Build management and business processes for the app model
IV PRACTICAL SIGNIFICANCE
1 For users
When the software was built, it became easier for the housewives to shop and cook Specifically, through each form of software including customer management, food import and export management (export here means providing food to customers) Thanks to that, the manager can comprehensively monitor the data and use it properly, thereby helping the usage process and supporting decision making in the best way
2 For my team
Understanding the process of building a database from idea creation, modeling, data collection, storage and operation on SQL
Designing a software based on the available data
Project is the basis that my group can continue to develop in the following subjects
Trang 7CHAPTER II: INTRODUCTION
II GENERAL DESCRIPTION OF THE COMPANY
APP acts as an intermediary to help seller's products reach consumers conveniently and quickly on the website In order to provide clean food to consumers quickly and conveniently, APP has main departments including Sales and Marketing, and Accounting Division IT department and warehouse management department
III GENERAL BUSINESS PROCESS
1 Import process
Trang 8Procedure Describe
Step 1 Plan and contract with supplier
Step 2 Check the goods and compare
Step 3 Make an inventory receipt
Step 4 Completion of warehousing and payment
2 Sales process
Step 4 Delivery and processing of returned orders
IV MAIN FUNCTION OF THE BUSINESS MODEL
1 Import process
Trang 9
- Plan and contract with supplier
Staff sends purchase request information to Seller including: real name, product, quantity to be purchased, delivery schedule
Trang 10The import department contact with the Supplier and notify the plan to the relevant to update information and sign a purchase contract Then, the contract information will be saved And in the Contract database, each contract will be managed with a contract code individual
- Check the goods and compare
The warehouse department keeper relies on the purchase order or request form
to compare inventory information from the Warehouse database and at the same time check their quality
- Make an inventory receipt
When the goods inspection is completed, all paperwork and receipt request will
be transferred to the accounting department to compare again before conducting the transaction and printing the receipt
Information about the goods entering the warehouse and the receipt will be saved
in the Warehouse database to manage imported products
- Completion of warehousing and payment
The department store keeper performs the stock storage operation and collates with the sales information, then updates the information on the warehouse card Finally, payment is made to the provider When the payment is successful, invoice information will be recorded on the basis Corporate Purchase Invoice data
2 Sales process
Trang 11- Customers order
Customers through the information provided about the product and choose to
purchase through the application
When ordering success, customer order information including order code,
customer code, Order date, product code and will be stored in the Order database to be
controlled
Trang 12- Order process
The system receives order information from the Order database, the company checks orders and generates inventory information to prepare goods and shipping Delivery Company
Export slip information is stored in the Sales Voucher database
- Payment process
The accounting department transfers order information to issues invoices to customers
- Delivery and processing of returned orders
The company will check the information and issue the same slip with row for the Delivery company The company receives the goods and carries out the communication hang
The delivery company receives and delivers the delivery The delivery company will confirm and send the bill of lading code and update the order status for the company
V MAIN FUNCTION OF APP
Display information and images about the product: customers can feel the
authenticity through many angles of the product as well as reflect to customers partly the product quality of the company
For the product evaluation function: customers will have the reference to
decide whether to buy or not At the same time, this function also helps the company to manage quality 12 as well as its operation process effectively or not
Display promotions and offers: to help customers have more opportunities to
access the company's products, especially for new products and outstanding products Not only that, promotion activities also aim to promote the product brand as well as the company's reputation through consumer reviews
Trang 13Advanced product search and filtering function: Because the volume of
products is relatively large, customers often have the need to filter out a list of products they want to buy, providing a better experience for users trust and appreciate instead they have to be frustrated by wasting hours searching for the product they want
Display related products: so that customers can refer more and increase the
ability to buy more products, an indispensable e-commerce app to display additional products, reference products, products Other customers also buy …
Service experience: provides customers the option to add products to cart, create
a list of favorite products
Show recipes : Not only provides clean, fresh and high quality ingredients, the
app also gives customers standard recipes to make family meals more delicious and enjoyable In addition to familiar Vietnamese dishes, the app also updates recipes from famous chefs to get the richest menu for customers to choose from
Trang 14CHAPTER III: ENTITY RELATIONSHIP DIAGRAM
I IDENTIFIES ENTITIES AND ATTRIBUTES
Entity Attribute Key
attribute
Multivalued Attribute
Composite Attribute
Required attribute
Supplier SupplierID
SupplierName Address PhoneNumber Email
Product
SupplierI
D
Address PhoneNumbe
r Email Product
Address SupplierID
SupplierName Address PhoneNumber Product
Employee
EmployeeID DepartmentID Position LastName FirstName Address PhoneNumber Email
HireDate Salary
*Position:
Manager EmployeeOnl EmployeeOff
Employee
ID DepartmentID
Position DepartmentI
D
Address EmployeeID
Position LastName FirstName Address PhoneNumber Email
HireDate Salary
Employee
Onl
EmployeeOnlID ManagerID
EmployeeOnlID
EmployeeOnlID ManagerID
EmployeeOf
f
EmployeeOffID ManagerID
EmployeeOffID
EmployeeOffID ManagerID
Department DepartmentID
DepartmentName
DepartmentID
DepartmentID DepartmentName
Trang 15Contract ContractID
ContractTime SupplierID SigningDate QualityProductQuantityProduct ValueContract ManagerID
ContractIDContractTime SupplierI
D
QualityProdu
ct
ContractID ContractTime SupplierID SigningDate QuantityProduct ValueContract ManagerID
Contract
Detail
ContractID ContractTime LineNumber ProductID QuantityProduct UnitPrice
VAT TotalAmount
ContractIDContractTime LineNumber
ContractID ContractTime LineNumber ProductID Quantity VAT UnitPrice TotalAmount WarehouseL
ist
WarehouseID InventoryName Location
WarehouseID
Location InventoryID
InventoryName Location
InventoryLis
t
WarehouseID ProductID QuantityProduct
ProductI
D
WarehoueID ProductID QuantityProduct Product ProductID
ProductName UnitPrice ContractID
ProductI
D
ProductID ProductName UnitPrice
Goods
Receipt
Note
ReceiptNoteIDReceiptTime
SupplierID EmployeeOffID
ReceiptNoteID ReceiptTi
me SupplierI
D
ReceiptNoteID ReceiptTime SupplierID EmployeeOffID
ReceiptNoteID ReceiptNotTime
ReceiptNoteID ReceiptTime LineNumber ProductID
Trang 16UnitPrice VAT TotalAmount WarehouseID
LineNumber
Quantity UnitPrice VAT TotalAmount WarehouseID Customer CustomerID
CustomerNameAddress
PhoneNumber Account PassWord
Customer
ID
Address Address CustomerID
CustomerName Address
PhoneNumber Account PassWord Order OrderID
OrderTime CustomerID
OrderID OrderTim
e
OrderID CustomerID OrderTime
Order
Detail
OrderID OrderTime LineNumber CustomerID ProductID QuantityProduct
OrderID OrderTimeLineNumber
OrderID OrderTime LineNumber CustomerID ProductID QuantityProduct Goods
Delivery
Note
DeliveryNoteID DeliveryTime OrderID CompanyDeID
DeliveryNoteID DeliveryTime
DeliveryNoteIDDeliveryTime
OrderID CompanyDeID
e LineNumber QuantityProduct UnitPrice
TotalAmount ProductID
DeliveryNoteID DeliveryTimeTime LineNumber
DeliveryNoteIDDeliveryTimeTime LineNumber Quantity UnitPrice TotalAmount ProductID
Invoice InvoiceID
InvoiceTime OrderID CustomerID
InvoiceID InvoiceTi
me
InvoiceID InvoiceTime OrderID CustomerID
Trang 17Invoice
Detail
InvoiceID InvoiceTime LineNumber ProductID QuantityProduct UnitPrice
TotalAmount
InvoiceID InvoiceTi
me LineNumber
InvoiceID InvoiceTime LineNumber ProductID Quantity UnitPrice TotalAmount Delivery
Company
CompanyID CompanyNam Address Email PhoneNumber
Company
ID
Address CompanyID
CompanyName Address
Email PhoneNumber Delivery
Status
DeliveryID DeliveryTime Status
CompanyID
DeliveryI
D
DeliveryID DeliveryTime Status
CompanyID Returned
Goods
Receipt
Note
ReturnNoteID ReturnTime DeliveryNoteID CustomerID
ReturnNoteID ReturnTi
me
ReturnNoteID ReturnTime DeliveryNoteIDCustomerID
Reason Refund WarehouseID
ReturnNoteID ReturnTi
me LineNumber
ReturnNoteID ReturnTime LineNumber ProductID QuantityProductUnitPrice
Reason Refund WarehouseID
II RELATIONSHIP OF ENTITIES
Name Relationship Cardinality
Relationship
Description
Trang 18A goods received notes has one or more goods received notes details
A goods received notes detail belongs only to one goods received note
Trang 19R8 EmployeeOff – GoodsReceipt
Note
1-n
An employee creates zero or more goods received notes
A goods received note is generated by one employee
R9 WarehouseList – Goods
ReceiptNoteDetail
1-n
A warehouse list has one or more goods received note details
A goods received note detail belongs only to one warehouse list
Trang 20R15 Order - Invoice
1-1
One order has one invoice
A invoice is part of an order
A invoice detail with zero or one goods delivery detail
A goods delivery detail belongs to only one invoice detail
R18 GoodsDeliveryNote – Goods
DeliveryNoteDetail
1-n
A goods delivery note has one or more goods delivery note details
A goods delivery note detail only belongs to one goods delivery note
R19 DeliveryCompany – Goods
DeliveryNote
1-n
A delivery company has one or more goods delivery notes
A goods delivery note belongs to only one company delivery
R20 DeliveryCompany – Delivery
Status
1-n
A delivery company has one or more delivery status
A delivery status belong to delivery company
Trang 21R22 GoodsDeliveryNote – Returned
GoodsReceivedNote
1-1
A goods delivery note has zero or one returned goods received note
A returned goods received note belongs to only one goods delivery note
R23 ReturnedGoods ReceivedNote –
ReturnedGoodsReceived
NoteDetail
1-n
A returned goods received note has one or more returned goods received note details
A returned goods received note detail belongs to only one returned goods received note
R24 InventoryList – Returned
GoodsReceivedNoteDetail
1-n
A inventory list has one or more returned goods received note details
A returned goods received note detail belongs to only one inventory list
III ENTITY RELATIONSHIP DIAGRAM (ERD)
Trang 23CHAPTER IV: LOGICAL DATABASE MODEL
Trang 24CHAPTER V: PHYSICAL DATABASE MODEL
Trang 25Table 2a: Manager
Attribute Key Data type Length Allow null
Trang 32Attribute Key Data type Length Allow null
Trang 34Attribute Key Data type Length Allow null
Trang 35II DATABASE CREATION STATEMENT
1 Command to create database
IFEXISTS(SELECT 1
FROM SYS.SYSREFERENCES R JOIN SYS.SYSOBJECTS O ON (O.ID =
R.CONSTID AND O.TYPE= 'F')
WHERE R.FKEYID =OBJECT_ID('CONTRACT')AND O.NAME =
'FK_CONTRACT_R1_SUPPLIER')
ALTERTABLECONTRACT
DROPCONSTRAINT FK_CONTRACT_R1_SUPPLIER
GO
Trang 36IFEXISTS(SELECT 1
FROM SYS.SYSREFERENCES R JOIN SYS.SYSOBJECTS O ON (O.ID =
R.CONSTID AND O.TYPE= 'F')
WHERE R.FKEYID =OBJECT_ID('CONTRACT_DETAIL')AND O.NAME =
'FK_CONTRACT_DETAIL_R2_CONTRACT')
ALTERTABLE CONTRACT_DETAIL
DROPCONSTRAINT FK_CONTRACT_DETAIL_R2_CONTRACT
GO
IFEXISTS(SELECT 1
FROM SYS.SYSREFERENCES R JOIN SYS.SYSOBJECTS O ON (O.ID =
R.CONSTID AND O.TYPE= 'F')
WHERE R.FKEYID =OBJECT_ID('GOODS_RECEIPT_NOTE') AND O.NAME=
'FK_GOODS_RECEIPT_NOTE_R3_SUPPLIER')
ALTERTABLE GOODS_RECEIPT_NOTE
DROPCONSTRAINT FK_GOODS_RECEIPT_NOTE_R3_SUPPLIER
GO
IFEXISTS(SELECT 1
FROM SYS.SYSREFERENCES R JOIN SYS.SYSOBJECTS O ON (O.ID =
R.CONSTID AND O.TYPE= 'F')
WHERE R.FKEYID =OBJECT_ID('GOODS_RECEIPT_NOTE') AND O.NAME=
'FK_GOODS_RECEIPT_NOTE_R4_GOODS_RECEIPT_NOTE_DETAIL')
ALTERTABLE GOODS_RECEIPT_NOTE
Trang 37FK_GOODS_RECEIPT_NOTE_R4_GOODS_RECEIPT_NOTE_DETAIL
GO
IFEXISTS(SELECT 1
FROM SYS.SYSREFERENCES R JOIN SYS.SYSOBJECTS O ON (O.ID =
R.CONSTID AND O.TYPE= 'F')
WHERE R.FKEYID =OBJECT_ID('EMPLOYEE')AND O.NAME =
'FK_EMPLOYEE_R5_DEPARTMENT')
ALTERTABLE EMPLOYEE
DROPCONSTRAINT FK_EMPLOYEE_R5_DEPARTMENT
GO
IFEXISTS(SELECT 1
FROM SYS.SYSREFERENCES R JOIN SYS.SYSOBJECTS O ON (O.ID =
R.CONSTID AND O.TYPE= 'F')
WHERE R.FKEYID =OBJECT_ID('EMPLOYEE_OFF') AND O.NAME=
'FK_EMPLOYEE_OFF_INHERITAN_EMPLOYEE')
ALTERTABLE EMPLOYEE_OFF
DROPCONSTRAINT FK_EMPLOYEE_OFF_INHERITAN_EMPLOYEE
GO
IFEXISTS(SELECT 1
FROM SYS.SYSREFERENCES R JOIN SYS.SYSOBJECTS O ON (O.ID =
R.CONSTID AND O.TYPE= 'F')
Trang 38WHERE R.FKEYID =OBJECT_ID('EMPLOYEE_ON')AND O.NAME=
'FK_EMPLOYEE_ON_INHERITAN_EMPLOYEE')
ALTERTABLE EMPLOYEE_ON
DROPCONSTRAINT FK_EMPLOYEE_ON_INHERITAN_EMPLOYEE
GO
IFEXISTS(SELECT 1
FROM SYS.SYSREFERENCES R JOIN SYS.SYSOBJECTS O ON (O.ID =
R.CONSTID AND O.TYPE= 'F')
WHERE R.FKEYID =OBJECT_ID('MANAGER') AND O.NAME=
'FK_MANAGER_INHERITAN_EMPLOYEE')
ALTERTABLE MANAGER
DROPCONSTRAINT FK_MANAGER_INHERITAN_EMPLOYEE
GO
IFEXISTS(SELECT 1
FROM SYS.SYSREFERENCES R JOIN SYS.SYSOBJECTS O ON (O.ID =
R.CONSTID AND O.TYPE= 'F')
WHERE R.FKEYID =OBJECT_ID('EMPLOYEE_ON')AND O.NAME=
'FK_EMPLOYEE_ON_R6_MANAGER')
ALTERTABLE EMPLOYEE_ON
DROPCONSTRAINT FK_EMPLOYEE_ON_R6_MANAGER
GO
Trang 39IFEXISTS(SELECT 1
FROM SYS.SYSREFERENCES R JOIN SYS.SYSOBJECTS O ON (O.ID =
R.CONSTID AND O.TYPE= 'F')
WHERE R.FKEYID =OBJECT_ID('EMPLOYEE_OFF') AND O.NAME=
'FK_EMPLOYEE_OFF_R7_MANAGER')
ALTERTABLE EMPLOYEE_OFF
DROPCONSTRAINT FK_EMPLOYEE_OFF_R7_MANAGER
GO
IFEXISTS(SELECT 1
FROM SYS.SYSREFERENCES R JOIN SYS.SYSOBJECTS O ON (O.ID =
R.CONSTID AND O.TYPE= 'F')
WHERE R.FKEYID =OBJECT_ID('GOODS_RECEIPT_NOTE') AND O.NAME=
'FK_GOODS_RECEIPT_NOTE_R8_EMPLOYEE_OFF')
ALTERTABLE GOODS_RECEIPT_NOTE
DROPCONSTRAINT FK_GOODS_RECEIPT_NOTE_R8_EMPLOYEE_OFF
GO
IFEXISTS(SELECT 1
FROM SYS.SYSREFERENCES R JOIN SYS.SYSOBJECTS O ON (O.ID =
R.CONSTID AND O.TYPE= 'F')
WHERE R.FKEYID =OBJECT_ID('GOODS_RECEIPT_NOTE_DETAIL')AND
O.NAME= 'FK_GOODS_RECEIPT_NOTE_DETAIL_R9_WAREHOUSE_LIST') ALTERTABLE GOODS_RECEIPT_NOTE_DETAIL
Trang 40FK_GOODS_RECEIPT_NOTE_DETAIL_R9_WAREHOUSE_LIST
GO
IFEXISTS(SELECT 1
FROM SYS.SYSREFERENCES R JOIN SYS.SYSOBJECTS O ON (O.ID =
R.CONSTID AND O.TYPE= 'F')
WHERE R.FKEYID =OBJECT_ID('PRODUCT')AND O.NAME=
'FK_PRODUCT_10_CONTRACT_DETAIL')
ALTERTABLE PRODUCT
DROPCONSTRAINT FK_PRODUCT_R10_CONTRACT_DETAIL
GO
IFEXISTS(SELECT 1
FROM SYS.SYSREFERENCES R JOIN SYS.SYSOBJECTS O ON (O.ID =
R.CONSTID AND O.TYPE= 'F')
WHERE R.FKEYID =OBJECT_ID('INVENTORY_LIST') AND O.NAME= 'FK_ INVENTORY_LIST_R11_WAREHOUSE_LIST')
ALTERTABLE INVENTORY_LIST
DROPCONSTRAINT FK_ INVENTORY_LIST _R11_WAREHOUSE_LIST
GO
IFEXISTS(SELECT 1