-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDemoDatabase.sql
101 lines (84 loc) · 2.9 KB
/
DemoDatabase.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
create database DemoDesignPattern
go
use DemoDesignPattern
go
--Đồ Ăn
-- Bàn Ăn
-- Danh Sách Đồ Ăn
-- Tài Khoản Đăng Nhập
-- Hóa Đơn
-- Thông tin hóa đơn
create table BanAn
(
id_table int identity primary key,
name_table nvarchar (100),
status_table nvarchar(20)
)
go
create table Account
(
email nvarchar(100) primary key,
name nvarchar(100) not null default 'Vippro123',
password nvarchar(100) not null default '1',
role int not null default 0
)
go
create table DanhSachMonAn
(
id_DS int identity primary key,
name nvarchar(100),
)
go
create table MonAn
(
id_MonAn int identity primary key,
name nvarchar(100) not null,
id_DS int not null,
price int not null,
foreign key (id_DS) references DanhSachMonAn(id_DS)
)
go
create table HoaDon
(
id_Bill int identity primary key,
Checkin Date Not null default getDate(),
Checkout date not null,
id_table int not null,
isPay int not null default 0, --Quy Định 0 là chưa trả, 1 là ngược lại
foreign key (id_table) references BanAn(id_table)
)
go
create table ChiTietHoaDon
(
id_Detail_Bill int identity primary key,
id_Bill int not null,
id_Food int not null,
count int not null default 0
foreign key (id_Bill) references HoaDon(id_Bill),
foreign key (id_Food) references MonAn(id_MonAn)
)
go
insert BanAn(name_table, status_table) values (N'Bàn 1','0')
insert BanAn(name_table, status_table) values (N'Bàn 2','0')
insert BanAn(name_table, status_table) values (N'Bàn 3','0')
insert BanAn(name_table, status_table) values (N'Bàn 4','0')
insert BanAn(name_table, status_table) values (N'Bàn 5','0')
insert BanAn(name_table, status_table) values (N'Bàn 6','0')
insert BanAn(name_table, status_table) values (N'Bàn 7','0')
insert BanAn(name_table, status_table) values (N'Bàn 8','0')
insert BanAn(name_table, status_table) values (N'Bàn 9','0')
insert BanAn(name_table, status_table) values (N'Bàn 10','0')
insert BanAn(name_table, status_table) values (N'Bàn 11','0')
insert BanAn(name_table, status_table) values (N'Bàn 12','0')
insert BanAn(name_table, status_table) values (N'Bàn 13','0')
insert BanAn(name_table, status_table) values (N'Bàn 14','0')
insert BanAn(name_table, status_table) values (N'Bàn 15','0')
insert BanAn(name_table, status_table) values (N'Bàn 16','0')
insert BanAn(name_table, status_table) values (N'Bàn 17','0')
insert BanAn(name_table, status_table) values (N'Bàn 18','0')
insert BanAn(name_table, status_table) values (N'Bàn 19','0')
insert BanAn(name_table, status_table) values (N'Bàn 20','0')
insert Account(email,name,password,role) values ('[email protected]',N'Đặng Phúc Huy','123456',3)
insert Account(email,name,password,role) values ('[email protected]',N'Giang Vinh Diễn','GD1234',1)
insert Account(email,name,password,role) values ('[email protected]',N'Nguyễn Đặng Hiếu','DH1234',0)
insert Account(email,name,password,role) values ('[email protected]',N'Trần Gia Huy','GH1234',0)