-
Notifications
You must be signed in to change notification settings - Fork 0
/
hotel.sql
66 lines (59 loc) · 1.61 KB
/
hotel.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
create Database HotelManagement;
use HotelManagement;
CREATE TABLE Customer (
customerId INT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
phoneNumber VARCHAR(15) NOT NULL,
email VARCHAR(50),
address VARCHAR(255)
);
-- Bảng Room
CREATE TABLE Room (
roomId INT PRIMARY KEY,
description VARCHAR(255),
floor INT,
type INT,
status INT
);
-- Bảng Price
CREATE TABLE Price (
priceId INT PRIMARY KEY,
roomType INT,
price FLOAT
);
-- Bảng Staff
CREATE TABLE Staff (
staffId INT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
username VARCHAR(20) NOT NULL,
password VARCHAR(20) NOT NULL,
phoneNumber VARCHAR(15) NOT NULL,
email VARCHAR(50),
gender VARCHAR(10),
address VARCHAR(255),
role INT
);
-- Bảng Booking
CREATE TABLE Booking (
bookingId INT PRIMARY KEY,
customerId INT NOT NULL,
roomId INT NOT NULL,
priceId INT NOT NULL,
startDate DATE NOT NULL,
endDate DATE,
FOREIGN KEY (customerId) REFERENCES Customer (customerId),
FOREIGN KEY (roomId) REFERENCES Room (roomId),
FOREIGN KEY (priceId) REFERENCES Price (priceId)
);
-- Bảng Payment
CREATE TABLE Payment (
paymentId INT PRIMARY KEY,
bookingId INT NOT NULL,
staffId INT NOT NULL,
total_amount INT NOT NULL,
paymentDate DATE NOT NULL,
FOREIGN KEY (bookingId) REFERENCES Booking (bookingId),
FOREIGN KEY (staffId) REFERENCES Staff (staffId)
);
INSERT INTO Staff (staffId, name, username, password, phoneNumber, email, gender, address, role)
VALUES (1, 'Tuan Anh', 'tuananh', '123456', '0375871003', '[email protected]', 'male', 'ND', 0);