SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblorderBook]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblorderBook](
[orderID] [int] NOT NULL,
[bookID] [int] NOT NULL,
[quality] [int] NOT NULL,
[soldPrice] [numeric](18, 1) NOT NULL,
[paysum] [numeric](18, 1) NOT NULL,
CONSTRAINT [PK_tblorderBook] PRIMARY KEY CLUSTERED
(
[orderID] ASC,
[bookID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tbluser]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tbluser](
[userID] [int] IDENTITY(1,1) NOT NULL,
[userName] [nvarchar](50) NOT NULL,
[userPwd] [nvarchar](50) NOT NULL,
[trueName] [nvarchar](30) NULL,
[address] [nvarchar](80) NULL,
[telephone] [nvarchar](30) NULL,
[postcode] [nvarchar](20) NULL,
[sex] [char](2) NOT NULL CONSTRAINT [DF_tbluser_sex] DEFAULT ('男'),
[userType] [smallint] NOT NULL,
CONSTRAINT [PK_tbluser] PRIMARY KEY CLUSTERED
(
[userID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[pinglun]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[pinglun](
[postID] [int] IDENTITY(1,1) NOT NULL,
[bookID] [int] NOT NULL,
[textname] [varchar](100) NOT NULL,
[userName] [nvarchar](50) NOT NULL,
[text] [varchar](1000) NOT NULL,
[speaktime] [datetime] NOT NULL,
CONSTRAINT [PK_pinglun] PRIMARY KEY CLUSTERED
(
[postID] ASC,
[bookID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblBook]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblBook](
[bookID] [int] IDENTITY(1,1) NOT NULL,
[typeID] [int] NOT NULL,
[bookName] [nvarchar](50) NOT NULL,
[bookAuthor] [nvarchar](50) NULL,
[bookPrice] [numeric](18, 1) NOT NULL,
[publisher] [nvarchar](50) NULL,
[publishDate] [smalldatetime] NULL,
[bookImage] [nvarchar](50) NULL,
[IsSelling] [bit] NOT NULL CONSTRAINT [DF_tblBook_IsSelling] DEFAULT ((0)),
CONSTRAINT [PK_tblBook] PRIMARY KEY CLUSTERED
(
[bookID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1代表正在出售,0代表没有' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'tblBook', @level2type=N'COLUMN', @level2name=N'IsSelling'
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblorder]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblorder](
[orderID] [int] IDENTITY(1,1) NOT NULL,
[userID] [int] NOT NULL,
[orderTime] [smalldatetime] NOT NULL CONSTRAINT [DF_tblorder_orderTime] DEFAULT (getdate()),
[orderSum] [numeric](10, 1) NOT NULL,
[payment] [nvarchar](20) NOT NULL CONSTRAINT [DF_tblorder_payment] DEFAULT (N'银行支付'),
[ship] [nvarchar](20) NOT NULL CONSTRAINT [DF_tblorder_ship] DEFAULT (N'平邮'),
[buyerName] [nvarchar](30) NOT NULL,
[buyerEmail] [nvarchar](50) NOT NULL,
[buyerAddress] [nvarchar](60) NOT NULL,
[buyerCode] [nvarchar](30) NOT NULL,
[buyerTel] [nvarchar](30) NOT NULL,
[IsPayed] [smallint] NOT NULL CONSTRAINT [DF_tblorder_IsPayed] DEFAULT ((0)),
CONSTRAINT [PK_tblorder] PRIMARY KEY CLUSTERED
(
[orderID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblType]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblType](
[typeID] [int] NOT NULL,
[typeName] [sysname] NOT NULL,
[fatherID] [int] NULL,�
评论4