Tài liệu 5
Tài liệu 5
Tài liệu 5
TẠO DATABASE:
CREATE DATABASE WEBPHIM
TẠO BẢNG:
USE WEBPHIM
TENGIAODICH Nvarchar(30),
DIACHI Nvarchar(50),
DIENTHOAI Nvarchar(15),
FAX Nvarchar(15),
EMAIL Nvarchar(30)
);
);
MACONGTY Nvarchar(10),
MALOAIHANG Nvarchar(10),
SOLUONG INT,
DONVITINH Nvarchar(10),
GIAHANG INT,
CONSTRAINT fk_MATHANG_MACONGTY
FOREIGN KEY(MACONGTY)
REFERENCES NHACUNGCAP(MACONGTY),
CONSTRAINT fk_MATHANG_MALOAIHANG
FOREIGN KEY(MALOAIHANG)
REFERENCES LOAIHANG(MALOAIHANG)
);
NGAYSINH DateTime,
NGAYLAMVIEC DateTime,
DIACHI Nvarchar(50),
DIENTHOAI Nvarchar(15),
LUONGCOBAN INT,
PHUCAP INT,
);
TENGIAODICH Nvarchar(30),
DIACHI Nvarchar(50),
DIENTHOAI Nvarchar(15),
FAX Nvarchar(15),
EMAIL Nvarchar(30),
);
MAKHACHHANG Nvarchar(10),
MANHANVIEN Nvarchar(10),
NGAYDATHANG DateTime,
NGAYGIAOHANG DateTime,
NGAYCHUYENHANG DateTime,
NOIGIAOHANG Nvarchar(50),
CONSTRAINT fk_DONDATHANG_MAKHACHHANG
FOREIGN KEY(MAKHACHHANG)
REFERENCES KHACHHANG(MAKHACHHANG),
CONSTRAINT fk_DONDATHANG_MANHANVIEN
FOREIGN KEY(MANHANVIEN)
REFERENCES NHANVIEN(MANHANVIEN)
);
GIABAN INT,
SOLUONG SmallInt,
MUCGIAMGIA NumeriC(2,1),
CONSTRAINT fk_CHITIETDATHANG_SOHOADON
FOREIGN KEY(SOHOADON)
REFERENCES DONDATHANG(SOHOADON),
CONSTRAINT fk_CHITIETDATHANG_MAHANG
FOREIGN KEY(MAHANG)
REFERENCES MATHANG(MAHANG)
);
ADD
CONSTRAINT df_CHITIETDATHANG_SOLUONG
ADD
CONSTRAINT df_CHITIETDATHANG_MUCGIAMGIA