-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.sql
More file actions
87 lines (79 loc) · 2.58 KB
/
script.sql
File metadata and controls
87 lines (79 loc) · 2.58 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
create table Guest
(
guestId varchar(100) not null
primary key,
guestFirstName varchar(100) not null,
guestLastName varchar(100) not null,
guestAddress varchar(100) not null,
passportNumber varchar(100) not null,
guestCountry varchar(100) not null,
guestContact varchar(15) not null,
guestStatus varchar(50) default 'in' not null
);
create table RoomType
(
typeId int auto_increment
primary key,
typeName varchar(100) not null,
typePrice decimal(6, 2) not null
);
create table Room
(
roomNumber varchar(10) not null
primary key,
typeId int not null,
roomStatus varchar(50) not null,
constraint Room_RoomType_typeId_fk
foreign key (typeId) references RoomType (typeId)
);
create table User
(
userId varchar(50) not null
primary key,
firstName varchar(100) not null,
email varchar(100) not null,
contact varchar(11) not null,
userRole varchar(50) not null,
userName varchar(100) not null,
password varchar(100) not null
);
create table Reservation
(
resvId varchar(20) not null
primary key,
resvDate date not null,
guestId varchar(50) not null,
checkInDate date not null,
checkOutDate date not null,
userId varchar(50) not null,
status varchar(20) default 'check-in' null,
constraint Reservation_FK
foreign key (guestId) references Guest (guestId),
constraint Reservation_FK_1
foreign key (userId) references User (userId)
);
create table CheckOut
(
checkOutId int auto_increment
primary key,
resvId varchar(20) not null,
userId varchar(50) not null,
date date not null,
noOfNight int not null,
totalPrice decimal(7, 2) not null,
constraint CheckOut_FK
foreign key (resvId) references Reservation (resvId),
constraint CheckOut_FK_1
foreign key (userId) references User (userId)
);
create table ReservationDetail
(
resvId varchar(20) not null,
roomNumber varchar(10) not null,
roomPrice decimal(6, 2) not null,
primary key (resvId, roomNumber),
constraint RoomDetail_FK
foreign key (resvId) references Reservation (resvId),
constraint RoomDetail_FK_1
foreign key (roomNumber) references Room (roomNumber)
);