By GokiSoft.com| 20:41 21/01/2022|
SQL Server/MySQL

[Video] Phân tích hệ thống CSDL Quản Lý Khách Sạn - Khóa học SQL Server - C2108L

Phân tích hệ thống CSDL Quản Lý Khách Sạn - Khóa học SQL Server






Liệt kê được các đối tượng cần quản lý
- Roles: Quản lý role người dùng
	- id: int -> primary key -> identity(1,1)
	- rolename: nvarchar(50) not null
- User: Quản lý được nhân viên
	- id: int -> primary key -> identity(1,1)
	- fullname: nvarchar(50)
	- birthday: date
	- gender: nvarchar(20)
	- email: nvarchar(150)
	- phone_number: nvarchar(20)
	- address: nvarchar(200)
	- id_role: int -> references Role (id)
- Room: Quản lý phòng
	- id: int -> primary key -> identity(1,1)
	- room_no: nvarchar(20)
	- type: nvarchar(20)
	- max_num: int
	- price: float (Quy dinh theo ngay/gio/...)
- Quản lý đặt phòng: 1 người thuê được nhiều phòng, mỗi phòng lưu được danh sách người thuê
	- Booking:
		- id: int -> primary key -> identity(1,1)
		- staff_id: int -> references User (id)
		- customer_id: int -> references User (id)
		- checkin: datetime
		- checkout: datetime
		- status: int -> 0 (pending -> confirm|cancel -> checkedin -> checkedout -> done)
		- note: ~~~
	- BookingDetail:
		- booking_id: int -> references Booking (id)
		- room_id: int -> references Room (id)
		- price: float
		- unit: float
		- primary key (booking_id, room_id)
	- UserDetail:
		- booking_id: int -> references Booking (id)
		- room_id: int -> references Room (id)
		- customer_id: int -> references User (id)
		- primary key (booking_id, room_id, customer_id)
- Category: Quản lý danh mục dịch vu
	- id: int -> primary key -> identity(1,1)
	- name: nvarchar(50)
- Product: Quản lý dịch vụ (đồ uống, dịch vụ khác bể bởi, massage, tennis, .v.v)
	- id: int -> primary key -> identity(1,1)
	- category_id: int -> references Category (id)
	- title: nvarchar(150)
	- thumbnail: nvarchar(500)
	- description: ntext
	- price: float
	- amount: int
- Quản lý sử dụng dịch vụ
	- Người/Tổ chức -> Thuê phòng -> thuê nhiều phòng -> mỗi phòng gồm nhiều người -> mỗi người họ sẽ sử dụng 1 dịch vụ khác nhau
		Mong muốn: ai đã sử dụng đồ uống, đồ uống gì, giá tiền, số lượng, thời điểm mua -> Gắn bới đặt phòng nào
	Services:
		- id: int -> primary key -> identity(1,1)
		- customer_id: int -> references User (id)
		- product_id: int -> references Product (id)
		- amount: int
		- price: float
		- buy_date: datetime
		- booking_id: int -> references Booking (id)
================================= HOÀN THÀNH QUÁ TRÌNH PHÂN TÍCH CSDL =====================================


-- Tao CSDL
create database BT2781
go

-- Kich hoat CSDL
use BT2781
go

-- Tao Tables
create table Roles (
	id int primary key identity(1,1),
	rolename nvarchar(50)
)
go

create table Users (
	id int primary key identity(1,1),
	fullname nvarchar(50),
	birthday date,
	gender nvarchar(20),
	email nvarchar(150),
	phone_number nvarchar(20),
	address nvarchar(200),
	role_id int references Roles (id)
)
go

create table Room (
	id int primary key identity(1,1),
	room_no nvarchar(20) not null,
	type nvarchar(20),
	max_num int,
	price float
)
go

create table Booking (
	id int primary key identity(1,1),
	staff_id int references Users (id),
	customer_id int references Users (id),
	checkin datetime,
	checkout datetime
)
go

create table BookingDetail (
	booking_id int references Booking (id),
	room_id int references Room (id),
	price float,
	unit float,
	primary key (booking_id, room_id)
)
go

create table UserDetail (
	booking_id int references Booking (id),
	room_id int references Room (id),
	customer_id int references Users (id),
	primary key (booking_id, room_id, customer_id)
)

create table Category (
	id int primary key identity(1,1),
	name nvarchar(50)
)
go

create table Product (
	id int primary key identity(1,1),
	category_id int references Category (id),
	title nvarchar(150),
	thumbnail nvarchar(500),
	description ntext,
	price float,
	amount int
)
go

create table Services (
	id int primary key identity(1,1),
	booking_id int references Booking (id),
	customer_id int references Users (id),
	product_id int references Product (id),
	price float,
	amount int,
	buy_date datetime
)
go




Tags:

Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)