帮助数据库结构

时间:2010-10-20 10:19:35

标签: sql sql-server database database-design

我正在尝试创建一个允许本地网络用户一起协作内容的系统。

要求:用户应该能够:

  1. 制作内容,
  2. 编辑内容(由任何人创建的内容),
  3. 记录应保留在谁编辑的内容和时间,
  4. 应该可以轻松地在编辑之间来回转换,
  5. 为网页添加评论,
  6. 应该能够为创建/编辑的页面分配权限(即谁可以查看它们)
  7. 我正在尝试提出一些数据库结构,但需要一些帮助。有人可以帮我为这些要求创建一个好的结构吗?

    编辑:

    这是我到目前为止所做的:

    page table -
    page_id
    title
    content
    date
    inactive (0,1)
    author
    
    rights table -
    page_id
    user_id
    view (0,1)
    edit (0,1)
    delete (0,1)
    
    history table -
    page_id
    title
    content
    date
    inactive (0,1)
    author
    

    如何改进?

2 个答案:

答案 0 :(得分:1)

我认为你所拥有的大部分都很好。我只是在设计中显示添加或更改,快速但粗略估计:

user
----
user_id
network_username ("Or Active Directory Name or whatever, you get the idea.
    Using user_id as a foreign key in other tables instead of the network
    name makes it easier if account names change.")

role
----
role_id
name

user_role
---------
user_role_id
role_id
user_id

page
----
page_id
author_user_id

page_comment
------------
page_comment_id
parent_page_comment_id ("Self reference to allow for nested comments")
page_id ("Even though you could conceivably look up page_id via
    parent_page_comment_id if you're dealing with a nested comment, that
    would involve N nested queries... so it's probably good to require this
    field be populated for every single record")
user_id


permission
----------
permission_id
page_id
role_id ("To simplify, I'd stick solely to role-based access.")

history
-------
history_id ("If you have high-volume edits, you may need to use date AND this
    to establish the order changes were made in.  Probably safest to use both
    right from the start.")
page_id
user_id ("caveat:  you won't know what role the user was in when a change was
    made.")
old_title ("I'd prefix "old_" to all the fields just to make it intuitively
    clear.")

答案 1 :(得分:0)