CREATE TABLE [GGUser] (
	[UserID] [varchar] (50) NOT NULL ,
	[PasswordMD5] [varchar] (100) NOT NULL ,
	[Name] [nvarchar] (50) NOT NULL ,
	[Friends] [nvarchar] (4000) NOT NULL ,
    [CommentNames] [nvarchar] (4000) NOT NULL ,	
	[Signature] [nvarchar] (100) NOT NULL ,
	[HeadImageIndex] [int] NOT NULL ,
	[HeadImageData] [image] NULL ,
	[Groups] [varchar] (1000) NOT NULL ,
	[CreateTime] [datetime] NOT NULL ,
	[Version] [int] NOT NULL ,
	CONSTRAINT [PK_GGUser] PRIMARY KEY  CLUSTERED 
	(
		[UserID]
	)  ON [PRIMARY] 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [GGGroup] (
	[GroupID] [varchar] (20) NOT NULL ,
	[Name] [nvarchar] (20) NOT NULL ,
	[CreatorID] [varchar] (20) NOT NULL ,
	[Announce] [nvarchar] (200) NOT NULL ,
	[Members] [nvarchar] (4000) NOT NULL ,
	[CreateTime] [datetime] NOT NULL ,
	[Version] [int] NOT NULL ,
	CONSTRAINT [PK_GGGroup] PRIMARY KEY  CLUSTERED 
	(
		[GroupID]
	)  ON [PRIMARY] 
) ON [PRIMARY]
GO

CREATE TABLE [ChatMessageRecord] (
	[AutoID] [bigint] IDENTITY (1, 1) NOT NULL ,
	[SpeakerID] [varchar] (20) NOT NULL ,
	[AudienceID] [varchar] (20) NOT NULL ,
	[IsGroupChat] [bit] NOT NULL ,
	[Content] [image] NOT NULL ,
	[OccureTime] [datetime] NOT NULL ,
	CONSTRAINT [PK_ChatMessageRecord] PRIMARY KEY  CLUSTERED 
	(
		[AutoID]
	)  ON [PRIMARY] 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE  INDEX [IX_ChatMessageRecord] ON [dbo].[ChatMessageRecord]([SpeakerID], [AudienceID], [OccureTime]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_ChatMessageRecord_1] ON [dbo].[ChatMessageRecord]([AudienceID], [OccureTime]) ON [PRIMARY]
GO


CREATE TABLE [dbo].[GGConfiguration](
	[GGKey] [varchar](20) NOT NULL,
	[GGValue] [nvarchar](1000) NOT NULL,
 CONSTRAINT [PK_GGConfiguration] PRIMARY KEY CLUSTERED 
(
	[GGKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

INSERT [dbo].[GGConfiguration] ([GGKey], [GGValue]) VALUES (N'OrgVersion', N'1')


