2012-04-30 56 views
-2

我想管理一个n标签评论系统并设计一个这样的数据库结构。 my database structure评论系统的结构

我想设计一个支持未注册用户的评论审核的数据库。我需要的功能是当发布评论时

  • 如果用户注册,它会直接出现。除此以外;
  • 该帖子必须由主持人检查才出现。

请建议对我的数据库模式进行可能的更改以支持此功能。

+0

在我为您写回答之前,几乎没有问题:1)您如何识别用户是否已注册,您是否拥有RegisteredUser表? 2)你已经显示了'BlogSetting'表,但它没有出现任何链接。是否有一个'Blog'表是'BlogSetting'和'BlogPost'的父亲? (提示:应该有!)3)'BlogBlockedUser'如何进入? – Jamiec

+0

@Jamiec雅我有'RegisteredUser' table.Blog seeting是页面加载时获取。它由我的'sp'管理。 –

回答

1

看起来你有或多或少的需求,为了做你想做的事情。当用户创建一个新的评论的过程如下

if the user is registered, and not blocked 
    create BlogComment record with: 
      IsApproved=true 
      IsBlocked=false 
      UserId=registered userId 
      UserName = null 
if the user is registered and blocked 
    create BlogComment record with 
      IsApproved=false 
      IsBlocked=true 
      UserId=registered userId 
      UserName = null 
if the user is unregistered 
    create BlogComment record with 
     IsApproved=false 
     IsBlocked=false 
     UserId=null 
     UserName=user's name 

当你拉出来的意见,看看下面你要像

SELECT Comment, ISNULL(bc.UserName, ru.UserName) AS UserName 
FROM BlogComment bc 
LEFT JOIN RegisteredUser ru 
    ON bc.UserId = ru.Id 
WHERE postId=<current PostId> 
AND IsApproved=1 

这将退出所有已批准评论的查询(那些帖子来自注册用户或已注册的未注册用户)以及他们的用户名(对于注册用户,这将是他们的用户名RegisteredUser表,未注册它将保存在BlogComment表中的注释旁边)

最后,当你想拔出职位名单的主持人,中度

SELECT * 
FROM BlogComment 
WHERE IsApproved=0 
AND IsBlocked=0 

然后,您可以更新他们接受IsApproved=1记录。

+0

非常感谢给我一个很好的方法。我明白了我想要的。 –