NogDog;11056621 wrote:For clarification: when you say "form", can we just substitute the word "document", as in multiple users are editing the same document; or are we talking about a HTML form to which they are inputting data (i.e. editing the form field content, not the form itself)?
The latter; the forms/documents will all the same except for the different values in the form fields.
Derokorian;11056623 wrote:I've done this in the past by keeping a history table. Since we all know I'm good with words, I'll give an example instead. Given a Post table like this:
Table: post
post_id int primary key,
title varchar(255),
body text,
uid int,
created datetime,
updated datetime
I would then create a history table like:
Table: post_history
post_history_id int primary key,
changed datetime,
changed_by int,
change_type enum('create','update','delete'),
post_id int,
title varchar(255),
body text,
uid int,
created datetime,
updated datetime
Then all changes get 2 sql's ran one for the post table, and one for the post_history table. To the history table, we just insert the current version of the object. To see what changed you just look for the differences between the change you're looking at and the most recent change before that (or any particular previous change).
That's kind of what I'd been considering, but the DB design seems complex. Say we have 20 form fields ...
Table: post_history
post_history_id int primary key,
changed datetime,
changed_by int,
change_type enum('create','update','delete'),
post_id int,
title varchar(255),
field1 int,
field2 varchar(128),
field3 tinytext,
field4 enum('foo','bar'),
field5 tinyint,
field6 text,
field7 blog,
field8 int,
field9 int,
field10 int,
field11 int,
field12 int,
field13 int,
field14 int,
field15 int,
field16 int,
field17 int,
field18 int,
field19 int,
field20 int,
uid int,
created datetime,
updated datetime
The other thing will be a dialog/chat transcript about the changes. I don't see that as being terribly difficult; mostly the idea of the diff. Would you still keep a history table even if you have this many variables? (I'll admit, I can't really thing of anything else off the top of my head, either ...)