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

Database Design And Managementfinalproject Design And Implement Restaurant Management Database.pdf

26 0 0
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

Thông tin cơ bản

Tiêu đề Design And Implement Restaurant Management Database
Tác giả Nguyễn Công Trữ
Người hướng dẫn Nguyễn Hoàng Long
Trường học Đại học Quốc Gia Hà Nội
Chuyên ngành Quản lý thông tin
Thể loại final project
Thành phố Hà Nội
Định dạng
Số trang 26
Dung lượng 1,39 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Customers Table:  Store customer information such as name, email, phone number, booking history.. Product Table:  Store product information such as name, price, description, category,

Trang 1

TRƯỜNG ĐẠI HỌC KHOA HỌC XÃ HỘI VÀ NHÂN VĂN

ĐẠI HỌC QUỐC GIA HÀ NỘI

KHOA THÔNG TIN – THƯ VIỆN

*****

DATABASE DESIGN AND MANAGEMENTFINALPROJECT DESIGN AND IMPLEMENT RESTAURANT MANAGEMENT

DATABASE

Giảng viên hướng dẫn : Nguyễn Hoàng Long

Ngành : Quản lý thông tin CLC TT23

Mã sinh viên : 19032898

Sinh viên thực hiện : Nguyễn Công Trữ

Trang 2

I Introduction 2

II Description of database requirements/functions 2

III The relational model 3

IV All the tables in the database 7

V Here are 14 queries that cite data : 15

Trang 3

II Description of database requirements/functions

1 Customers Table:

 Store customer information such as name, email, phone number, booking history

 Allows adding, updating, obtaining customer information

 Ensure the uniqueness of email addresses for each customer

2 Product Table:

 Store product information such as name, price,

description, category, inventory level, and image URL

 Allows adding, updating, obtaining product information

 Ensure the uniqueness of the product name

 Track the inventory levels of each product

3 Stock table:

 Track the inventory levels of each product

 Store information about the last update to the stock level

 Ensure the integrity of stock data by referencing the Product ID from the Products table

4 Employee Table:

 Store employee information such as full name, email, phone number, position, work schedule

 Allows adding, updating, obtaining employee information

 Ensure the uniqueness of email addresses for each employee

5 Order Table:

Trang 4

 Store order information such as customer ID, employee ID,order date, and total amount.

 Allows adding, updating, obtaining order information

 Establish relationships between customers and orders (one-to-many) and employees and orders (one-to-many)

 Ensure data integrity by referencing customer and agent IDs from their respective tables

6.Revenue table

 Stores revenue information related to orders, including order ID, revenue date, and amount

 Allows adding, updating, obtaining revenue information

 Establish a relationship between orders and revenue to-many)

(one- Ensure data integrity by referencing the Order ID from the Orders table

7 Menu Items table:

 Store menu item information such as item name,

description, price, and product ID

 Allows adding, updating, and retrieving menu item information

 Establish relationships between menu items and products (one-to-one or one-to-many)

 Ensure data integrity by referencing product IDs from the Products table

8 Stock Table

 Store inventory information:

 Manage inventory updates

 Support order management:

Trang 5

III The relational model

Trang 6

Customers table:

reservation_history TEXT

MenuItems table:

customer_id INT FOREIGN KEY (customer_id) REFERENCES Customers(customer_id)

item_id INT FOREIGN KEY (item_id) REFERENCES MenuItems(item_id)

Trang 7

FIELD DATATYPE CONSTRAINT

Trang 8

FIELD DATATYPE CONSTRAINT

order_id INT FOREIGN KEY (order_id) REFERENCES Orders (order_id)

amount DECIMAL(10, 2) DECIMAL(10, 2)

Employees table:

phone_number VARCHAR(15) UNIQUE

work_schedule TEXT

Revenue table:

FIELD DATATYPE CONSTRAINT

revenue_i

order_id INT FOREIGN KEY (order_id) REFERENCES Orders(order_id)

item_id INT FOREIGN KEY (item_id) REFERENCES MenuItems(item_id)quantity INT NOT NULL

total_amo

unt DECIMAL(10,2) NOT NULL

sale_date DATE

Trang 9

FIELD DATATYPE CONSTRAINT

sale_time TIME

Stock Table

product_id INT FOREIGN KEY (Products)stock_level INT

last_update DATE

Customers and Orders:

Relationship: One customer can have multiple orders Many)

(One-to-Employees and Orders:

Relationship: One employee can be responsible for multiple orders (One-to-Many)

MenuItems and Products:

Relationship: A menu item can be associated with a product (One-to-One or One-to-Many)

Orders and Revenue:

Relationship: One order can have multiple revenue records (One-to-Many)

Products and Stock:

Relationship: One product can have multiple stock information (One-to-Many)

Trang 10

Customers , Orders, Employees ,MenuItems , Products, Revenue,Stock

IV All the tables in the database

CREATE TABLE Customers (

customer_id INT PRIMARY KEY,

name VARCHAR(50) NOT NULL,

email VARCHAR(50) UNIQUE,

phone_number VARCHAR(15) NOT NULL,

reservation_history TEXT

);

CREATE TABLE Products (

product_id INT PRIMARY KEY,

product_name VARCHAR(255) NOT NULL,

product_price DECIMAL(10, 2) NOT NULL,

product_description TEXT,

product_category VARCHAR(255) NOT NULL,

product_stock INT NOT NULL,

product_image_url VARCHAR(255)

);

CREATE TABLE Stock (

stock_id INT PRIMARY KEY,

product_id INT NOT NULL,

stock_level INT NOT NULL,

last_update DATETIME NOT NULL,

Trang 11

FOREIGN KEY (product_id) REFERENCES Products (product_id));

CREATE TABLE Employees (

employee_id INT PRIMARY KEY,

employee_name VARCHAR(50) NOT NULL,

email VARCHAR(100) UNIQUE,

phone_number VARCHAR(20),

position VARCHAR(50),

work_schedule DATE

);

CREATE TABLE Orders (

order_id INT PRIMARY KEY,

customer_id INT NOT NULL,

employee_id INT NOT NULL,

order_date DATE NOT NULL,

total_amount DECIMAL(10, 2) NOT NULL,

FOREIGN KEY (customer_id) REFERENCES Customers

(customer_id),

FOREIGN KEY (employee_id) REFERENCES Employees (employee_id)

);

CREATE TABLE Revenue (

revenue_id INT PRIMARY KEY,

order_id INT NOT NULL,

revenue_date DATE NOT NULL,

amount DECIMAL(10, 2) NOT NULL,

FOREIGN KEY (order_id) REFERENCES Orders (order_id));

Trang 12

CREATE TABLE MenuItems (

item_id INT PRIMARY KEY,

item_name VARCHAR(100) NOT NULL,

Thêm dữ liệu vào bảng

INSERT INTO Customers (customer_id, name, email,

(3, 'Lê Văn C', 'levanc@gmail.com', '0923456789', 'Khách hàng VIP'),

(4, 'Phạm Thị D', 'phamthid@gmail.com', '0934567890', 'Đã đặtbàn cho tiệc sinh nhật'),

(5, 'Hoàng Văn E', 'hoangvane@gmail.com', '0945678901', 'Gọi

để đặt chỗ trước'),

(6, 'Nguyễn Thị F', 'nguyenthif@gmail.com', '0956789012', 'Gọi

để đặt bàn'),

(7, 'Trần Văn G', 'tranvang@gmail.com', '0967890123', 'Đã đặttrước 1 lần'),

Trang 13

(8, 'Lê Thị H', 'lethih@gmail.com', '0978901234', 'Khách hàng thân thiết'),

(9, 'Phạm Văn I', 'phamvani@gmail.com', '0989012345', 'Reservation 9'),

(10, 'Hoàng Thị J', 'hoangthij@gmail.com', '0990123456', 'Gọi

để đặt chỗ'),

(11, 'Nguyễn Văn K', 'nguyenvank@gmail.com', '0901234567','Không có ghi chú'),

(12, 'Trần Thị L', 'tranthil@gmail.com', '0912345678', 'Đã đặt trước 2 lần'),

(13, 'Lê Văn M', 'levanm@gmail.com', '0923456789', 'Khách hàng VIP'),

(14, 'Phạm Thị N', 'phamthin@gmail.com', '0934567890', 'Đã đặt bàn cho tiệc sinh nhật'),

(15, 'Hoàng Văn O', 'hoangvano@gmail.com', '0945678901', 'Gọi để đặt chỗ'),

(16, 'Nguyễn Thị P', 'nguyenthip@gmail.com', '0956789012', 'Gọi để đặt bàn'),

(17, 'Trần Văn Q', 'tranvanq@gmail.com', '0967890123', 'Đã đặt trước 1 lần'),

(18, 'Lê Thị R', 'lethir@gmail.com', '0978901234', 'Khách hàng thân thiết'),

(19, 'Phạm Văn S', 'phamvans@gmail.com', '0989012345', 'Reservation 19'),

(20, 'Hoàng Thị T', 'hoangthit@gmail.com', '0990123456', 'Gọi

để đặt chỗ');

INSERT INTO Products (product_id, product_name,

product_price, product_description, product_category,

product_stock, product_image_url)

VALUES

Trang 14

(1, 'Cà phê đen', 25000, 'Cà phê đen nguyên chất', 'Đồ uống',

50, 'https://example.com/images/ca-phe-den.jpg'),

(2, 'Trà sữa trân châu', 35000, 'Trà sữa thơm ngon với trân châumềm dai', 'Đồ uống', 30, 'https://example.com/images/tra-sua-tran-chau.jpg'),

(3, 'Bánh mì sandwich', 45000, 'Bánh mì sandwich thịt gà', 'Thức ăn', 20, 'https://example.com/images/banh-mi-

sandwich.jpg'),

(4, 'Nước ngọt Coca Cola', 20000, 'Nước ngọt Coca Cola lon 330ml', 'Đồ uống', 100, 'https://example.com/images/coca-cola.jpg'),

(5, 'Pizza hải sản', 120000, 'Pizza hải sản tươi ngon', 'Thức ăn',

10, 'https://example.com/images/pizza-hai-san.jpg'),

(6, 'Bánh mỳ pate', 20000, 'Bánh mỳ pate thơm ngon', 'Thức ăn', 15, 'https://example.com/images/banh-my-pate.jpg'), (7, 'Cà phê sữa đá', 30000, 'Cà phê sữa đá thảo mộc', 'Đồ uống', 25, 'https://example.com/images/ca-phe-sua-da.jpg'), (8, 'Bánh flan', 40000, 'Bánh flan caramel mềm mịn', 'Thức ăn', 12, 'https://example.com/images/banh-flan.jpg'),

(9, 'Trà xoài', 35000, 'Trà xoài mát lạnh', 'Đồ uống', 30, 'https://example.com/images/tra-xoai.jpg'),

(10, 'Burger thịt bò', 55000, 'Burger thịt bò nướng', 'Thức ăn',

Trang 15

(16, 'Bánh bao', 25000, 'Bánh bao nhân thịt', 'Thức ăn', 15, 'https://example.com/images/banh-bao.jpg'),

(17, 'Cappuccino', 35000, 'Cappuccino phô mai béo ngậy', 'Đồ uống', 28, 'https://example.com/images/cappuccino.jpg'), (18, 'Bánh patê sô', 45000, 'Bánh patê sô nhân thịt hấp', 'Thứcăn', 22, 'https://example.com/images/banh-pate-so.jpg'), (19, 'Sinh tố trái cây', 40000, 'Sinh tố trái cây tươi ngon', 'Đồ uống', 30, 'https://example.com/images/sinh-to-trai-cay.jpg'), (20, 'Bánh cuốn', 30000, 'Bánh cuốn thịt nướng', 'Thức ăn', 12,'https://example.com/images/banh-cuon.jpg');

INSERT INTO Stock (stock_id, product_id, stock_level,

Trang 16

(1, 'Nguyễn Thị X', 'nguyenthix@gmail.com', '0976543210', 'Quản lý', '2023-06-01'),

(2, 'Trần Văn Y', 'tranvany@gmail.com', '0965432109', 'Nhân viên phục vụ', '2023-06-01'),

(3, 'Lê Thị Z', 'lethiz@gmail.com', '0954321098', 'Nhân viên phachế', '2023-06-01'),

(4, 'Phạm Văn M', 'phamvanm@gmail.com', '0943210987', 'Nhân viên phục vụ', '2023-06-01'),

(5, 'Hoàng Thị N', 'hoangthin@gmail.com', '0932109876', 'Nhânviên pha chế', '2023-06-01'),

(6, 'Vũ Văn P', 'vuvanp@gmail.com', '0921098765', 'Nhân viên phục vụ', '2023-06-01'),

(7, 'Đặng Thị Q', 'dangthiq@gmail.com', '0910987654', 'Quản lý', '2023-06-01'),

(8, 'Bùi Văn R', 'buivanr@gmail.com', '0909876543', 'Nhân viên pha chế', '2023-06-01'),

(9, 'Trương Thị S', 'truongthis@gmail.com', '0898765432', 'Nhânviên phục vụ', '2023-06-01'),

(10, 'Ngô Văn T', 'ngovant@gmail.com', '0887654321', 'Quản lý', '2023-06-01');

INSERT INTO Orders (order_id, customer_id, employee_id, order_date, total_amount)

Trang 18

(1, 'Cà phê sữa đá', 'Cà phê sữa thơm ngon', 30000, 1),

(2, 'Trà ô long đào', 'Trà ô long thơm ngon', 40000, 2),

(8, 'Bánh mì pate', 'Bánh mì pate thịt ngon', 45000, 3),

(9, 'Nước ngọt 7 Up', 'Nước ngọt 7 Up lon 330ml', 20000, 4),(10, 'Pizza hải sản tỏi', 'Pizza hải sản vị tỏi thơm ngon', 120000, 5),

(11, 'Cà phê sữa nóng', 'Cà phê sữa thơm ngon', 30000, 1),(12, 'Trà đào', 'Trà đào thơm ngon', 40000, 2),

(13, 'Bánh mì thịt gà', 'Bánh mì thịt gà ngon', 50000, 3),

(14, 'Nước ngọt Mirinda', 'Nước ngọt Mirinda lon 330ml', 18000, 4),

Trang 19

(15, 'Pizza hải sản cay', 'Pizza hải sản vị cay thơm ngon',

110000, 5);

V Here are 14 queries that cite data :

1 Truy vấn tất cả khách hàng trong bảng "Customers":

SELECT * FROM Customers;

Câu 2 Truy vấn tên và email của khách hàng có customer_id là 1:

SELECT name, email

FROM Customers

WHERE customer_id = 1;

Trang 20

Câu 3 Truy vấn sản phẩm có giá tiền lớn hơn 30,000 đồng:

SELECT * FROM Products

WHERE product_price > 30000;

Câu 4 Truy vấn số lượng sản phẩm còn trong kho

SELECT product_name, product_stock

FROM Products;

Trang 21

Câu 5 Truy vấn tên và giá tiền của sản phẩm có giá tiền cao nhất:

SELECT product_name, product_price

FROM Products WHERE product_price = (SELECT

MAX(product_price) FROM Products);

Trang 22

Câu 7 Truy vấn tổng số lượng sản phẩm có trong kho:

SELECT SUM(product_stock) AS tonkho

Câu 9 Truy vấn số lượng khách hàng đã đặt trước bàn:

SELECT COUNT(*) FROM Customers

WHERE reservation_history LIKE 'Đã đặt trước%';

Câu 10 Truy vấn tổng số lượng sản phẩm có trong kho theo từng danh mục (category):

SELECT product_category, SUM(product_stock)

FROM Products

Trang 24

Câu 12 Tìm tên sản phẩm và số lượng tồn kho của các sản phẩm có tên là "Cà phê đen"" hoặc "Bánh mỳ pate"

SELECT Products.product_name, Stock.stock_level

FROM Products

INNER JOIN Stock ON Products.product_id = Stock.product_idWHERE Products.product_name = 'Cà phê đen' OR

Products.product_name = 'Bánh mỳ pate';

Trang 25

Câu 13 Tìm các khách hàng có tổng doanh thu từ các đơn hàng lớn hơn 5000 đơn vị:

SELECT customers.customer_id, SUM(amount) AS total_revenueFROM orders

INNER JOIN Revenue on Revenue.order_id = orders.order_idINNER JOIN customers on orders.customer_id=

Ngày đăng: 21/08/2024, 17:36

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w