Background:
Two projects (A & B) under design at the same time both needs a new table(called DocumentStore
) to store document/file under postgres.
But business logic around the document storage are different between project A & B, this means relationship around DocumentStore
are different between A & B.
Let's make this a bit more concrete, see example below:
The Document storage table structure looks the same without constraints/ foreign Keys:
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
In project A, DocumentStore.DocUUID
references Email.EmailUUID
:
Note there is a one to many relationship between Email -> DocumentStore via the FK.
Table Email
EmailUUID //PK
subject
title
...
In project B, DocumentStore.DocUUID
references Letter.LetterUUID
:
Note there is a one to many relationship between Letter -> DocumentStore via the FK.
Table Letter
LetterUUID //PK
UserId
rightId
...
Email
and Letter
are completely different because of different of business logic.
My questions are:
Should I share this
DocumentStore
table between project A & B ?If the answer to 1. is yes, then how? Through inheritance under postgres?
If the answer to 1. is no, should I create two table with the same structure but different table name and different foreign key ? One for project A and project B?