Storing revisions of a document

Posted by dev.e.loper on Programmers See other posts from Programmers or by dev.e.loper
Published on 2012-12-06T17:20:39Z Indexed on 2012/12/07 5:21 UTC
Read the original article Hit count: 206

This is a follow up question to my original question. I'm thinking of going with generating diffs and storing those diffs in the database 'History' table.

I'm using diff-match-patch library to generate what is called a 'patch'. On every save, I compare previous and new version and generate this patch. The patch could be used to generate a document at specific point in time.

My dilemma is how to store this data. Should I:

a Insert a new database record for every patch?

b. Store these patches in javascript array and store that array in history table. So there is only one db History record for document with an array of all the patches.

Concerns with:

a. Too many db records generated. Will be slow and CPU intensive to query.

b. Only one record. If record is somehow corrupted/deleted. Entire revision history is gone.

I'm looking for suggestions, concerns with either approach.

© Programmers or respective owner

Related posts about database

Related posts about database-design