Search code examples
phpmysqldatabaserevision

Revision content in php


I'm trying to implement a revision system for a site I'm building and am working on it's design...

How does a revision system (for content) like Stackoverflow work? Does it store a diff from version to version or does it store the full text in each db entry?

I'm guessing the columns are something like: date, revision_num, content, author. Am I missing anything?


Solution

  • For content revisions, storing the full text of each revision is the way to go. If you used diffs, you might save some space, but having to process the data would more than make up for the saved space. For columns, you'll probably want a post ID, a revision number, a timestamp, the author ID, and the content. You can add other fields if needed, but those are the basics. Any revisions of an older post would share the same post ID.