Elements and attributes: modeling relational data in XML, part 1
XML: You can use either elements or attributes to model relational data in XML, but unless you have some compelling reason not to, it is more efficient to use attributes for the data points. More on xml data management and xml attributes

by Kevin Williams, founder and CEO, Blue Oxide Technologies. Intel Corp.

This article is the first in a series that looks at the steps involved in modeling relational data in XML. We look at the three major components of a relational database—tables, columns, and the key relationships among them—and see how to best model each in XML.

Before discussing how we should model our relational data in XML, we first need to understand one of the classic problems in XML data modeling: whether to use elements or attributes to model our data points.

Data points (individual pieces of information, the equivalent of values in the columns in our relational database) can be expressed either as elements or attributes in an XML model. For example, an abbreviated customer table might be modeled either this way:

Or this way:


<customer>


       <name>Fred Q.

    Anybody</name>


       <address>123 Somewhere

    Street</address>


       <city>Randomtown</city>


       <state>WV</state>


       <zip>25423</zip>


    </customer>

While these two approaches appear interchangeable at first, a closer examination reveals that one is superior to the other for modeling relational information.

Comparing elements, attributes, and the relational model
In the relational model, a set of related information is stored in a table; individual pieces of information are stored as values in columns in the table. In XML, tables are modeled as elements that provide the only way to associate pieces of information together into a related group.

Order significance
In XML, the order in which elements appear is significant. Because the XML data model preserves the order found in the original document, the following document:


    <customer


       name="Fred Q. Anybody"


       address="123 Somewhere Street"


       city="Randomtown"


       state="WV"


       zip="25423" />

Subscribers who liked this article also read:

<customer>


       <name>Fred Q.

    Anybody</name>


       <address>123 Somewhere

    Street</address>


       <city>Randomtown</city>


       <state>WV</state>


       <zip>25423</zip>


    </customer>
Advanced packages drive on-board programming innovations
by Peter T. Larsen. Intel Corp. Vendors such as Intel recognize tha...

If you're interested in this topic, these articles may be helpful:

XMLSpy Home Edition 2005
from Altova Altova XMLSpy 2005 Home Edition is a free entry level X...
Custom ASP.NET DataGrid paging with Exact Count
by Dimitrios Markatos, independent .NET architect. Anybody in the D...
Semantic interoperability with universal data element framework
by Neelima Vobugari, XML certified independent software consultant. ...
Schema Plus Professional trial download
from SchemaPlus Schema Plus is an array of robust database management...
Determine the correct XML parser type for a Java application
by Padma Apparao, senior performance architect, Software Solutions Gro...

Related Jobs:

Data Migration Specialist #TEC00001143 - PA - Horsham - The Thomson Corporation
Data Migration Specialist TEC00001143 Job Description ...
Technical Yahoo #RX1000023474 - CA - Sunnyvale - Yahoo! Inc.
Technical Yahoo Job No. RX1000023474 Location US - Sunnyvale ...
Web Developer/Front End #RX1000022062 - CA - Sunnyvale - Yahoo! Inc.
Web Developer/Front End, Structured Web Search Job No. RX10000...
Web Facilitator #1544 - OH - Akron - RCG Information Technology
Description-Web Facilitator will assist with general website mainten...
Software Development Principal #002VF - TX - Dallas - Sabre Inc.
Software Development Principal 002VF Job Description ...
Microsoft Developer - Senior Consultant #1376 - MN - Richfield - Sogeti USA LLC
Microsoft Developer - Senior Consultant Req. ID: 1376 # Positions:...
Senior Web Applications Engineer #C8469CF29B4A750B - CA - Oakland - Ask Jeeves,Inc.
Title Senior Web Applications Engineer City Oakland State CA Zip...
Software Developer #BK-DEV - PA - Philadelphia - SunGard
Reference No.: BK-DEV Opening Date: July 17, 2007 Job Title: Softw...
Sr. C# .Net OO Developer #3741826 - TX - Houstan - Ajilon
Description : If you're a professional looking for exciting, new oppo...
Oracle Business System Analyst #2528 - OH - Cleveland - WOW Global Corporation LLC
Required Skills: Enterprise Applications, Business Systems Analyst (...