Storing revisions of a document
- by dev.e.loper
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.