-
Notifications
You must be signed in to change notification settings - Fork 0
/
FirstWithMrThut.sql
51 lines (45 loc) · 1.03 KB
/
FirstWithMrThut.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
create database qlbh_new
go
use qlbh_new
go
CREATE TABLE KHACHHANG
(
MAKH char(4) CONSTRAINT PK_KH PRIMARY KEY,
HOTEN varchar(40),
DCHI varchar(50),
SODT VARCHAR(20),
NGSINH SMALLdatetime,
NGDK SMALLdatetime,
)
CREATE TABLE NHANVIEN
(
MANV char(4) CONSTRAINT PK_NV PRIMARY KEY,
HOTEN varchar(40) ,
SODT varchar(20),
NGVL SMALLdatetime
)
CREATE TABLE SANPHAM
(
MASP char(4) CONSTRAINT PK_SP PRIMARY KEY,
TENSP VARCHAR(40),
DVT VARCHAR(20),
NUOCSX VARCHAR(40) ,
GIA money ,
)
CREATE TABLE HOADON
(
SOHD INT CONSTRAINT PK_HD PRIMARY KEY,
NGHD SMALLDATETIME,
MAKH CHAR(4) CONSTRAINT FK_HD_KH FOREIGN KEY REFERENCES KHACHHANG(MAKH),
MANV CHAR(4) CONSTRAINT FK_HD_NV FOREIGN KEY REFERENCES NHANVIEN(MANV),
TRIGIA MONEY,
)
CREATE TABLE CTHD
(
SOHD INT CONSTRAINT FK_CTHD_HD FOREIGN KEY REFERENCES HOADON(SOHD),
MASP CHAR(4) CONSTRAINT FK_CTHD_SP FOREIGN KEY REFERENCES SANPHAM(MASP),
SL INT,
CONSTRAINT PK_CTHD PRIMARY KEY(SOHD, MASP),
)
SELECT * FROM NHANVIEN
INSERT INTO NHANVIEN VALUES ('NV01', 'TAM', '02900293',05-05-2002)