views:

379

answers:

9

Hi All,

I'm in the process of designing a small website and was curious when an XML file can/should be substituted for a database table. There are some cases where I think using a database table may be overkill and was just wondering if anyone else has come across making this decision.

Thanks!

+11  A: 

If you think you'll end up needing more than a tiny amount of CRUD, or your site will grow beyond a handful users, use a database.

Searching or updating XML files can kill performance and future scalability.

Galwegian
This point cannot be stressed enough, I answered a question like this before...but I can't find the link. There are statistics out there on the differences as well.
Mitchel Sellers
A: 

I'm working with an application that works with 100% XML for data storage right now. The reason for this is allowing text searching in many different other applications. Sometimes XML is better when you need to share data in other applications.

stephenbayer
XML can be used to share data, but that doesn't mean it needs to be stored as XML in the backend.
Jon Tackabury
+7  A: 

I'd opt for using database tables when concurrent writes might happen, i.e. in any situation when you cannot guarantee that only a single change to the data will happen at any one time.

Further, if the data is relational, I'd use a database.

For small things which are likely to be low traffic, XML is fine.

Dominic Rodger
+3  A: 

IMO: Use a DB when you'll have many write transactions to your data. If you are primarily writing a config type document, something mostly read only, go XML. XML as a datastore is not your best solution as you'll have much better results using a DB. Especially when you begin having many records(rows), a DB begins to become easier to work with.

Jeremy B.
A: 

You can use XML if you are not going to mage many changes with records (for labels, config etc.) otherwise it is more appropriate to use tables.

niko
A: 

I design my tables and generate XML document with select properties (FOR XML).

I think if I come across a performance problem, I can change my repository with DB.

It's better to do changeable design if performance problem or etc happens.

emremp
+2  A: 

I disagree with Stephen. Databases should be used especially when sharing data among applications is a concern.

Databases are for sharing data. That's what they were invented for, and that's what they are good at. Even in situations where concurrent update is not at issue, databases are more formal than XML files. And XML's informality is tempting at the outset, but ultimately leads to unusability.

Although it can be difficult to solve the impedance mismatch between some applications and the relational model of data and/or the SQL interface, it's still the case that you gain more in flexibility and stability than you do with XML.

I would reserve XML for situations where formal data analysis is somehow inappropriate, or formal database design is beyond the reach of the development team.

Walter Mitty
I couldn't agree more. If you want to share data use a database. We use XML but reserve it for config files which are nothing more than glorified ini files.
SWD
+3  A: 

Consider the nature of your data, and limits your data storage imposes on your data. If your data resembles records rather than documents, with a regular structure and little hierarchy, and perhaps many horizontal relations among data elements, then generally you will get better performance and robustness with a RDBMS than with some kind of native XML storage. If your data takes the form of documents, with irregular sequential structures and indefinite hierarchies, you will probably not be very heppy modeling this data in a RDBMS, and you may wish to explore native XML datastores. Open-source examples include

Commercial XML databases include

I have not used any of these products myself yet.

In either case, you can use XML as a data interchange format.

ChuckB
A: 

XML should be used for data-transfer - ie, moving data between applications (when the other apps can't touch the database for whatever reason).

There's [barely] ever a reason to NOT use a database for driving a website, however.

You might also consider a hybrid approach, like that used by Rice University's Connexions project: they use Plone (and other stuff on top of it) to present data from their database which has been created in the CNXML dialect.

warren