新闻评论系统:我的表设计如下,请求效率等问题。。。
目前设计在一个表内,考虑到对评论人的回复 + 对于回复的回复的回复。。。
设计如下,请各位提出意见,谢谢:
--评论表
create table [dbo].[Comment]
(
[ID] int identity (1,1) primary key not null,
[aid] int not null,--文章ID
[replyid] int null,--回复ID
[replycount] int null,--回复数
[uid] int not null,--评论人ID
[uname] nvarchar(30) not null,--评论人用户名
[createtime] datetime default getdate() not null,--评论时间
[content] nvarchar(2000) null,--评论内容
[state] int default(1) not null--状态
) on [primary]
go
create index index_Comment on Comment (aid,replyid)
go
还有个站内短信息,也是采用类似的结构,也请看看吧:
--短信息
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Message]'))
drop table [dbo].[Message]
go
create table [dbo].[Message]
(
[ID] int identity (1,1) primary key not null,
[replyid] int null,--回复ID
[uid] int not null,--发送人ID
[uname] nvarchar(30) not null,--发送人用户名
[createtime] datetime default getdate() not null,--发送时间
[content] nvarchar(2000) null,--发送内容
[uid] int not null,--接收人ID
[uname] nvarchar(30) not null,--接收人用户名
[createtime] datetime null,--接收时间
[state] int default(1) not null--状态
) on [primary]
go
create index index_Message on [Message] (replyid)
go
网上查了下有的分成多个表,第一次做评论系统,请大家发表下意见谢谢了!