[thelist] xml vs. regular database

David.Cantrell at Gunter.AF.mil David.Cantrell at Gunter.AF.mil
Fri Jan 17 09:05:01 CST 2003


>1. what's the difference between xml and a flat text database?

Well, if you pull from flat-text you have to write the whole parser
yourself. With XML you already have a parser. When you change your text
format your parser has to change. The XML parser will not change; it's
automatically forward-compatible. :)

>2. why use xml over a standard call to a db?

Depends on what you want to do. If you are only talking about small bits of
data then storing it in an XML file is probably a good way to go. Also if
the data can easily be represented in a hierarchical fashion, then XML is a
good choice.

If you need to preserve referential integrity, need to store large amounts
of data, or need a really robust solution with transactional support, then
databases are the obvious choice.

Also, many of us (me at least) use both: I have a system whereby I fetch an
ADO Recordset from the database (using ASP & VBScript), then run the
recordset through a custom VBScript class which converts the recordset to a
custom hierarchical XML document for me, then I pass that document in-memory
through an XSLT stylesheet and write out the results to the browser.

The end result is that I have almost complete separation of code (ASP) and
presentation (XSLT). When I am asked to make a change to a page's layout, I
just edit the HTML emitted by the XSLT file. And since XSLT and XML are
markup languages similar to HTML, it's a lot easier on the eyes as well. (if
you're used to that sort of thing anyway)

Now that I'm moving to ASP.NET and VB.NET/C#.NET I believe I'll be pulling
data from the SQL Server 2000 database using T-SQL's "FOR XML" clause, which
returns the data from the database as XML. Should eliminate the intermediate
step of conversion.

>3. is xml only useful if no database can be used and/or data is to be
>transferred between two dissimilar systems? that is, i can't send an
>MSSQL database to a system running 9i.

No, see above. :)

>as far as i'm concerned, i think...

<snip!>

Yes, you are thinking along the right tracks.

I've found XML is one of those things that you spend a while trying to get
your head around, and then suddenly ZAP you *really* start to grok it, you
see the potential for it in storing data and, more importantly, *moving data
around between systems*. Next thing you know you are standing on your desk
with your XML book in hand, preaching to everyone in earshot about how
important it is. :)

HTH,
-dave



More information about the thelist mailing list