Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: Document Table Record Versioning

Started 1 month, 1 week ago by joehansen
Hey All, We have a table named "document" with following fields: documentnum, documenttypenum, description, filename, uploadedon, createdby We would like to add versioning capability to the document records. New functionality would involve a) creating a new document b) replacing a document with a newer version c) deleting the latest version and making the older version current d) ...
Site: dBforums - Database Support Community  dBforums - Database Support Community - site profile
Forum: Database Concepts & Design  Database Concepts & Design - forum profile
Total authors: 6 authors
Total thread posts: 10 posts
Thread activity: no new posts during last week
Domain info for: dbforums.com

Other posts in this thread:

mike_bike_kite replied 1 month, 1 week ago
Quote: Originally Posted by joehansen What would be the best way to structure the database table(s) so that the queries for the above operations would not just be simple but also run fast? Couldn't you just have a timestamp in the record and then the current document is the one with the latest timestamp. If you ...

joehansen replied 1 month, 1 week ago
Thanks for the reply, Mike! I am torn between having one single document table with a timestamp field or having two tables, document table along with the documentarchive table. Wouldn't you think the SQL SELECT queries would be simpler and would perform better if I had two tables? Thank you, Joe

Pyrophorus replied 1 month, 1 week ago
Hi… IMO, using two tables gives no benefit. You shall have to move records back and forth from one table to the other one. Of course, any simple query on "DocumentTable" will run faster than Mike's query, because the subselect on each row. But if your query grabs only a few rows, you'll never see the difference. In your place, I would use Mike's design. If your queries aren't fast enough then...

MarkATrombley replied 1 month, 1 week ago
Wikipedia has a decent article on temporal database design. Usually you would add a ValidStart and ValidEnd datetime columns to reflect when the row was current. The current record has a ValidEnd datetime of some specific date in the distant future so it is easy to find. If you are going to have a huge number of document revisions (more than 20 per document) then I would go with an archive ...

blindman replied 1 month, 1 week ago
Normally I would recommend an archive table, but in your case records are not being "permanently archived", and can be change back to an active state. So, the single table may be your best option. Note though, that a single table with start and stop columns will not enable you to determine the history of when a document was in use (if it had multiple start and stop times), while an archive ...

Brett Kaiser replied 1 month, 1 week ago
OK, I would have a Document table, With Effective and Termination Dates (null), with a version Number for the document that is incremented by 1 any time the document was modified (via a trigger) I would also move all data images to a history table (via a trigger) when anything on the row was modified MOO

joehansen replied 1 month, 1 week ago
Thank you, Brett Kaiser, blindman, MarkATrombley and Laurent for your kind replies. You all have been consistent in saying that a single table would serve my purpose best. So here's the key document table columns that I am looking at right now: documentkey (unique) documentnum activefrom activeuntil version (optional) latest (default true; optional) Thanks for all your help ...

mike_bike_kite replied 1 month, 1 week ago
Quote: So here's the key document table columns that I am looking at right now: documentkey (unique) documentnum activefrom activeuntil version (optional) latest (default true; optional) Few questions : Surely the latest field is unnecessary as you'd just look for either look for records where the current date is between the from ...

Pyrophorus replied 1 month, 1 week ago
Something is yet unclear to me in the desired behavior: what you want is: -- a stack, i.e. returning to version n-2 will throw away n and n-1. -- an history, i.e. returning to version n-2 deletes nothing but "duplicates" n-2 to n+1 Mike's design (and my contribution) apply to a stack. Mark's is more about an history. And your final design seems to me a mix of the two ! If an history is ...

 

Top contributing authors

Name
Posts
joehansen
3
user's latest post:
Document Table Record Versioning
Published (2009-11-13 18:49:00)
Thank you, Brett Kaiser, blindman, MarkATrombley and Laurent for your kind replies. You all have been consistent in saying that a single table would serve my purpose best. So here's the key document table columns that I am looking at right now: documentkey (unique) documentnum activefrom activeuntil version (optional) latest (default true; optional) Thanks for all your help guys, Joe
mike_bike_kite
2
user's latest post:
Document Table Record Versioning
Published (2009-11-14 06:11:00)
Quote: So here's the key document table columns that I am looking at right now: documentkey (unique) documentnum activefrom activeuntil version (optional) latest (default true; optional) Few questions : Surely the latest field is unnecessary as you'd just look for either look for records where the current date is between the from and until dates. If the field defaults to true does this mean you might have more than one record with...
Pyrophorus
2
user's latest post:
Document Table Record Versioning
Published (2009-11-14 13:31:00)
Something is yet unclear to me in the desired behavior: what you want is: -- a stack, i.e. returning to version n-2 will throw away n and n-1. -- an history, i.e. returning to version n-2 deletes nothing but "duplicates" n-2 to n+1 Mike's design (and my contribution) apply to a stack. Mark's is more about an history. And your final design seems to me a mix of the two ! If an history is wanted, I would use two...
MarkATrombley
1
user's latest post:
Document Table Record Versioning
Published (2009-11-13 12:06:00)
Wikipedia has a decent article on temporal database design. Usually you would add a ValidStart and ValidEnd datetime columns to reflect when the row was current. The current record has a ValidEnd datetime of some specific date in the distant future so it is easy to find. If you are going to have a huge number of document revisions (more than 20 per document) then I would go with an archive table, otherwise keeping it in one table is best.
blindman
1
user's latest post:
Document Table Record Versioning
Published (2009-11-13 12:26:00)
Normally I would recommend an archive table, but in your case records are not being "permanently archived", and can be change back to an active state. So, the single table may be your best option. Note though, that a single table with start and stop columns will not enable you to determine the history of when a document was in use (if it had multiple start and stop times), while an archive table would.
Brett Kaiser
1
user's latest post:
Document Table Record Versioning
Published (2009-11-13 13:21:00)
OK, I would have a Document table, With Effective and Termination Dates (null), with a version Number for the document that is incremented by 1 any time the document was modified (via a trigger) I would also move all data images to a history table (via a trigger) when anything on the row was modified MOO

Related threads on "dBforums - Database Support Community":

Related threads on other sites:

Thread profile page for "Document Table Record Versioning" on http://www.dbforums.com. This report page is a snippet summary view from a single thread "Document Table Record Versioning", located on the Message Board at http://www.dbforums.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity