简体   繁体   English

XML 作为数据存储。 插入、删除、删除

[英]XML as data store. Insert, remove, delete

I was planning to use XML to store the data for a Java DVD database application I'm writing.我计划使用 XML 来存储我正在编写的 Java DVD 数据库应用程序的数据。 I know that the word "database" is right there in the title, but XML just seemed so much more portable, was human readable and (I assumed before looking into it) simpler to implement.我知道“数据库”这个词就在标题中,但是 XML 似乎更加便携,易于阅读并且(我在研究之前假设)更易于实现。

Parsing XML seems to be the easiest thing in the world... even creating a new XML file isn't much trouble, but changing records, inserting them or deleting them, I can only see to do by creating a fresh XML file.解析 XML 似乎是世界上最简单的事情......即使创建一个新的 XML 文件也不是很麻烦,但是更改记录,插入或删除它们,我只能通过创建一个新的 Z3501BB093D363ED83F8B67 文件来实现。

Am I missing something?我错过了什么吗? Or is the thing that I'm missing that I should switch over to a database format (but there's some wonderful database format I've not heard of, that's totally portable and users won't need to install something separate to use:) )或者是我缺少的东西,我应该切换到数据库格式(但是有一些我没听说过的美妙的数据库格式,它是完全可移植的,用户不需要安装单独的东西来使用:))

the most popular way to use a file as a database is probably with sqlite http://www.sqlite.org/ and that's what i would use if i were solving your problem (it's pretty much a standard SQL database, but uses just one file as storage). the most popular way to use a file as a database is probably with sqlite http://www.sqlite.org/ and that's what i would use if i were solving your problem (it's pretty much a standard SQL database, but uses just one文件作为存储)。 another, pure-java option is apache derby http://db.apache.org/derby/另一个纯 java 选项是 apache derby http://db.apache.org/derby/

however, pure xml databases do exist (and were quite fashionable about 10 years ago - the "nosql" of their time) - the associated standards are xpath http://en.wikipedia.org/wiki/XPath and xquery http://en.wikipedia.org/wiki/Xquery . however, pure xml databases do exist (and were quite fashionable about 10 years ago - the "nosql" of their time) - the associated standards are xpath http://en.wikipedia.org/wiki/XPath and xquery http:// en.wikipedia.org/wiki/Xquery i haven't used it, but it seems like basex http://basex.org/open-source/ is an open-source implementation that you could use (and it does claim to provide ACID guarantees - http://basex.org/products/ ).我没有使用它,但似乎basex http://basex.org/open-source/是一个你可以使用的开源实现(它确实声称提供ACID保证 - http://basex。组织/产品/ )。

if you're more familiar with xml than sql i don't see any great harm in using an xml database for a small project.如果您对 xml 比 sql 更熟悉,我认为在小型项目中使用 xml 数据库没有什么大的危害。 just structure your code so that most of the program doesn't care what the storage is (ie by providing a neutral interface).只需构造您的代码,以便大多数程序不关心存储是什么(即通过提供中性接口)。 then if xml doesn't work out you can switch to sql by re-implementing just that interface and leaving the rest of your program alone (and if it does work, post back here saying so - it would be interesting to know).然后,如果 xml 不起作用,您可以切换到 sql,方法是重新实现该接口并留下 rest 单独返回您的程序(如果它确实有效,那么在这里说出来会很有趣)。

If you're going to have a web-based front end, it seems that a regular database is the way to go as the back end.如果您要拥有一个基于 Web 的前端,那么似乎常规数据库是 go 作为后端的方式。 I don't believe your users would have a need to download anything new, since that's all taken care of server-side.我不相信您的用户需要下载任何新内容,因为这一切都由服务器端处理。 A real database also has the ACID advantage over a pseudobase;与伪数据库相比,真实数据库也具有 ACID 优势。 it should be atomic, consistent, isolated, and durable, and I can't imagine XML would be a good substitute in those respects.它应该是原子的、一致的、隔离的和持久的,我无法想象 XML 在这些方面会是一个很好的替代品。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM