【发布时间】:2018-04-07 11:08:12
【问题描述】:
我有一些名称为联系人、关注、任务、工单、帐户和...的表格 上面的每一个表,都应该和 Notifications 表有关系。
现在我在 SQL 中为 Notifications 表使用这种结构来创建它们之间的关系:
Id, ContactId, FollowId, TaskId, TicketId, AccountId, Text
Id 是主键,ContactId、FollowId、TaskId、TicketId、AccountId 应该是外键。
每次向该表中添加一条记录时,该外键列表中只有一列获得了值,如下所示:
Id ContactId FollowId TaskId TicketId AccountId Text
1 null null null null 2 notification test 1
2 null null null 12 null notification test 2
3 null null null 11 null notification test 3
4 5 null null null null notification test 4
5 null 1 null null null notification test 5
6 null null null null 3 notification test 6
7 null null null null 43 notification test 7
这是一个不拒绝databBase规范化的优秀架构师吗?
【问题讨论】:
-
您的 fkeys 似乎指向错误的方向..?
-
为什么不在每个表中添加notificationID 外键呢?从那里您可以监控每个表及其通知。
标签: sql sql-server database database-design