My question is related to Database Design for Revisions? but more complicated.
I have two tables with many-to-many relations between them. Let's call them A and B.
A: A.id, A.data, A.last_change_time
B: B.id, B.data
A_B: A_B.A_id, A_B.B_id, A_B.connected_since_time, A_B.some_status_enum
The A_B connector table must support revisions. If connection between element in A to element in B is removed historical information that it existed before must be kept. If connection status changes historic info on old status must be kept.
Some of the reports that I need to generate are:
- List of all elements in A that are not connected to B at all (now).
- List of all elements in A that are connected to at at least one element in B with certain status.
- List of all A-B pairs that were once connected but no longer connected.
- List of all A-B connections where A's last change time is after the connection time.
- Count of all A-B connections where A's last change time is after the connection time grouped by status.
I considered simply adding A_B.is_current boolean field to the connecting table. When connection is deleted I simply set is_current to false. When status changes I set is_current to false for old records and add a new record with new status.
Answers to similar previously asked questions often claim that "is_current" is bad design and there should be a better solution. Previous solutions talked about revision of record in single table and not relations between them.
Is it wrong to use is_current column to track the history of many-to-many connections? If it is wrong what problems it may cause? What is the better solution?