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

Re: XML representation of a Table

  • From: petsa@u...
  • To: xml-dev@i...
  • Date: Wed, 21 Oct 1998 12:03:34 -0400

xml representation of sql
Two points re. translating from relational tables to XML and back.
1. The example seems reasonable but the fun really starts when you want to
    represent 2 or more joined tables as an XML document.  In general,
    you want to map a SQL view into a XML document and if you have more
   than 1 table in the view its not always clear how to structure the
hierarchy.
2. Omitting a value is *not* the right way to represent a NULL value.
   SQL distinguishes between these 2 cases.  A string column can have an
   empty string as a value or its value can be NULL.  In DCD we recommend
   that you use a special attribute to represent that the value is NULL.

Ashok Malhotra


                                                                   
 (Embedded                                                         
 image moved to "Michael Kay" <M.H.Kay@e...>              
 file:          10/21/98 11:28 AM                                  
 pic25949.pcx)                                                     
                                                                   



Please respond to "Michael Kay" <M.H.Kay@e...>


To:   xml-dev@i...
cc:    (bcc: Ashok Malhotra/Watson/IBM)
Subject:  Re: XML representation of a Table




>  I just wrote an application which creates XML file from the table. All
you
>hava to do is to to give the table name and it will generate the XML. My
>Question, i just wanted to know, whether the XML generated is correct.

Sounds a useful application, I'd like to know more about it (especially if
you can do the reverse as well!). You can check whether the XML is
"correct"
(i.e. valid and well-formed) by putting it through any xml parser, I think
xp is one of the strictest. Some test cases you need to check are your
handling of non-ASCII characters and special characters such as "<" in your
data. You also need to consider whether CR/LF characters in your data are
significant: XML treats CR=LF=CRLF which may not be what you want.

One observation, in your DTD all the columns of the table are declared
mandatory, this gives you no way of handling null values (the obvious
representation of a null value is to omit the relevant element).

Another issue you may need to address is that not every SQL table and
column
identifier is a valid XML name. For example, SQL identifiers can contain
spaces.

You will also have to think about how to encode binary (blob) fields.

For large tables your representation is very inefficient in space terms.
Often we don't worry about this in XML work, but relational tables can
reach
gigabytes in size even without all these tags. An alternative I would
consider for large tables is:

<TABLEDEF NAME="ACTION">
  <COLUMNS>
    <COL NAME="ACTION_ID"/><COL NAME="ACTION_DESC"/>  etc
  </COLUMNS>
</TABLEDEF>
<TABLE NAME="ACTION">
<ROW>A<C/>Activate<C/>A<C/>PASSTEST<C/>1998-02-23 09:44:00.000</ROW>
<ROW>...</ROW>
</TABLE>

I don't think the gurus would recommend using empty elements as separators
like this, but it is a perfectly legitimate use of XML.

Finally, a transfer format for relational tables also needs to be able to
represent the metadata; my example heads in this direction.

Regards,
Mike Kay


xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following
message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)



pic25949.pcx


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.