This is for a project. I am making up a database for different kinds of records for an office. There is a table collecting all the primary keys of those record tables. So, I need to have a foreign key referencing those tables. And I am lost. I asked my very loyal friend google but I didn't understand some of the possible answers for this.
Here's what I have come up (the names of the tables are not their real names, just want it to be generic here).
Edit: I am using Postgres
RecordsTable:
recordId -> references record1 id,record2 id,record2 id
docId -> identifies what kind of record it is
filingDate
Record1:
id
attribute2
attribute3
Record2:
id
attribute2
attribute3
Record3:
attribute2
attribute3
Actually,Record1, Record2, and Record3 have more than 30 columns each (imagine a birth certificate e.g.)
RecordsTable will be the one shown to the users. record1-3 will only be shown if the user needs to edit something.
I thought, I would make record 1-3 reference recordstable but it will be troublesome to the user as he/she will need to input first in the recordstable and that's not what recordstable is for. It's just to show the summary of all the records filed in the office since it will be not good to show all of those at once.
If there's anything unclear, please let me know so that I can explain it more. Thanks in advance
RecordsTableneed to exist at all. Wouldn't a view performing aUNION ALLbetween the individual record tables (and any common columns) serve the purpose better?TableName, then the combination ofTableNameandIdshould be unique with no further effort.