use [NetHookUser]
GO

-- UserInfo 用户信息表
CREATE TABLE [dbo].[UserInfo] (
	[AutoID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[UserName] [varchar] (32) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[UserPass] [varchar] (32) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[UserLevel] [int] NOT NULL ,
	[IconID] [int] NOT NULL ,
	[OnlineTime] [int] NOT NULL, 
	[VipLevel] [int] NOT NULL ,
	[Gold] [int] NOT NULL ,
	[Bean] [int] NOT NULL ,
	[AdminRight] [int] NOT NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[UserInfo] WITH NOCHECK ADD 
	CONSTRAINT [PK_UserInfo] PRIMARY KEY  CLUSTERED 
	(
		[AutoID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[UserInfo] ADD 
	CONSTRAINT [DF_UserInfo_UserID] DEFAULT (0) FOR [UserID],
	CONSTRAINT [DF_UserInfo_UserLevel] DEFAULT (0) FOR [UserLevel],
	CONSTRAINT [DF_UserInfo_IconID] DEFAULT (0) FOR [IconID],
	CONSTRAINT [DF_UserInfo_OnlineTime] DEFAULT (0) FOR [OnlineTime],
	CONSTRAINT [DF_UserInfo_VipLevel] DEFAULT (0) FOR [VipLevel],
	CONSTRAINT [DF_UserInfo_Gold] DEFAULT (0) FOR [Gold],
	CONSTRAINT [DF_UserInfo_Bean] DEFAULT (0) FOR [Bean],
	CONSTRAINT [DF_UserInfo_AdminRight] DEFAULT (0) FOR [AdminRight],
	CONSTRAINT [IX_UserInfo_UserName] UNIQUE  NONCLUSTERED 
	(
		[UserName]
	)  ON [PRIMARY],
	CONSTRAINT [IX_UserInfo_UserID] UNIQUE  NONCLUSTERED 
	(
		[UserID]
	)  ON [PRIMARY]  
GO

--UserFriend 好友信息表
CREATE TABLE [dbo].[UserFriend] (
	[AutoID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[FriendID] [int] NOT NULL ,
	[GroupID] [int] NOT NULL ,
	[IsAuth] [int] NOT NULL ,
	[AddTime] [int] NOT NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[UserFriend] WITH NOCHECK ADD 
	CONSTRAINT [PK_UserFriend] PRIMARY KEY  CLUSTERED 
	(
		[AutoID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[UserFriend] ADD 
	CONSTRAINT [DF_UserFriend_UserID] DEFAULT (0) FOR [UserID],
	CONSTRAINT [DF_UserFriend_FriendID] DEFAULT (0) FOR [FriendID],
	CONSTRAINT [DF_UserFriend_GroupID] DEFAULT (0) FOR [GroupID],
	CONSTRAINT [DF_UserFriend_IsAuth] DEFAULT (0) FOR [IsAuth],
	CONSTRAINT [DF_UserFriend_AddTime] DEFAULT (0) FOR [AddTime]
GO
 
CREATE  INDEX [IX_UserFriend_UserID] ON [dbo].[UserFriend]([UserID]) ON [PRIMARY]
GO

--UserFriendGroup 好友分组表
CREATE TABLE [dbo].[UserFriendGroup] (
	[AutoID] [int] IDENTITY (1, 1) NOT NULL ,
	[UserID] [int] NOT NULL ,
	[GroupID] [int] NOT NULL ,
	[GroupName] [varchar] (32) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[AddTime] [int] NOT NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[UserFriendGroup] WITH NOCHECK ADD 
	CONSTRAINT [PK_UserFriendGroup] PRIMARY KEY  CLUSTERED 
	(
		[AutoID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[UserFriendGroup] ADD 
	CONSTRAINT [DF_UserFriendGroup_UserID] DEFAULT (0) FOR [UserID],
	CONSTRAINT [DF_UserFriendGroup_GroupID] DEFAULT (0) FOR [GroupID],
	CONSTRAINT [DF_UserFriendGroup_GroupName] DEFAULT ('') FOR [GroupName],
	CONSTRAINT [DF_UserFriendGroup_AddTime] DEFAULT (0) FOR [AddTime]
GO
 
CREATE  INDEX [IX_UserFriendGroup_UserID] ON [dbo].[UserFriendGroup]([UserID]) ON [PRIMARY]
GO

-- UserActiveInfo 用户活动信息表
CREATE TABLE [dbo].[UserActiveInfo] (
	[UserID] [int] NOT NULL ,
	[RegTime] [int] NOT NULL ,
	[RegIP] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[LastLoginTime] [int] NOT NULL ,
	[LastLoginIP] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[LoginTimes] [int] NOT NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[UserActiveInfo] WITH NOCHECK ADD 
	CONSTRAINT [PK_UserActiveInfo] PRIMARY KEY  CLUSTERED 
	(
		[UserID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[UserActiveInfo] ADD 
	CONSTRAINT [DF_UserActiveInfo_RegTime] DEFAULT (0) FOR [RegTime],
	CONSTRAINT [DF_UserActiveInfo_RegIP] DEFAULT ('') FOR [RegIP],
	CONSTRAINT [DF_UserActiveInfo_LastLoginTime] DEFAULT (0) FOR [LastLoginTime],
	CONSTRAINT [DF_UserActiveInfo_LastLoginIP] DEFAULT ('') FOR [LastLoginIP],
	CONSTRAINT [DF_UserActiveInfo_LoginTimes] DEFAULT (0) FOR [LoginTimes]
GO