Hi all. I have a database design conundrum for you....
The Scenario
A table, called SystemDocuments_History, has a m:1 relationship with SomeSystemDocuments, and also SomeOtherSystemDocuments. To distinguide which table the history is held for, there is a "Key" column in History, which could be "S" for one document type, and "O" for the other one.
So, if you wanted all the history items for SomeSystemDocuments with ID of 2, you'd have to filter SystemDocuments_History for Document_ID = 2 and Key = 'S'.
Is this good, or should there be 2 history tables - and if so why?
With this design above, the advantages are that fewer tables is easier from a scripting side, but the relationship is not a "true" relationship in that the foreign key constaint can not be enabled. Theres also arguably less code - the code is more "abstract" and re-use might be better.
The alternative is one history table per document table.
The way I see it, the advantages to that is that the relationship can be defined and enabled, and its easier to retrieve the data from the database (very straightforward).
Is one of these approaches frowned upon, which is better, from a practical viewpoint?
I'd be keen to know anyones thoughts....