开发者

DB or XML Question

开发者 https://www.devze.com 2023-02-05 21:26 出处:网络
XML seems to be another way to store information in a much smaller scale? While DB can handle all sorts. I\'m interested in knowing what are the pro\'s and c开发者_如何学Con\'s to the each. Is one of

XML seems to be another way to store information in a much smaller scale? While DB can handle all sorts. I'm interested in knowing what are the pro's and c开发者_如何学Con's to the each. Is one of them better in a scenario? I'm sure each has there best case scenario.

Thank you in advance.


Well... XML is a file that anyone can read, since it's text.

A database must be accessed through an API, and conforms to certain database-ey structures.

You can make XML that's like a database, or make it different, too.

You can probably prove that informationally they're equivalent, XML schema to Database schema.

In practice you'll want to write an appropriate API to your particular XML structure. But others could read the schema and do their own...

Databases shine because they usually have an API that lots of agents can access safely simultaneously. XML, by itself, is just a text file.


XML is great for storing static data, like configuration files. It can be read from very easily and quickly with existing APIs and/or XPath. However, since it is simply a file it should be used only for storing data that will be read and not require updates from the application your users will use. Depending on your OS, file locking and privileges may be an issue for updates and concurrency could be a logistical nightmare to maintain.

Databases are collections of records that can be read, updated, or deleted with ease. For large datasets, databases also provide the ability to index fields to improve performance and to setup different schema or views to control the visibility of records for different types of users. Data integrity can more easily be maintained with a database as well.

In summary, XML is better suited for small to medium datasets that will not need to change often and are read-only from the application. Databases are better suited for dynamic or large datasets or where security of the data may be a concern.


Well XML vs DB has been covered a lot by all the smart people you care to name including the Man himself. Read http://www.joelonsoftware.com/articles/fog0000000319.html things will become clearer.

0

精彩评论

暂无评论...
验证码 换一张
取 消