I wish to store your blog publish inside a database. I figured it might be nice to possess different versions of this data, similar to version controlling does for text files.

So, I imagine it working just like a row inside a table, which had version control. So, for instance, you can retrieve the most recent version of this row, or perhaps a previous version. You can even branch from that row.

Does anything such as this exist?

Possibly helpful info: I'm presently using Python, Django &lifier MySQL. I am experimentation with MongoDB

Edit for clearness/more context: I am searching for an answer more customized towards "version control" of rows than of databases I am less thinking about branching entire databases. For instance, I'd have the ability to query this content of blog publish at 1/1/2011 and also at 1/1/2010 (without switching databases).

Version control is really a complicated subject doing the work right is actually challenging that is basically why even using e.g. git can be hard. I would not wish to write a complete blown version control system.

For simpler needs, think about this structure, in pseudo-mongodb/JSON:

BlogPost {
    "_id": ObjectId("..."),
    "slug" : "how-to-version-my-posts",
    "author" : "cammil",
    "published" : date,
    "lastModified" : date,
    "publicVersion" : 32,
    "draftVersion" : 34,
    "teaserText" : "lorem ipsum dolor sit amet..."

BlogPostBody {
    "_id" : ObjectId("..."),
    "Version" : 32,
    "Text" : "lorem ipsum dolor sit amet..."

Therefore the idea would be to store each version individually along with a pointer to the present public version and also the current version for editors, writers, etc.

My answer is a touch MongoDB centric (because I built a MongoDB based blog engine for use at home), however it should work similarly for just about any storage system.


  • You don't need to do MAX queries from the version number for either public or private posts
  • Doesn't correlate last edited to version amounts, which is probably not desirable
  • Enables versioning even when a particular version has already been released
  • Can fetch the teaser w/o needing to fetch the whole article


  • Copies the whole text each time. Not really a real concern for textual data I suppose (attempt to type 1GB...). Is a problem for bigger blogging sites, however. Minimization: Compress text using deflate, delta-compression.
  • Must update two objects on update

To begin with, I have to admit it is really an interesting question.

During my type of work, I have in order to save versions of numerous user inputs. Generate an income get it done, and go ahead and I do not fully realize whether it's the proper way or otherwise, may be the following:

I've got a master table and revisions table. I selected these 2 names for that example's sake only.

What master does is stores the next info:

  • id (autoincrement)
  • version_id (int)

What revisions store may be the following:

  • id
  • master_id
  • version_id
  • relaxation from the relevant data about joined entity (dates, etc)

Things I accomplished by doing this is the fact that I'd become an ID of, let us say your blog publish. If a person edits the publish, I'll store that info to revisions table. Via triggers I am incrementing the version_id in revisions table. Next I update master table using the latest version_id number. This way I do not have to perform MAX() when I wish to see exactly what the latest version is.

This way I acquired simple, yet effective version system of website's content. It's not hard to see changes, also it's very fast to acquire data should you abuse some MySQL awesome features (during my actual tables, I am mistreating InnoDB's clustered primary answer to the max. therefore the db design is slightly diff. compared to one I published here).

OffScale DataGrove enables you to definitely version you entire DB.

It tracks all the new changes which happen towards the DB and you will tag versions and switch backwards and forwards together. DataGrove is exclusive in the truth that it versions the whole DB - schema and data.

Inside your example - just add the row/data you need to the DB and tag a version. You'll always have the ability to return to that version as well as branch from this.