[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: database primary keys in XML Schema
My XML Schema contains country, state and city elements (which correspond to the Country, State, and City tables in the DB). When I want to insert a country, a state, and some cities altogether for the first time using a XML document, the keys are not the problem because the parser will shred the XML elements into the corresponding tables and the RDBMS will automatically create the keys. But what if I want to add some cities at a later point? My idea was to design my schema in a way that it allows the city element to be declared as document root. Doing so, I can insert only cities (using the same XML Schema as for inserting all three parts together). But how can I tell the parser/RDBMS which country/state the cities to be inserted belong to? One idea I had was to add a attribute to the city element in order to specifiy the RDBMS primary key for country. But the XML document creater must know the RDBMS key in advance then ... Thanks, Markus > 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@g...] > > Sent: 12 February 2004 19:29 > > To: xml-dev@l... > > Subject: 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@g... Phone: +49 (941) 504 1009 Mobile: +49 (171) 212 6869 FAX: +49 (89) 1488 210457
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|