if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_linkGang_linkGroup]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[linkGang] DROP CONSTRAINT FK_linkGang_linkGroup
GO

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

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

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

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

CREATE TABLE [dbo].[linkGang] (
	[pkId] [int] IDENTITY (1, 1) NOT NULL ,
	[name] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[pic] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[url] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[ordering] [int] NULL ,
	[isTop] [int] NULL ,
	[userId] [int] NULL ,
	[updateTime] [datetime] NULL ,
	[updateIp] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[passed] [int] NULL ,
	[gradeId] [int] NULL ,
	[gate] [int] NULL ,
	[menuId] [int] NULL ,
	[IsPicLink] [int] NULL ,
	[height] [int] NULL ,
	[width] [int] NULL ,
	[groupId] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[linkGroup] (
	[pkId] [int] IDENTITY (1, 1) NOT NULL ,
	[groupName] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[remark] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[ordering] [int] NULL ,
	[userId] [int] NULL ,
	[updateTime] [datetime] NULL ,
	[updateIp] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[gradeId] [int] NULL ,
	[gate] [int] NULL ,
	[bigClassId] [int] NULL ,
	[menuId] [int] NULL ,
	[isShow] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[messageBoard] (
	[pkId] [int] IDENTITY (1, 1) NOT NULL ,
	[title] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[checked] [int] NULL ,
	[author] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[tel] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[isSecrecy] [int] NULL ,
	[email] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[sex] [varchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
	[homePage] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL ,
	[reContent] [ntext] COLLATE Chinese_PRC_CI_AS NULL ,
	[userId] [int] NULL ,
	[updateTime] [datetime] NULL ,
	[updateIp] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[click] [int] NULL ,
	[isTop] [int] NULL ,
	[MenuId] [int] NULL ,
	[gradeId] [int] NULL ,
	[bigClassId] [int] NULL ,
	[gate] [int] NULL ,
	[username] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[password] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[retime] [datetime] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[messageBoardProperty] (
	[pkId] [int] IDENTITY (1, 1) NOT NULL ,
	[allowAnonymityAppear] [int] NULL ,
	[isAllowAnonymityAppearSecrecy] [int] NULL ,
	[isAnonymityAuditing] [int] NULL ,
	[isRegisterAuditing] [int] NULL ,
	[isShowIp] [int] NULL ,
	[suspendUseMessageBoard] [int] NULL ,
	[isShowRespondFlag] [int] NULL ,
	[showParticularListWidth] [int] NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[linkGang] ADD 
	CONSTRAINT [PK_linkGang] PRIMARY KEY  CLUSTERED 
	(
		[pkId]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[linkGroup] ADD 
	CONSTRAINT [PK_linkGroup] PRIMARY KEY  CLUSTERED 
	(
		[pkId]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[messageBoard] ADD 
	CONSTRAINT [PK_messageBoard] PRIMARY KEY  CLUSTERED 
	(
		[pkId]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[messageBoardProperty] ADD 
	CONSTRAINT [MessageBoardProperty_PK] PRIMARY KEY  CLUSTERED 
	(
		[pkId]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[linkGang] ADD 
	CONSTRAINT [FK_linkGang_linkGroup] FOREIGN KEY 
	(
		[groupId]
	) REFERENCES [dbo].[linkGroup] (
		[pkId]
	)
GO

