W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > April to June 1999

Re: primary key elements, searchable elements, and element relationships proposal

From: <petsa@us.ibm.com>
Date: Thu, 13 May 1999 09:17:40 -0400
To: "Brian H. Dunford-Shore" <brian@gpc.ibc.wustl.edu>
cc: "'Www-Xml-Schema-Comments@W3.Org'" <Www-Xml-Schema-Comments@w3.org>
Message-ID: <85256770.0049039E.00@D51MTA03.pok.ibm.com>
Brian:
Thanks for your comments.  Keys and uniqueness have been on our minds.
The reason you don't see anything about them in the draft is that we've not
decided what to do about them.  Below is my current thinking on the subject.
This does not mean that the WG will agree and this will find its way into the
spec but its gives us a position to discuss and debate.

1) Single property keys
Allow a facet to be added to where a datatype is specified for a property
to declare whether the value has to be unique and the scope
of the uniqueness.  The scope may be the containing element or an ancestor.
For example, the name of a child must be unique within its family
but the license plate of a car must be unique within a state.

2) Define a new datatype called REFERENCE which takes its value
from the domain of values of one or more unique properties.  A facet
defines which unique properties.

3) Multi-part keys are more problematic.  Clearly, they are a property of
the parent element and must be declared there as your example shows.
The syntax you propose seems reasonable but you also need to define
foreign key relationships.

4) My instinct is not to specify anything having to do with search.  This is
because the best search strategy depends on how the document is stored
and not some intrinsic property of the document.


Regards, Ashok


                                                                   
 (Embedded                                                         
 image moved to "Brian H. Dunford-Shore" <brian@gpc.ibc.wustl.edu> 
 file:          05/12/99 05:12 PM                                  
 pic17867.pcx)                                                     
                                                                   




To:   "'www-xml-schema-comments@w3.org'" <www-xml-schema-comments@w3.org>
cc:    (bcc: Ashok Malhotra/Watson/IBM)
Subject:  primary key elements, searchable elements, and element relationsh
      ips proposal




Here are some suggestions for additions to the XML Schema Part 1: Structures
working draft.  They deal with primary key elements, searchable elements,
and element relationships (primary/foreign key relationships ala relational
databases).

It would be very desirable if it could be indicated in an XML Schema
which elements within an element comprise a unique identifier for the
element (a unique or primary key).

Also perhaps desirable would be to be able to indicate which elements
comprise a good set for searching.  An attribute for this might
indicate what type of search this is good for (unique hash, keyword,
etc.).

Relationships between elements (primary/foreign key relationships) can
be implemented by assuming that if an elementType definition appears
within the definition of another elementType definition, then it is
the primary key element, otherwise, the new 'primary' attribute of
elementTypeRef records this information.  Primary key relationships
are cumulative, such that a new element added to the primary key makes
the element which contains it the parent element.  (In the example
below, element table1 is the parent of element table2 and element
table2 is the parent of element table3).

Proposed definition changes and an example follow my signature.

Thank you for your work--it is a good start.

Brian H. Dunford-Shore
________________________________________________________________________
|  Brian H. Dunford-Shore              |  Campus Box 8036                |
|  Institute for Biomedical Computing  |  Phone: (314) 362-2944          |
|  Washington University in St. Louis  |  Fax:   (314) 362-0234          |
|  700 South Euclid Avenue             |  Email: brian@ibc.wustl.edu.us  |
|  Saint Louis,  Missouri 63110        |                                 |
======================================================


Definition (change):


[36] compositor ::= sequence key? search? | choice | all key? search?

        key ::= listField listField?

        search ::= searchField searchField?


Here is the XML Schema definition (with changes to elementTypeRef and
compositor):

<!-- elementTypeRef element type -->
  <elementType name="elementTypeRef">
    <archetypeRef name="reference"/>
    <attrGroupRef name="occurrence"/>
    <attrDecl name="primary">
      <datatypeRef name="boolean">
        <default>true</default>
      </datatypeRef>
    </attrDecl>
  </elementType>



  <archetype name="compositor">
    <elementTypeRef name="key" minOccur="0"/>
    <elementTypeRef name="search" minOccur="0"/>
    <choice minOccur="2" maxOccur="*">
      <modelGroupRef name="modelElt"/>
      <elementTypeRef name="elementType"/>
    </choice>
    <attrGroupRef name="occurrence"/>
  </archetype>

  <archetype name="tuple">
    <elementTypeRef name="elementTypeRef" maxOccur="*"/>
  </archetype>

  <elementType name="key">
    <archetypeRef name="tuple"/>
  </elementType>

  <elementType name="search">
    <archetypeRef name="tuple"/>
  </elementType>



Example:

<elementType name="table1">
     <sequence>
          <key name="table1Primary">
               <elementTypeRef name="field1"/>
               <elementTypeRef name="field2"/>
          </key>
          <search type="unique">
               <elementTypeRef name="field1"/>
               <elementTypeRef name="field2"/>
          </search>
          <elementType name="field1">
               <datatypeRef name='dt:numeric'>
                    <precision>8</precision>
                    <scale>2</scale>
               </datatypeRef>
          </elementType>
          <elementTypeRef name="field2" primary="true"/>
     </sequence>
</elementType>

<elementType name="field2">
     <datatypeRef name='dt:dateTime'/>
</elementType>

<elementType name="table2">
     <sequence>
          <key name="table2Primary">
               <elementTypeRef name="field1"/>
               <elementTypeRef name="field2"/>
               <elementTypeRef name="field3"/>
          </key>
          <search type="unique">
               <elementTypeRef name="field1"/>
               <elementTypeRef name="field2"/>
               <elementTypeRef name="field3"/>
          </search>
          <elementTypeRef name="field1"/>
          <elementTypeRef name="field2"/>
          <elementType name="field3">
               <datatypeRef name='dt:string'>
                    <length>10</length>
               </datatypeRef>
          </elementType>
     </sequence>
</elementType>


<elementType name="table3">
     <sequence>
          <key name="table2Primary">
               <elementTypeRef name="field1"/>
               <elementTypeRef name="field2"/>
               <elementTypeRef name="field3"/>
          </key>
          <search type="unique">
               <elementTypeRef name="field1"/>
               <elementTypeRef name="field2"/>
               <elementTypeRef name="field3"/>
          </search>
          <elementTypeRef name="field1"/>
          <elementTypeRef name="field2"/>
          <elementTypeRef name="field3"/>
          <elementTypeRef name="field4">
               <datatypeRef name='dt:string'>
                    <length>10</length>
               </datatypeRef>
          </elementType>
     </sequence>
</elementType>







Received on Thursday, 13 May 1999 09:18:02 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 18:12:46 GMT