NYCPHP Meetup

NYPHP.org

XML vs. rel DBs [was: Re: [nycphp-talk] Many pages: one script]

Keith Casey mailinglists at caseysoftware.com
Wed Aug 8 10:59:43 EDT 2007


On 8/8/07, David Krings <ramons at gmx.net> wrote:
> The best thing about XML is that it is really is just a flat file and
> everything in it has a beginning and an end. I cannot think of anything
> that one would want to store in XML that cannot be stored in a db and
> that also cannot be stored in a text file with way less overhead.
> Examples are welcome.

There are a number of things which are a much better fit for XML
rather than a database or a flat file... such as arbitrary depth/width
tree structures.

For example, when I worked at the Library of Congress answering the
Ultimate Geek Question, we were working with such trees in the
digitization process.  Handling arbitrary width in a database is basic
but handling arbitrary depth quickly gets you into a table structure
that looks like:

tableName - id, displayOrder, parent_id

While that seems simple, it gets to be quite nasty quite quickly
because of the recursive database queries to pull everything back...
and you need to convert it to the actual tree before you can do much
with it.  Using a Lazy Loader improves things a bit, but you're just
spreading out the work.

Alternatively, with the XML, it's already in the tree.  Add in a
simple recursive template and storing it as XML (in a db or native
XML) and you can render it in html/whatever in one fell swoop.  It's
really kind of nifty when it's done right.

The same applies to work breakdown structures...  *cough*dotProject*cough*.

One disclaimer... when I was at the LoC, Elliote's XML Bible was one
of our core resources.

kc

-- 
D. Keith Casey Jr.
CEO, CaseySoftware, LLC
http://CaseySoftware.com



More information about the talk mailing list