views:

579

answers:

9

Well, I know its a bit stupid. If I want to store a large amount of data. Should I use xml or database(mysql)?

Why do you choose (that) one?

What are the pros and cons using xml?

What are the pros and cons using mysql?

Clubpenguin, habbo hotel, those virtual worlds are using xml or mysql??

A: 

Most big sites are using a database like MySQL.

The most important question you need to answer is how you want to access your data. If you want to have many people looking things up many times a second (eg a popular website), then use a database like mysql.

Rory
A: 

I would believe it more likely they're using a Fully Fledged DBMS as a backing store, and only generating/parsing XML as an interface.

XML is imho far too heavy to be used for a high-data store database.

The Structure is too parse-heavy and even if you had some sort of server which started, parsed, and then ran based on the XML data, the initialization time would be killer, as would be the data reserialization phase every time a write was done.

RDBMS's benefit by having much more efficient packed data storage with predictable searching/seeking through records and multiple data-stores and multiple indicies.

Kent Fredric
nb. this question is probably more apt for StackOverflow.com, its not really a server-side deal, its more a programmatic/efficiency/implementation deal.
Kent Fredric
+7  A: 

MySQL (or SQL Server, Oracle, DB2, etc.) are database engines: they're specific applications thatwere built for data storage and processing, and are very good at doing that; they also can run on a different server than the one where your main program is, allowing for load sharing.

XML files are just text files stored on your machine or another one; they need to be read, parsed and written to, and only your program can do that. They'are also really, really inefficient, because of their text nature: reading and parsing a text file is very slow, and modifying it is even worse.

XML files are good for storing configuration settings and passing data between different systems, but data storage and processing should definitely live in a proper DBMS.

Massimo
+2  A: 

It depends a lot on what kind of data you want to store. If you are storing mostly document oriented stuff, XML can be a good choice. If you are storing lots of small hierarchies, XML is probably better than SQL. The time to read and parse an XML file is definitely more that the time needed to get a simple query out of a database. But if you have data that do not fit naturally in a database, the cost of query could go up dramatically and actually become more than just using XML files.

One other option you could try is using an XML database, for example Xindice (http://xml.apache.org/xindice/). XML databases are not that much used at the moment, mostly because we dont have good mathematical theories about hierachic databases. But they can be really usefull if you have the right problem ...

Guillaume
+1  A: 

This seems more of a StackOverflow question rather than a ServerFault question. Anyways..

If you need random access to data elements, use a real database. If you're just doing batch processing or something, xml will work, but a database is still fine for that too.

If you don't need to store data with relational properties, you could try a key/value store, or document-oriented database, instead of a RDBMS, for better performance/scalability in exchange for fewer features.

ehsanul
+3  A: 

Consider if you have an XML document with a nested person element that contains information on each of your users, and you have 3000 users. If you want to pull the information for a single person, you're going to have quite the task of parsing through that huge file to find that person's information. You might could use some clever seeking to jump around the file, but ultimately there is going to be alot of sequential access.

With a database you will normally have indexes, which would allow you to very quickly perform searching tasks like the above. In the above scenario, finding an individual in an indexed table will probably be on the order of 100 times faster.

AaronLS
+1  A: 

Well, I know its a bit stupid. If I want to store a large amount of data. Should I use xml or database(mysql)?

First of all, XML is hierarchic by its nature, while MySQL is relational.

If you will store your data as XML document:

<customer>
 <address/>
 <address/>
</customer>

, it's super easy to obtain all addresses of a customer, but not so easy to obtain customers for a given address.

Second, XML is more user-oriented. You can easily edit it with your favourite text editor. In MySQL, it's not so easy.

Given all above, if your data are hierarchical, small in size and you need them to be easily editable without any frontend, use XML.

If your data are relational and you need fast set operations on large quantities of data, use MySQL.

Quassnoi
A: 

XML is not a database, it's a file format (or, to be more precise, an input or output stream format). It allows you to define your own format using XML's syntax elements and then you can, for example, convert your memory object to an XML stream and save it to disk.

mySQL is a software product that belongs to the class of products called DBMS (Database managent system). DBMSs manage your data and provide various storage, retrieval, indexing, querying, and transactional capabilities.

What you need to decide is whether you need a file format or a management system. Depending on that, your choice may be XML (or some other format, e.g. JSON or a plain-text file) or mySQL (or another relational DBMS, e.g. MS SQL Server or Oracle -- or may even be a non-relational DBMS).

azheglov
A: 

Markmail.org may surprise you -- it's an xml store.

Read Ron Burret (http://www.rpbourret.com/xml/XMLAndDatabases.htm) is an great source on the subject.