SHARE
TWEET

_sql

trongnv May 25th, 2020 (edited) 1,010 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE DATABASE LAYLOIHOI_DB;
  2.  
  3. USE LAYLOIHOI_DB;
  4. GO;
  5.  
  6. CREATE TABLE KHACH_HANG(
  7.     MAKH INT PRIMARY KEY,
  8.     TENKH VARCHAR(30),
  9.     DIACHI VARCHAR(50),
  10.     SODT CHAR(11)
  11. )
  12. CREATE TABLE PHONG(
  13.     MAPHONG INT PRIMARY KEY,
  14.     LOAIPHONG VARCHAR(20),
  15.     SOKHACHTOIDA INT,
  16.     GIAPHONG DECIMAL(6,3),
  17.     MOTA VARCHAR(255)
  18. )
  19. CREATE TABLE DAT_PHONG(
  20.     MADATPHONG INT PRIMARY KEY,
  21.     MAPHONG INT,
  22.     MAKH INT,
  23.     NGAYDAT DATE,
  24.     GIOBATDAU TIME,
  25.     GIOKETTHUC TIME,
  26.     TIENDATCOC DECIMAL(6,3),
  27.     GHICHU VARCHAR(255),
  28.     TRANGTHAIDAT VARCHAR(30),
  29.     FOREIGN KEY (MAPHONG) REFERENCES PHONG(MAPHONG),
  30.     FOREIGN KEY (MAKH) REFERENCES khach_hang(MAKH)
  31. )
  32. CREATE TABLE DICH_VU_DI_KEM(
  33.     MADV INT PRIMARY KEY,
  34.     TENDV VARCHAR(255),
  35.     DONVITINH VARCHAR(30),
  36.     DONGIA DECIMAL(6,3)
  37. )
  38. CREATE TABLE CHI_TIET_SU_DUNG_DV(
  39.     MADATPHONG INT,
  40.     MADV INT,
  41.     SOLUONG INT,
  42.     PRIMARY KEY (MADATPHONG, MADV),
  43.     FOREIGN KEY (MADATPHONG) REFERENCES dat_phong(MADATPHONG)
  44. )
  45.  
  46. -- INSERT DATA
  47.  USE LAYLOIHOI_DB;
  48.  
  49. INSERT INTO [dbo].[PHONG] (MAPHONG, LOAIPHONG, SOKHACHTOIDA, GIAPHONG, MOTA) VALUES
  50. (1, 'LOAI 1', 20, '60.000', ''),
  51. (2, 'LOAI 1', 25, '80.000', ''),
  52. (3, 'LOAI 2', 15, '50.000', ''),
  53. (4, 'LOAI 3', 20, '50.000', '');
  54.  
  55. INSERT INTO [dbo].[KHACH_HANG] (MAKH, TENKH, DIACHI, SODT) VALUES
  56. (1, 'MARIA OZAWA', 'HOA XUAN', '11111111111'),
  57. (2, 'TOKUDA', 'HOA XUAN', '11111111112'),
  58. (3, 'MIKAMI YUA', 'HOA XUAN', '11111111113'),
  59. (4, 'NGUYEN VAN D', 'HOA XUAN', '11111111114');
  60.  
  61. INSERT INTO [dbo].[DICH_VU_DI_KEM] (MADV, TENDV, DONVITINH, DONGIA) VALUES
  62. (1, 'HOT GIRL', 'EM', '10.000'),
  63. (2, 'HOA HAU', 'EM', '20.000'),
  64. (3, 'BEER', 'LON', '10.000'),
  65. (4, 'TRAI CAY', 'DIA', '35.000');
  66.  
  67.  
  68. INSERT INTO [dbo].[DAT_PHONG] (MADATPHONG, MAPHONG, MAKH, NGAYDAT, GIOBATDAU, GIOKETTHUC, TIENDATCOC, GHICHU, TRANGTHAIDAT) VALUES
  69. (1, 1, 2, '2018-03-26', '11:00:00', '13:00:00', '100.000', '', 'DA DAT'),
  70. (2, 1, 3, '2018-03-27', '17:15:00', '19:15:00', '50.000', '', 'DA HUY'),
  71. (3, 2, 2, '2018-03-26', '20:30:00', '22:15:00', '100.000', '', 'DA DAT'),
  72. (4, 3, 1, '2018-04-01', '19:30:00', '21:15:00', '200.000', '', 'DA DAT');
  73.  
  74. INSERT INTO [dbo].[CHI_TIET_SU_DUNG_DV] (MADATPHONG, MADV, SOLUONG) VALUES
  75. (1, 1, 20),
  76. (1, 2, 10),
  77. (1, 3, 3),
  78. (2, 2, 10),
  79. (2, 3, 1),
  80. (3, 3, 2),
  81. (3, 4, 10);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top