0

对于两个用户之间的简单请求/操作过程,我有以下列:

request_type
request_to
request_by
request_msg
request_time

action_type
action_by
action_msg
action_time

来自何时我们需要在数据库设计中使用 1-to-1 关系?表明我的示例不符合此处接受的任何分区原因。但是,我仍然想知道这两组列是否应该属于同一个表,因为:

  • 该过程本质上是两个行插入,但后者必须使用更新来应用,因为表包含两组列
  • 每个集合都无法更新,因此两个表将有助于拒绝更新权限
  • 操作未决时,表的一半是空字段
  • 虽然直接相关,但它们仍然感觉像是两个语义不同的用户操作

感谢您的任何想法。

4

1 回答 1

0

您可以有两张表,一张用于请求,一张用于操作。

request
=======
request_id (primary key identity(1,1))
request_type (fk to type table)
request_to (fk to user table)
request_by (fk to user table)
request_msg 
request_time (default getdate())

action
======
action_id (primary key identity(1,1))
request_id (fk to request table)
action_type (fk to type table)
action_by (fk to user table)
action_msg 
action_time (default getdate())
于 2012-06-23T13:06:49.443 回答