While I'm on the roll and after posting my first thread just a while ago, I'd thought I'd post another about table structure and holding historical data.
As a rough example of one of the projects I am working on.
The main table will consist of a log of all raised system issues. Say:
issueID (PK)
originallyRaisedBy
dateRaised
timeRaised
Due to the nature of the database users will be able to virtually change everything about the issueID. For instance every issue will have an owner but this owner will change over time, but I need to know what the history of changes will be. Hence I will have another table like this:
dbID (PK)
issueID (FK linked to main Table)
ownerChangeDate
ownerChangeTime
issueOwner
isCurrent (bool)
The history of the issue will probably held in a listbox of sorts, however the main form of the database only needs to know the current issue owner. My thoughts are that when this changes I simply change the isCurrent flag to false and when inserting the new owner make isCurrent true.
I have reservations about this though as setting a flag such a way does not really preserve referential integrity, although it is quite clean. I could of course not use a flag at all and just get the latest issue owner for each issueID from either the data or in fact the dbID, as the highest one for each issueID will be definition be the latest. This should perform better too as I won't need to update any prior records to false and can just do one insert for each change.
I'm open to other ideas though so am keen to hear how other people have dealt with these issues.
As a rough example of one of the projects I am working on.
The main table will consist of a log of all raised system issues. Say:
issueID (PK)
originallyRaisedBy
dateRaised
timeRaised
Due to the nature of the database users will be able to virtually change everything about the issueID. For instance every issue will have an owner but this owner will change over time, but I need to know what the history of changes will be. Hence I will have another table like this:
dbID (PK)
issueID (FK linked to main Table)
ownerChangeDate
ownerChangeTime
issueOwner
isCurrent (bool)
The history of the issue will probably held in a listbox of sorts, however the main form of the database only needs to know the current issue owner. My thoughts are that when this changes I simply change the isCurrent flag to false and when inserting the new owner make isCurrent true.
I have reservations about this though as setting a flag such a way does not really preserve referential integrity, although it is quite clean. I could of course not use a flag at all and just get the latest issue owner for each issueID from either the data or in fact the dbID, as the highest one for each issueID will be definition be the latest. This should perform better too as I won't need to update any prior records to false and can just do one insert for each change.
I'm open to other ideas though so am keen to hear how other people have dealt with these issues.