Page 1 of 1

Xml or Mysql?

Posted: Sat May 10, 2008 4:17 pm
by chidge
My first post on this forum.

Im new to the world of Php and am learning very fast and enjoying the pleasures gained from bringing things to life:) I am currently a good chunk of my way through developement of a new site and I have one question that I already have a few answers for.

Basically for say a blog system, communicating the contents of a folder and captions (for dynamic picture gallery), internal email system and off the top of my head say a news system am I better off using xml or mysql?

For instance - the dynamic picture gallery automatically uploads images, creates thumbnails into specific user folders - then I will either read the src of the images and captions from the table in the database or from an xml file where they are stored. Pretty much the same theory for the rest. Also the usual delete and add theory for xml and database (as in the storage method is not going to get clogged up with redundant information)

I have read that xml is good for portability between programs as such and also that mysql is very fast - but I am still a little confused as to the best way to turn for the storage of this data. Considering php will be the face of submitting and retriving both forms of data and the processes used will be reflected across different user profiles. I obviously want the site I am creating to be as fast as possible and to be as scaleable as possible and basically wish to design and create it by using best practices.

So what do you say? Xml or Mysql

Anyway your thoughts would be appreciated on this.

Re: Xml or Mysql?

Posted: Sat May 10, 2008 4:57 pm
by onion2k
If you want it to be fast and scalable that MySQL is the only choice. Using XML wouldn't be scalable, and probably wouldn't be very fast unless you created some elaborate caching system.

Of course, ideally you should use an abstraction layer between your code and the data. Not sure that would be something I'd recommend if you're completely new to it all though. It's quite complicated.

Re: Xml or Mysql?

Posted: Sun May 11, 2008 4:43 am
by chidge
Thanks, so apart from portability why is xml apparently so good with php5? (even your tag makes it sound as good as ultra violence!)

Re: Xml or Mysql?

Posted: Wed May 14, 2008 6:22 pm
by Kieran Huggins
parsing XML is easier with PHP5 than it was in previous versions, but that doesn't mean XML is well suited to your task.

MySQL FTW!

Re: Xml or Mysql?

Posted: Thu May 15, 2008 9:30 am
by chaos
The main thing is, MySQL is a database engine and XML isn't. XML is a markup language. A flat file containing XML is just a flat file; in and of itself, it has no search capabilities, no nothing. XML itself isn't a medium of storage at all, it's a format.

Asking whether you should store your data in MySQL or XML is something like asking whether you should cut your hair with scissors or enthusiasm.

Re: Xml or Mysql?

Posted: Thu May 15, 2008 9:44 am
by pickle
chaos wrote:...like asking whether you should cut your hair with scissors or enthusiasm.
Bwa ha ha ha. That's awesome.

But I digress...

Re: Xml or Mysql?

Posted: Thu May 15, 2008 9:56 am
by chidge
But in the case of say an internal email system, a message sent from say "admin" that will be sent to every site users inbox - for that to be stored in an xml file and for ever users inbox to read that xml file rather than communicating with the database would surely be better? Or am I underestimating the speed of mysql?

Re: Xml or Mysql?

Posted: Thu May 15, 2008 10:07 am
by chaos
You are underestimating the speed of MySQL, or any database engine. That sort of thing is what they're for.

Re: Xml or Mysql?

Posted: Thu May 15, 2008 10:34 am
by chidge
excellent news - thanks for all the replys