Loading ...
Sorry, an error occurred while loading the content.

650RE: [xml-dbms] UPDATE & DELETE

Expand Messages
  • Dimitrios Alexandrou
    Feb 8, 2001
    • 0 Attachment
      Ronald thank you very much for your help.

      -----Original Message-----
      From: Ronald Bourret [mailto:rpbourret@...]
      Sent: Wednesday, February 07, 2001 10:41 PM
      To: xml-dbms@yahoogroups.com
      Subject: Re: [xml-dbms] UPDATE & DELETE

      Sorry to take so long replying.

      Before you write any code, I strongly suggest that you write a short
      specification of how update and delete will function and post it to the
      list for feedback. That will probably save a lot of time later.

      My current suggestions for DELETE are as follows. If people think this
      is a good solution (FEEDBACK PLEASE!), you might want to write this
      while we think about how to do UPDATE, which is much harder.

      I'll try to send ideas about update by Friday.

      -- Ron

      This can be implemented similarly to DBMSToDOM. That is, the basic idea
      is that the code traverses the database hierarchy and, instead of
      building a DOM document, deletes rows.

      The only tricky part of this is that rows must be deleted in the order
      required by referential integrity. That is, all foreign key rows must be
      deleted before any primary key rows. The algorithm for this is roughly
      as follows:

      1) Get the TableMap for a given table.

      2) Check all relatedTables. If parentKeyIsCandidate is true for a given
      table, then process the relatedTable immediately. (That is, recursively
      start with step 1 for the relatedTable.) This will delete all rows in
      child tables for which the current table has the primary key and the
      child rows have the foreign key.

      3) Delete the row in the current table.

      4) Check all relatedTables again. This time, if parentKeyIsCandidate is
      false, process the relatedTable. (That is, recursively start with step 1
      for the relatedTable.) This will delete all rows in child tables for
      which the current table has the foreign key and the child rows have the
      primary key.

      Here is a proposed API. Comments welcome. Note that the Map object is
      now passed as an argument to each method, rather than being set ahead of
      time. This is a change I am considering making on DBMSToDOM and
      DOMToDBMS as well, as it simplifies the interface and makes clearer what
      is happening.

      public class DBMSDelete

      /** Construct a new DBMSToDOM object. */
      public DBMSDelete()

      // Public methods

      /** Delete documents from specified tables. */
      public Document deleteDocument(Map map, String[] tableNames,
      Object[][] keys)
      throws InvalidMapException, SQLException

      /** Delete a document from a specified table. */
      public Document deleteDocument(Map map, String tableName, Object[]
      throws InvalidMapException, SQLException

      /** Delete a document according to the information in a DocumentInfo
      object. */
      public Document deleteDocument(Map map, DocumentInfo docInfo)
      throws InvalidMapException, SQLException

      As a starting point, you can use the DBMSDelete class from
      www.schemantix.com. (They gave me permission to modify/use/reship it.)
      This is code they wrote for use with XML-DBMS that implements the
      algorithm above, except that the version I saw did not handle
      referential integrity -- it simply deleted rows in hierarchical order.
      (If you can't find this on their site, tell me and I will send you a
      copy. I don't know if they still use XML-DBMS.)

      To post a message, send it to: xml-dbms@yahoogroups.com
      To unsubscribe, send a blank message to:
      Or join the newsgroup at: news://news.barkto.com/homeless.xml.xml-dbms
    • Show all 11 messages in this topic