Xml or Mysql?

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
chidge
Forum Commoner
Posts: 29
Joined: Sat May 10, 2008 4:03 pm

Xml or Mysql?

Post 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.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Xml or Mysql?

Post 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.
chidge
Forum Commoner
Posts: 29
Joined: Sat May 10, 2008 4:03 pm

Re: Xml or Mysql?

Post 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!)
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Xml or Mysql?

Post 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!
User avatar
chaos
Forum Newbie
Posts: 22
Joined: Thu May 15, 2008 9:20 am
Location: New Jersey

Re: Xml or Mysql?

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Xml or Mysql?

Post 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...
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
chidge
Forum Commoner
Posts: 29
Joined: Sat May 10, 2008 4:03 pm

Re: Xml or Mysql?

Post 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?
User avatar
chaos
Forum Newbie
Posts: 22
Joined: Thu May 15, 2008 9:20 am
Location: New Jersey

Re: Xml or Mysql?

Post by chaos »

You are underestimating the speed of MySQL, or any database engine. That sort of thing is what they're for.
chidge
Forum Commoner
Posts: 29
Joined: Sat May 10, 2008 4:03 pm

Re: Xml or Mysql?

Post by chidge »

excellent news - thanks for all the replys
Post Reply