users@jaxb.java.net

Re: Relational Data in XML?

From: Andrew Wellman <aj_at_wellmans.com>
Date: Sun, 09 Feb 2003 07:41:04 -0700

On Sun, 9 Feb 2003 13:33:13 +1100
Robert Mark Bram <relaxedrob_at_optushome.com.au> wrote:

> Howdy all!
>
> I am about to start building an order entry system (re my earlier post
> "JAXB or XML DB?"). I have a question about storing the data as XML..

First off, I would likely not recommend using XML as your entire data
store unless you have a sophisticated tool such as an XML capable
database. What I traditionally do is us XML for single use cases --
such as storing and order -- or for property/config files that can be
loaded in at start-up time. In other words, I don't like to do a lot of
input and output with XML. However, even in those circumstances JAXB
has become a tremendous tool.

>
> I know how a set of tables for a basic database might look:
>
> [customer] 1 - x [order] 1 - x [line-order] x - 1 [part]
>
> Customer makes many orders, each order is for one customer.
> An order may contain many line-orders, each line-order is part of one
> order only.
> Each line order is for one part only, each part may be included in
> many line-orders.
>
> But how do I go about designing an xml document for this? Am I going
> to repeat part data inside every line order? Can I link xml documents
> in the same way relational tables can be linked?

First off, my best guess says you would want seperate files. In an
order scenario I would name an order with a unique name (like a primary
key) and then know how to find it based on that. Here is an excellent
article I just read about OO and Datbase structures within an XML
document.

http://www.xml.com/pub/a/2000/10/04/linking/index.html

I am using the strategy which uses schema ids and references.

Regards,
Andrew Wellman