Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

use master go if db_id (N\'QLKhachSan\') is not null drop database QLKhachSan Go

ID: 3613738 • Letter: U

Question

use master
go
if db_id (N'QLKhachSan') is not null
drop database QLKhachSan
Go
Create database QLKhachSan
Go
use QLKhachSan
Go
Create table loaiphong
(
maloaiphong nvarchar (20) primary key,
tenloai nvarchar (20),
htnv nvarchar (20)

)
Go

Create table Phong
(
masophong int primary key,
tenphong nvarchar (20),
tiennghi nvarchar (50),
dongiathuetheongay money,
dongiathuetheogio money,
maloaiphong nvarchar (20),
foreign key (maloaiphong) references loaiphong
)
Go


Create table Khachhang
(
socmnd int primary key,
tenkhachhang nvarchar(20),
diachi nvarchar(50)

)
Go
Create table Dichvu
(
madichvu nvarchar(20)primary key,
tendichvu nvarchar(20),
dongia money,
donvitinh nvarchar (20)

)
Go
Create table NK_Traphong
(
socmnd int,
masophong int,
sohoadontt int primary key,
ttphongluctra nvarchar (50),
ngaytra datetime,
foreign key (masophong) references Phong,
foreign key (socmnd) references Khachhang
)
Go
Create table NK_Thuephong
(
socmnd int,
masophong int,
sophieuthue int primary key,
ngaythue datetime,
ngaydukientra datetime,
ttphongbandau nvarchar(50),
foreign key (masophong) references Phong,
foreign key (socmnd) references Khachhang
)
Go
Create table KH_Dichvu
(
socmnd int,
madichvu nvarchar (20),
sophieudichvu int primary key,
ngaysudung datetime,
sotien money,
foreign key (socmnd) references Khachhang,
foreign key (madichvu) references Dichvu
)
Go
---------------------------------------
Insert into Phong values (10,'A','Ð?y d?',500,50,'T')
Insert into Phong values (70,'B','Sang tr?ng',1000,100,'V')
Insert into Phong values (11,'A','Ð?y d?',500,50,'T')
Insert into Phong values (50,'B','Sang tr?ng',500,50,'V')
Insert into Phong values (60,'D','Ð?y d?',500,50,'T')
Insert into Phong values (80,'C','Sang tr?ng',500,50,'V')
------
Insert into LoaiPhong values ('V','VIP','Nguy?n Ng?c Duy')
Insert into LoaiPhong values ('T','Thuong','Ph?m ThànhLuân')
Insert into LoaiPhong values ('V','VIP','Tr?n Quang Kh?i')
Insert into LoaiPhong values ('T','Thuong','Vu Th? H?ngLiên')
Insert into LoaiPhong values ('V','VIP','Ðinh Th? H?ngLiên')
Insert into LoaiPhong values ('T','Thuong','Ph?m ThànhHuân')
------
Insert into Khachhang values (031475624,'Nguy?n Ng?c Duy','79Nguy?n Ð?c C?nh')
Insert into Khachhang values (031475627,'Ph?m ThànhHuân','34 Lê L?i')
Insert into Khachhang values (031475215,'Ðinh Th? H?ngLiên','790 Ðà N?ng')
Insert into Khachhang values (034472227,'Tr?n Quang Kh?i','203/12Ð?ng Qu?c Bình')
Insert into Khachhang values (045475624,'Ph?m ThànhLuân','234 Dân L?p')
Insert into Khachhang values (031435629,'Vu Th? H?ngLiên','346 L?ch Tray')
------
Insert into Dichvu values ('M01','Nu?c ng?t',8000,'Chai')
Insert into Dichvu values ('M02','Ð? an',30000,'Xu?t')
Insert into Dichvu values ('M03','Massage',200000,'Gi?')
Insert into Dichvu values ('M04','Boi',50000,'Gi?')
Insert into Dichvu values ('M05','Karaoke',200000,'Gi?')

-----------
Insert into NK_ThuePhong values(031475624,70,100,'01-08-2009','01-08-2010','Ð?y d? ti?n nghinhu trong danh sách')
Insert into NK_ThuePhong values(031475627,10,101,'05-08-2009','09-08-2010','Ð?y d? ti?n nghinhu trong danh sách')
Insert into NK_ThuePhong values(031475215,50,102,'06-08-2009','08-08-2009','Ð?y d? ti?n nghinhu trong danh sách')
Insert into NK_ThuePhong values(034472227,11,103,'02-10-2009','09-08-2009','Ð?y d? ti?n nghinhu trong danh sách')
Insert into NK_ThuePhong values(045475624,60,104,'01-15-2009','03-08-2010','Ð?y d? ti?n nghinhu trong danh sách')
Insert into NK_ThuePhong values(031435629,80,105,'01-20-2009','05-08-2010','Ð?y d? ti?n nghinhu trong danh sách')
---------
Insert into NK_Traphong values (031475624,70,123,'Ð?y d?và không hu h?i','08-01-2009')
Insert into NK_Traphong values (031475627,10,124,'Ð?y d?và không hu h?i','08-02-2009')
Insert into NK_Traphong values (031475215,50,125,'Ð?y d?và không hu h?i','09-03-2009')

-------
insert into KH_DichVu values (031475624,'M01',302,'01-08-2009',40000)
insert into KH_DichVu values (031475624,'M02',303,'01-09-2009',60000)
insert into KH_DichVu values (031475624,'M03',304,'01-10-2009',200000)
insert into KH_DichVu values (031475627,'M01',305,'05-08-2009',32000)
insert into KH_DichVu values (031475627,'M02',306,'05-09-2009',30000)
insert into KH_DichVu values (031475627,'M05',307,'05-10-2009',400000)
insert into KH_DichVu values (031475215,'M01',308,'06-12-2009',32000)
insert into KH_DichVu values (034472227,'M04',309,'02-11-2009',100000)
insert into KH_DichVu values (045475624,'M01',400,'01-15-2009',24000)
insert into KH_DichVu values (031435629,'M01',401,'01-20-2009',16000)
insert into KH_DichVu values (031435629,'M02',402,'01-21-2009',90000)
select * from KH_DICHVU

Explanation / Answer

please, fix my error