|
RE: [xml-dev] database primary keys in XML Schema
|
[
Lists Home |
Date Index |
Thread Index
]
Markus,
Here is the XSD. Notice the KEY element with the min and max occurs. That tells our parser what the key is for this message. Our database staging tables have them marked as keys.
Thanks,
Dave
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by David Porter (Eli Lilly and Company) -->
<xs:schema targetNamespace="http://results.d51.lilly.com/IdssSchemas/BiologicalEntity.xsd" xmlns="http://results.d51.lilly.com/IdssSchemas/BiologicalEntity.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="\\peach\PEACH.GRP\M-R\Olotf_itarea\OLO_Results_in vivo\Validation\06 Design\XML Signatures\MessageTypeGroup.xsd"/>
<xs:element name="BIOLOGICAL_ENTITY">
<xs:complexType>
<xs:complexContent>
<xs:extension base="GENERIC_REFERENCEtype">
<xs:sequence>
<xs:element name="BIOLOGICAL_ENTITY_TYPE">
<xs:complexType>
<xs:sequence>
<xs:group ref="REFERENCEgroup"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="KEY" minOccurs="0" maxOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="BIOLOGICAL_ENTITY">
<xs:complexType>
<xs:choice>
<xs:element name="ID"/>
<xs:element name="NAME"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="SCHEMA_VERSION" use="required">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="1.0"/>
<xs:maxInclusive value="1.0"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attributeGroup ref="MESSAGE_DESCRIPTORattrgroup"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:schema>
| Markus Seibold <Markus.Seibold@gmx.net>
02/13/2004 08:38 AM
|
To: David J Porter <PORTER_DAVID_J@LILLY.COM>
cc: michael.h.kay@ntlworld.com, xml-dev@lists.xml.org
Subject: RE: [xml-dev] database primary keys in XML Schema |
Hi David,
it would be great if you sent an example. I did not completely understand
your solution and therefore I think it might be good to "see it" working ...
Thanks, Markus
> We have implemented business keys (primary keys) within individual XSD
> (schemas) using a non-instantiated element (definition of the key but
> cannot be placed into the XML document)
> -- The element upper and lower bounds are both 0. This allows us to tell
>
> the parser the key of the message so that is can be shredded into database
>
> staging table. The parser is SAX based an is configured with XML. Very
> nice use of technologies.
>
> Our XSDs do not map directly to tables but to key messages that the
> consumer needs. Sometimes they are parts of one table, other times they
> are multiple. Hope this helps. I can send an example to help clarify.
>
>
>
>
>
> Michael Kay <michael.h.kay@ntlworld.com>
> 02/13/2004 07:19 AM
> Please respond to michael.h.kay
>
>
> To: "'Markus Seibold'" <Markus.Seibold@gmx.net>,
> xml-dev@lists.xml.org
> cc:
> Subject: RE: [xml-dev] database primary keys in XML Schema
>
>
> Your XML schema describes constraints on a single document. A single
> document probably corresponds to a "business object" held in your
> database. The XML Schema cannot describe constraints that apply across
> documents. Perhaps this is where your difficulty lies.
>
> Michael Kay
>
> > -----Original Message-----
> > From: Markus Seibold [mailto:Markus.Seibold@gmx.net]
> > Sent: 12 February 2004 19:29
> > To: xml-dev@lists.xml.org
> > Subject: [xml-dev] database primary keys in XML Schema
> >
> >
> > Hello everybody,
> >
> > I am developing a XML Schema which should function as an
> > interface to a relational database. I have problems with how
> > to design the primary keys in XML Schema.
> >
> > 1.) When I insert data via XML instance documents the first
> > time, I cannot specify a primary key in my XML instance
> > document because the database automatically creates an
> > auto-increment key. Correct?
> >
> > 2.) What if I, for example, want to insert a city in a
> > geography database (the database has a Country and a City
> > table; 1:n relationship). When inserting a city, how can I
> > specify to which country the city belongs? I needed to know
> > the database primary key for the country, wouldn't I and add
> > this key as an attribute to the city in my instance document?
> > What other solutions do exist?
> >
> > This issue cost me alot of time so far and I would really
> > appreciate any help!
> >
> > Thanks a lot, Markus
> >
> >
> > -----------------------------------------------------------------
> > The xml-dev list is sponsored by XML.org
> > <http://www.xml.org>, an initiative of OASIS
> <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
>
>
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
>
>
>
>
--
Markus Seibold
------------------------------
Krebsgasse 6
D-93047 Regensburg
Germany
------------------------------
Email: markus.seibold@gmx.net
Phone: +49 (941) 504 1009
Mobile: +49 (171) 212 6869
FAX: +49 (89) 1488 210457
|
|
|
|
|