I work on an enterprise system that utilizes effective dated joins. I am trying to figure out how to document the joins between the tables to assist me with my queries. As far as I can tell this information does not exist in the index or constraint information on the tables. Which database document or tool would be best suited for recording this information?
An example of a join would be:
Table_A
Key_ID - Primary Key
Employee_ID
Position_ID
Effective_DT
Unique Key -> Employee_ID, Position_ID, Effective_DT
Table_B
Employee_ID
Position_ID
Effective_DT
Table_A_Key_ID
Unique Key -> Employee_ID, Position_ID, Effective_DT
Table_A_Key_ID is a foreign key from Table_A and cannot be null. In other words, every record in Table_B requires a corresponding record in Table_A but the reverse is not true. To determine the record in Table_B that relates to a record in Table_A that does not have a corresponding record you need to grab the highest effective dated record less than Table_A.Effective_DT.
An ER modelling tool will document referential integrity, but will not by itself help you document all the JOINs that you do in your client code (that might not all “lie” on top of FKs).
Either always do the JOINing through views (which ER tool should help you document), or you’d need to have a separate documentation just for JOINs. This can be a separate document or embedded in the source-level documentation (near the code that actually initiates the JOINs). Prefer the second option since people maintaining the code will be more likely to update the documentation as they update the code and make changes to JOINs.