Sorry to be so long answering. Design questions always make me think...
This is a good idea. There are actually two variations:
1) As Emmanuel suggests, we can assign a timestamp based on the
document. XML-DBMS would return this to the application as separate
metadata when the application retrieves the document. The application
would return this to XML-DBMS when updating the document. To identify
individual documents, it would probably be sufficient for the
application to pass in the (pre-update) key value(s) and root table(s)
(a DocInfo object?). Note that the pre-update values would have to be
used since these could have changed -- the obvious case is a document
with an ignored root in which elements at the next level down are added
2) We can use timestamp/value columns in the database. These would be
identified in the map and would form the basis for optimistic locking
comparisons. For example:
<!ELEMENT ToClassTable (Table, (TimestampColumn | ValueColumn+)?)>
<!ELEMENT TimestampColumn EMPTY>
Name CDATA #REQUIRED
Generate "Yes | No" #REQUIRED>
<!ELEMENT ValueColumn EMPTY>
Name CDATA #REQUIRED>
Note that the timestamp/value column(s) would need to be mapped
separately to the XML document. That is, they would be included in the
XML document as data, not metadata.
The first option is relatively simple, but has the disadvantage that it
only works if the data is not updated through another document or
through a separate (non-XML-DBMS) application. The second option
provides a more complete solution, but has the disadvantage that
timestamp information is included in the document, which may be
confusing to some users.
Emmanuel Clarke wrote:
> --- In firstname.lastname@example.org, Ronald Bourret <rpbourret@r...> wrote:
> > 3.3) Optimistic Locking
> > -----------------------
> > A problem with optimistic locking just occurred to me. This that
> > XML-DBMS does not keep an original copy of a document. Therefore,
> > it receives a document for update, it has nothing to compare against
> > what is in the database to determine if somebody else has changed
> > document in the mean time. That is, if a user makes a change, XML-
> > won't be able to tell if the difference between the document and the
> > database is due to the user's change or to somebody else changing
> > database.
> > The only workaround I can think of is a retrieveForUpdate method,
> > XML-DBMS keeps a copy of the document. The obvious problem with
> this is
> > that people could check out large numbers of documents and easily
> > overwhelm memory.
> > Suggestions welcome.
> How about adding metadata for each document (or element?) which would
> contain a timestamp indicating the last modification date/time.
> You would somehow have to uniquely identify the document/element in
> order to retrieve its metadata, but this is something that needs to
> be done anyway.
> There are obvious disadvantages when you get into fine grained
> updating of elements within a document that may be shared with other
> documents, but it may be a viable approach when you only want to deal
> with a single document.
Programming, Writing, and Training
XML, Databases, and Schemas