[nycphp-talk] MySQL versioning system
Adam Maccabee Trachtenberg
adam at trachtenberg.com
Tue Apr 27 13:58:01 EDT 2004
On Tue, 27 Apr 2004, Mark Withington wrote:
> I have a client who would like to store product development information
> within a MySQL table. The table will consist of multiple fields, each
> representing a product attribute (height, weight, color, etc.). The client
> would like to store each iteration (or version) of the product development
> information along with the ability to role back to prior versions if
> necessary.
My first idea would be to create a unique identifier for each product
and store all the product specifications alongside the identifier and
a version number. When you select the specifications for a product,
select the one with the highest version number. Rolling back only
requires you to delete the highest version number from the database.
The easiest version number is either an auto_increment field or maybe
a timestamp of the insert time.
Also, if you were super concerned about select speed, you could make
an additional column that's an enum('current', 'old') and make the
latest version as "current" and the others as "old". Of course, this
requires more convoluted insert / update logic. But this may or may
not be necessary.
-adam
--
adam at trachtenberg.com
author of o'reilly's php cookbook
avoid the holiday rush, buy your copy today!
More information about the talk
mailing list