Can i use xml as database




















Contact Us. Is the performance favorable using DataDirect XQuery? Do you have any sample code we can use for a proof of concept? Back to top. View all Tutorials for: XQuery. They are solid, stable, useful products. They are not going away. XML is a very useful technology for moving data between different databases or between databases and other programs. However, it is not itself a database. Don't use it like one.

This seems to really stress that XML should not be used for data storage and should only be used for program to program interoperability. Personally, I disagree and. NET's app.

However for databases rather than configurations etc XML should not be used. To develop my point, I will use two examples: A Data about customers with fields that are all on one level i. So my question is, Is this still a valid statement and is it now acceptable to store data using XML? This quote is not about using XML as a storage format in general for which it is fine, depending on the requirements , but for database -type storage.

When people talk about databases, they usually mean storage systems that store huge quantities of data, often in the gigabyte or terabyte range. A database is potentially much larger than the amount of available RAM on the server that stores it. Since nobody ever needs all the data in a database at once, databases should be optimized for fast retrieval of selective subsets of their data: this is what the SELECT statement is for, and relational databases as well as NoSQL solutions optimize their internal storage format for fast retrieval of such subsets.

XML, however, doesn't really fit these requirements. Due to its nested tag structure, it is impossible to determine where in the file a certain value is stored in terms of a byte offset into a file without walking the entire document tree, at least up to the match. A relational database has indexes, and looking up a value in an index, even with a primitive binary-search implementation, is a single O log n lookup, and then getting to the actual values is nothing but a file-seek e.

In an XML file, the most efficient way is to run a SAX parser over your document, doing an awful lot of reads and seeks before you get to your actual data; you can hardly get this any better than O n , unless you use indexes, but then, you'd have to rebuild the entire index for every insertion see below.

Inserting is even worse. Relational databases do not guarantee row order, which means they can just append new rows, or overwrite any rows marked as 'deleted'. This is extremely fast: the DB can just keep a pool of writable locations around; getting an entry from the pool is O 1 unless the pool is empty; worst case, the pool is empty and a new page has to be created, but this too is O 1. By contrast, an XML-based database would have to move everything after the insertion point to make room; this is O n.

When indexes come into play, things become even more interesting: typical relational-database indexes can be updated with relatively low complexity, say O log n ; but if you want to index your XML files, every insertion potentially changes the on-disk location of every value in the document, so you have to rebuild the entire index.

This also goes for updates, because updating, say, an element's text content, can change its size, which means the consecutive XML has to shift. A relational database doesn't have to touch the index at all if you update a non-indexed column; an XML database would have to rebuild the entire index for each update that changes the size of the updated XML node.

Those are the most important downsides, but there are more. XML is very verbose, which is good for server-to-server communication, because it adds safety the receiving server can perform all sorts of integrity checks on the XML, and if anything went wrong in the transfer, the document is unlikely to validate.

XML is lousy for data storage. First, it is very verbose. Data stored in an XML file will take much more disk space then the same data stored in any reasonable database system. In an XML record, the name of a particular field will be stored twice, along with the string representation of the data. So, for example, to store a single integar in a field called "foobar", you end up with this 19 byte string:. On the other hand, a real database will store this as a single integar value, taking 4 bytes.

If your database is small, that doesn't mean much, but if you have 10, records, that's a problem. Second, an XML has to be parsed from text every single time the file is read. For the above field, a real database simply reads the binary data into memory from the offset it knows it stored the field "foobar" in. If the file is stored as XML, it has to read the field "foobar", parse that text, determine what field it is, then parse the string "42" and convert it into the binary Thus the performance penalties for using XML are huge.

The benefits of XML are that it is somewhat human readable, and that it allows for easy transfer of data between completely separate systems. Neither of those advantages applies for a local database. The one exception is configuration files, which are generally small, and generally need to be editable by humans.

In this specific instance the devil is very much in the details. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. XML vs. Relational databases? Ask Question. Asked 6 years, 5 months ago. Active 5 years ago. Viewed 7k times. My questions, then, are: Could you describe some advantages that XML databases have over relational?

Could you provide an example where it might be better to use an XML database over a relational one? Improve this question. Colin 't Hart 8, 14 14 gold badges 33 33 silver badges 40 40 bronze badges. Perhaps the purpose is for you to learn XML technology, and thus become aware of its strengths and limitations? 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. 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.

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. 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.

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.

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. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow.

Learn more. Which should I use? Ask Question.



0コメント

  • 1000 / 1000