【SQL开源代码栏目提醒】:网学会员在SQL开源代码频道为大家收集整理了BookShop.sql提供大家参考,希望对大家有所帮助!
/*==============================================================*/
/* Database name: BookShop */
/* DBMS name:
sqlServer2000(Extend) */
/* Created on: 2006-8-27 9:07:10 */
/*==============================================================*/
/*==============================================================*/
/* Table: Account */
/*==============================================================*/
create table Account (
ProfileID int not null
/*ProfileID*/,
UserName nvarchar(50) not null
/*UserName*/,
Address nvarchar(100) not null
/*Address*/,
Phone nvarchar(20) not null
/*Phone*/,
Mail nvarchar(50) not null
/*Mail*/,
Country nvarchar(20) not null
/*Country*/,
Code nvarchar(20) not null
/*Code*/
)
go
/*==============================================================*/
/* Table: Cart */
/*==============================================================*/
create table Cart (
ItemID int not null
/*ItemID*/,
ProfileID int not null
/*ProfileID*/,
ProductID int not null
/*ProductID*/,
ProductName nvarchar(50) not null
/*ProductName*/,
Price decimal(10,2) not null
/*Price*/,
Quantity int not null
/*Quantity*/
)
go
/*==============================================================*/
/* Table: Category */
/*==============================================================*/
create table Category (
CategoryID int identity
/*CategoryID*/,
CategoryName nvarchar(50) not null
/*CategoryName*/,
CategoryDescription nvarchar(300) not null
/*CategoryDescription*/,
constraint PK_CATEGORY primary key (CategoryID)
)
go
/*==============================================================*/
/* Table: Item */
/*==============================================================*/
create table Item (
ItemID int identity
/*ItemID*/,
ProductID int null
/*ProductID*/,
SupplierID int null
/*SupplierID*/,
Price decimal(10,2) not null
/*Price*/,
ProductName nvarchar(50) not null
/*ProductName*/,
ProductImage nvarchar(100) not null
/*ProductImage*/,
constraint PK_ITEM primary key (ItemID)
)
go
/*==============================================================*/
/* Table: OrderItem */
/*==============================================================*/
create table OrderItem (
OrderID int null
/*OrderID*/,
ItemID int not null
/*ItemID*/,
LineNumber int not null
/*LineNumber*/,
Quantity int not null
/*Quantity*/,
Price decimal(10,2) not null
/*Price*/
)
go
/*==============================================================*/
/* Table: Orders */
/*==============================================================*/
create table Orders (
OrderID int identity
/*OrderID*/,
OrderDate datetime not null
/*OrderDate*/,
UserName nvarchar(50) not null
/*UserName*/,
BillAddress nvarchar(100) not null
/*BillAddress*/,
BillCode nvarchar(20) not null
/*BillCode*/,
BillCountry nvarchar(20) not null
/*BillCountry*/,
ShipAddress nvarchar(100) not null
/*ShipAddress*/,
ShipCode nvarchar(20) not null
/*ShipCode*/,
ShipCountry nvarchar(20) not null
/*ShipCountry*/,
BillToName nvarchar(50) not null
/*BillToName*/,
ShipToName nvarchar(50) not null
/*ShipToName*/,
TotalPrice decimal(10,2) not null
/*TotalPrice*/,
constraint PK_ORDERS primary key (OrderID)
)
go
/*==============================================================*/
/* Table: Product */
/*==============================================================*/
create table Product (
ProductID int identity
/*ProductID*/,
CategoryID int null
/*CategoryID*/,
ProductName nvarchar(50) not null
/*ProductName*/,
ProductDescription nvarchar(300) not null
/*ProductDescription*/,
ProductImage nvarchar(100) not null
/*ProductImage*/,
constraint PK_PRODUCT primary key (ProductID)
)
go
/*==============================================================*/
/* Table: ProductCount */
/*==============================================================*/
create table ProductCount (
ItemID int null
/*ItemID*/,
Count int not null
/*Count*/
)
go
/*==============================================================*/
/* Table: Profiles */
/*==============================================================*/
create table Profiles (
ProfileID int identity
/*ProfileID*/,
UserName nvarchar(50) not null
/*UserName*/,
LastActivityDate datetime not null
/*Last