This forum is in archive mode. You will not be able to post new content.

Author Topic: XML vs. MySQL databases  (Read 1085 times)

0 Members and 1 Guest are viewing this topic.

Offline m0l0ko

  • Peasant
  • *
  • Posts: 129
  • Cookies: -4
    • View Profile
XML vs. MySQL databases
« on: June 27, 2012, 08:43:40 PM »
I'm doing a research project for college in which I have to generate a heap of input files for a chemistry program. Luckily, I'm a programmer so I was able to make a script to generate the files automatically for me (it woulda taken my days doing it manually but only took me a couple of hours to write the script  8) ). I was going to store the data for each individual input file in an XML file then use PHP to generate an input file for each entry in the XML file. I was gonna do this cuz I don't have much experience with XML and I wanna learn. I ended up just using what I'm familiar with though, I loaded all the data into a MySQL database instead and used PHP to generate an input file for each row of the database table. I'm wondering now what advantages XML would have over databases. In what situations would you be better off using an XML file rather than a database?

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: XML vs. MySQL databases
« Reply #1 on: June 27, 2012, 10:12:14 PM »
Quick Google search explained everything better than I could of:
http://www.daniweb.com/web-development/databases/mysql/threads/334846/xml-vs-sql
http://lists.survex.com/pipermail/cave-surveying/2001-January/000053.html

For my input: both products were made for completely different purposes. SQL is for storing data to an infinite number of records. It is damn fast and therefore used with tasks where time is critical, such as banking operations or some other stuff.
XML on the other hand is good to store some stuff... it takes much longer to process the XML to make it manipulatable.

If you're going to just store the data, don't have a shit load of data to store and won't access it every minute, then XML is the answer. Otherwise SQL is the thing to use.
Of course this may change depending on the situation etc...

One example for me:
Let's say I have a list of books in format "Author-title-year". I have about 100 of them and I want to store them somewhere better than plaintext. For this I would choose XML, because I don't have lots of those, I won't be accessing the data often.

Let's say I want to make a geological tree of my family with all the attributes (name, lastname, birth date, pet name etc.). Even though I won't be accessing the data very often or share it, I would go with SQL, because it is flexible with queries, don't require parsing which may take lots of time if I have 1000 of records. And if I wanted to filter some data, with XML I'd have to write some scripts to do...

Hope you understood what I explained :P
« Last Edit: June 27, 2012, 10:17:40 PM by Kulverstukas »

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.