[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Doubt

  • To: 'Mudita Singhal' <msinghal3@r...>, xml-dev@l...
  • Subject: RE: Doubt
  • From: "CHIUSANO, Joseph" <JCHIUSANO@l...>
  • Date: Wed, 31 Jul 2002 16:49:52 -0400
  • Return-receipt-to: "CHIUSANO, Joseph" <JCHIUSANO@l...>

mudita singhal
Title: RE: Doubt

Mudita,

You can use the ID/IDREF technique in the DTD - i.e. an attribute of type "ID" would represent the primary key value, and an attribute of type "IDEF" would represent the foreign key value.  The one-to-many relationship would therefore be ID-to-IDREF.  Please note that there are some disadvantages to this approach:

(1) An ID-type attribute value cannot begin with a number;
(2) An ID-type attribute value can appear only once within an XML document (however, IDREF-type attribute values can appear multiple times);

(3) An XML processor will not validate the associations between ID and IDREF values.  That is, if A.1 contains the value "A123" and there is a B.2 (IDREF) value of "A123", that is great.  However, if there is a value of "A123" for another IDREF-type attribute (perhaps C.2 instead of B.2), an XML processor will be happy with this even though the association is incorrect.

To avoid these issues, you can use XML Schema and the KEY/KEYREF mechanism.  In addition to avoiding (1) and (2) above, you can explicitly declare associations between elements or attributes - so you can ensure that (for instance) when there is a value of "A123" for an A.1 attribute, there must be a matching value of "A123" for a B.2 attribute (not just any attribute in the XML document).

Hope that helps,
Joe Chiusano
LMI

> **************************************************************************
>   Joseph M. Chiusano
>   Logistics Management Institute
>   2000 Corporate Ridge
>   McLean, VA 22102
>   Email: jchiusano@l...
>   Tel: 571.633.7722
> **************************************************************************
>


-----Original Message-----
From: Mudita Singhal [mailto:msinghal3@r...]
Sent: Wednesday, July 31, 2002 4:12 PM
To: xml-dev@l...
Subject: Doubt


Hello all,

I am new to this group and so might be asking a question which
might ahve already been answered, or is very simple.Sorry for
that.

If we have to make a DTD for a database with 2 tables, say A and
B.The attributes of the tables are as under:


Table A
A.1(PRIMARY KEY)
A.2
A.3(FORIEGN KEY TO TABLE B)

Table B
B.1(PRIMARY KEY)
B.2(foriegn key to table A)

Now can anyone guide me on how to write a simple DTD for
this.Means , do we have to declare a content type declaration for
the forign keys also??IF not then how do we write the XML document
for this?

secondly How to impose the many-to-many and one-to-many
relationships?

Thanks
Mudita


-----------------------------------------------------------------
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>


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.