Foreign Key column mapped to multiple primary keys

前端 未结 3 1516
再見小時候
再見小時候 2020-12-06 23:37

I have a database which has three tables

Messages - PK = MessageId
Drafts - PK = DraftId
History - FK = RelatedItemId

The History table has a sin

3条回答
  •  执念已碎
    2020-12-07 00:04

    In a short description the solution you have used is called:
    Polymorphic Association
    Objective: Reference Multiple Parents
    Resulting anti-pattern: Use dual-purpose foreign key, violating first normal form (atomic issue), loosing referential integrity
    Solution: Simplify the Relationship

    More information about the problem.

    BTW createing a common super-table will help you:

    enter image description here

提交回复
热议问题