use aspxcndb
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Lists]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Lists]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Reply]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Reply]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fav]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[fav]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Msg]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Msg]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Catalog]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Catalog]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Class]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Class]
GO

CREATE TABLE [dbo].[Lists] (
[ListId] int IDENTITY (1, 1) NOT NULL,
[UserName] nvarchar(50) NULL,
[Catalog] int NULL,
[Class] int NULL,
[IsTop] bit NULL,
[_Date] datetime NULL,
[_Content] ntext NULL,
[_Title] nvarchar(100) NULL,
[Hits] int NULL,
[Reply] int NULL,
[Type] int NULL,
[Email] nvarchar(50) NULL,
[Recommend] bit NULL,
[IP] nvarchar(20) NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Lists] WITH NOCHECK ADD
CONSTRAINT [PK_Lists] PRIMARY KEY CLUSTERED
(
[ListId]
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Reply] (
[id] int IDENTITY (1, 1) NOT NULL,
[TopIc_ID] int NOT NULL,
[_Title] nvarchar(100) NULL,
[_Content] ntext NULL,
[UserName] nvarchar(50) NULL,
[Email] nvarchar(50) NULL,
[IP] nchar(20) NULL,
[_DateTime] datetime NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Reply] WITH NOCHECK ADD
CONSTRAINT [PK_Reply] PRIMARY KEY CLUSTERED
(
[id]
) ON [PRIMARY]
GO

CREATE INDEX [TopIc_ID] ON [dbo].[Reply]([TopIc_ID]) ON [PRIMARY]
GO

CREATE TABLE [dbo].[fav] (
[Listid] int IDENTITY (1, 1) NOT NULL,
[UserName] nchar(10) NULL,
[Add_DateTime] datetime NULL,
[favID] int NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[fav] WITH NOCHECK ADD
CONSTRAINT [PK_fav] PRIMARY KEY CLUSTERED
(
[Listid]
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Msg] (
[ID] int IDENTITY (1, 1) NOT NULL,
[Msg_Title] nvarchar(100) NULL,
[Msg_Content] nvarchar(300) NULL,
[From_userName] nvarchar(50) NULL,
[To_userName] nvarchar(50) NULL,
[Msg_DateTime] datetime NULL,
[IsRead] bit NULL,
[FromIsDel] bit NULL,
[ToIsDel] bit NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Msg] WITH NOCHECK ADD
CONSTRAINT [PK_Msg] PRIMARY KEY CLUSTERED
(
[ID]
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Catalog] (
[id] int IDENTITY (1, 1) NOT NULL,
[Name] nvarchar(20) NULL,
[Show] bit NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Catalog] WITH NOCHECK ADD
CONSTRAINT [PK_Catalog] PRIMARY KEY CLUSTERED
(
[id]
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Class] (
[id] int IDENTITY (1, 1) NOT NULL,
[Name] nvarchar(20) NULL,
[Catalogid] int NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Class] WITH NOCHECK ADD
CONSTRAINT [PK_Class] PRIMARY KEY CLUSTERED
(
[id]
) ON [PRIMARY]
GO

