Imagine I’m creating a very simple bug tracking system. I have a list of bugs, which in the database currently looks something like this:
ID Title Details CreatedDate
1 someTitle someDetails 26/09/2012
2 otherTitle otherDetails 27/09/2012
I’m looking to add versioning to this table, so that the history of each individual bug is stored. I was thinking of something like this:
ID BugID CreatedDate
1 1 26/09/2012
2 3 26/09/2012
BugID Title Details RevisionGroup
1 someTitle someDetails 1
2 otherTitle otherDetails 2
3 otherTitle changedDetails 2
Here I have the list of bugs in the first table, which links to the most current version of the bug in the second table. The revisionGroup column isn’t linked to anything, I’d just be taking the maximum value currently there and incrementing when needing to insert a new bug.
My database design is pretty shakey, but I’ve thought about this and believe it should work. Does this look like the best way to go about things? Is there a better way?
Nice question format 🙂
Well, since you just want the latest bug, why not put a timestamp instead of a version.
What it will do is save you one extra query that you would do when you enter a new bug and look for the last version. Unless your business rules states the requirement of the version number. I believe you said that is not the case then I dont see any other problem with your current design.
When designing a database, always remember… Calculation with a processor is much faster than any disk I/O. You should avoid any extra read/write if possible and avoidable.
Good luck!