背景:
同时设计的两个项目(A&B)都需要一个新表(称为DocumentStore
) 在 postgres 下存储文档/文件。
但是项目 A 和 B 之间围绕文档存储的业务逻辑是不同的,这意味着围绕文档存储的关系DocumentStore
A 和 B 之间不同。
让我们更具体一点,请参阅下面的示例:
文档存储表结构看起来相同,没有约束/外键:
Table DocumentStore
DocUUID //unique Id for this document, PK, FK to other table depends on project
fileName //file name
fileType //file type
FileContent //store file as blog
项目中A, DocumentStore.DocUUID
参考Email.EmailUUID
:
请注意,通过 FK,电子邮件 -> DocumentStore 之间存在一对多关系。
Table Email
EmailUUID //PK
subject
title
...
项目中B, DocumentStore.DocUUID
参考Letter.LetterUUID
:
请注意,Letter -> DocumentStore 之间通过 FK 存在一对多关系。
Table Letter
LetterUUID //PK
UserId
rightId
...
Email
and Letter
由于业务逻辑的不同,两者完全不同。
我的问题是:
我应该分享这个吗DocumentStore
项目 A 和 B 之间的表 ?
如果1.的答案是肯定的,那么如何呢?通过postgres下的继承?
如果1.的答案是否定的,我是否应该创建两个具有相同结构但不同表名和不同外键的表?项目 A 和项目 B 各一份?