BAI 1SQL
CREATE DATABASE QLBH1
CREATE TABLE DMKhach (
makhach char (15) primary key ,
tenkhach nvarchar (20)not null,
diachi nvarchar(20),
dienthoai char(12))
CREATE TABLE DMHang (
mahang char (20) primary key ,
tenhang nvarchar (25) not null,
dvt smallint )
CREATE TABLE HOADONBAN (
sohd nvarchar (15) primary key,
makhach char (15) ,
ngayhd smalldatetime ,
diengiai char (30),
CONSTRAINT KN FOREIGN KEY (makhach)REFERENCES DMKhach (makhach))
CREATE TABLE CHITIETHOADONBAN (
SOHD NVARCHAR (15),
MAHANG CHAR (20),
SOLUONG SMALLINT ,
DONGIA INT,
CONSTRAINT KC PRIMARY KEY ( SOHD,MAHANG),
CONSTRAINT KN1 FOREIGN KEY (MAHANG) REFERENCES DMHANG(MAHANG),
CONSTRAINT KN2 FOREIGN KEY (SOHD) REFERENCES HOADONBAN(SOHD))
Bạn đang đọc truyện trên: Truyen247.Pro