You are on page 1of 3

create table ProductType(Id int primary key identity,description nvarchar(200));

create table ShipperType(Id int primary key identity,description nvarchar(200));


create table ShippingStatus(Id int primary key identity,description nvarchar(200));
create table DiscountUnitType(Id int primary key identity,description
nvarchar(200));
create table UnitType(Id int primary key identity,description nvarchar(200));
create table CardType(Id int primary key identity,description nvarchar(200));
create table ContactType(Id int primary key identity,description nvarchar(200));
create table ShippingType(Id int primary key identity,description nvarchar(200));
create table SupplierType(Id int primary key identity,description nvarchar(200));
create table Discount(Id int primary key identity,Discount money,description
nvarchar(100));
create table ProductCategory(Id int primary key identity,ProductTypeId int foreign
key references ProductType(Id),description nvarchar(200));
create table ProductSubCategory(Id int primary key identity,ProductCategoryId int
foreign key references ProductCategory(Id),description nvarchar(200));
create table Customer(Id int primary key identity,FirstName
nvarchar(100),MiddleName nvarchar(100),LastName nvarchar(100),ContactName
nvarchar(100),
lastUpdatedBy nvarchar(50),LastUpdatedOn
DateTime);
create table Supplier(Id int primary key identity, SupplierName
nvarchar(100),CompanyName nvarchar(100),CompanyWebsite nvarchar(300),
SupplierTypeId int foreign key
references SupplierType(Id));
create table Shipper(Id int primary key identity, SupplierName
nvarchar(100),CompanyName nvarchar(100),CompanyWebsite nvarchar(300),
shipperTypeId int foreign key references
shipperType(Id));
create table BillingDetail(Id int primary key identity,CreditDebit bit,CardTypeId int
foreign key references CardType(Id),CardNo nvarchar(50), NameOnCard
nvarchar(100),
CardIssueDate
DateTime,CardExpirayDate DateTime, Cvn nvarchar(5),BillingDate DateTime);

create table Product(Id int primary key identity,ProductName


nvarchar(100),ProductTypeId int foreign key references ProductType(Id),
ProductCategoryId int foreign key references
ProductCategory(Id),ProductSubCategoryId int foreign key references
ProductSubCategory(Id),
SupplierId int foreign key references
Supplier(Id));
create table ProductDetail(Id int primary key identity,ProductId int foreign key
references Product(Id),description nvarchar(100),IsPictureAvailable bit,
Picture image,AvailableQuanity
int,UnitOnOrder int,UnitPurchasePrice money,UnitSellPrice money,
DiscountId int foreign key references
Discount(Id),UnitWeight float);
create table Cart(Id int primary key identity,ProductId int foreign key references
Product(Id),Quanity int, TotalPrice money,AddedTime DateTime,ExpiryTime
DateTime,
IsExpired bit);
create table Orders(Id int primary key identity,OrderNo nvarchar(48),CustomerId
int foreign key references Customer(Id),OrderDate DateTime,RequiredDate
DateTime);
create table OrderDetail(Id int primary key identity,ProductId int foreign key
references Product(Id) ,
OrderId int foreign key references Orders(Id) ,UnitTypeId
int foreign key references UnitType(Id),Quantity int,
DiscountUnitTypeId int foreign key references
DiscountUnitType(Id),UnitDiscount int,
TotalDiscount money,UnitAmount money,TotalAmount
money);

create table ShippingDetail(Id int primary key identity,ShipperId int foreign key
references Shipper(Id),
RequiredDate DateTime,ShippingDate DateTime,ShippingTypeId int foreign
key references ShippingType(Id),
ShippingStatusId int foreign key references ShippingStatus(Id));

create table TrackingDetail(Id int primary key identity,


ShippingDetailId int foreign key references ShippingDetail(Id) ,
CurrentStatusDate DateTime, ShippingStatusId int foreign key references
ShippingStatus(Id));

create table ContactDetails(Id int primary key identity,CustomerId int


foreign key references Customer(Id),
SupplierId int foreign key references Supplier(Id),ShipperId int foreign key
references Shipper(Id),
BillingDetailId int foreign key references BillingDetail(Id),ShippingDetailId int
foreign key references ShippingDetail(Id),
Street nvarchar(200),AprtNo nvarchar(100),City nvarchar(100),State
nvarchar(100),Country nvarchar(80),
Zip nvarchar(50),Phone nvarchar(12),AltPhone nvarchar(12),Mobile nvarchar(12),
Email nvarchar(120));

You might also like