XML 本机数据库与关系数据库 — PHP 与 XQuery
我正在尝试开发一个网站,其中存储并为客户检索许多食谱。我有一些关于 XML 和基于 XML 的原生数据库的课程,这些课程介绍了原生 XML 数据库的概念。此外,如果我没记错的话,我们了解到 XQuery 是最适合处理 XML 的编程语言。由于菜谱的半结构性和不那么表格化的性质,我猜想(如果我错了,请纠正我)它可以最好地用 XML 文件来表达,如下所示:
<recipe>
<ingredients>
<name='floor' amount='500g'/>
<name='y' amount='200g'/>
</ingredients>
<steps>
<step id='1'> first prepare .....
<steps>
</recipe>
我知道关系数据库有其优点,并且优于其他选项,但是在这种特殊情况下,它会导致表上有如此多的联接操作。另一方面,就其处理大量数据的性能和能力而言,本机 XML 数据库对我来说似乎不太有前途。此外,考虑到互联网上大量的教程和帮助,PHP 编程比 XQuery 简单得多。 我真的不知道该怎么办,所以我才来找你们。
I'm trying to develop a website in which many recipes are stored, and retrieved for the clients. I had some courses about XML and native XML-based databases, and those courses introduced the concept of native XML databases. Besides, if I remember correctly, we learned that XQuery is the most suitable programming language for working with XML. Because of the semi-structure and not so tabular nature of a recipe, I guess(please correct me if I'm wrong) that it can be best expressed in an XML file, like below :
<recipe>
<ingredients>
<name='floor' amount='500g'/>
<name='y' amount='200g'/>
</ingredients>
<steps>
<step id='1'> first prepare .....
<steps>
</recipe>
I know that relational databases have their advantages and glories over other options, however it would result in so many join operations on tables in this particular case. On the other hand, native XML databases don't seem very promising to me, regarding their performance and abilities to handle a large amount of data. Besides, programming in PHP is much more simpler than XQuery, considering the huge volume of tutorials and helps on internet.
I really don't know what to do, and that's why I came to you guys.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一些简单的确定理论,无需考虑任何强烈的要求或其他东西。
首先你的数据源在哪里。
那么你可以想到关系-db。
那么 Xml 数据库是关键。
some simple determination theory without looking any strong requirements or something.
first where is your data-source gonna be.
then you can think of relation - db.
then Xml Database is the key.
使用关系数据库 - 因为如果您获得更多记录,它会更快,并且创建起来更简单。
(对于您的示例,它是 3 张表 - 一张包含食谱,另一张包含成分,最后一张包含步骤。另一种方法是创建包含所有已知成分的表格并使用关联 - 例如包含食谱 ID、成分 ID 和数量的表格)
Use relations DB - because it is much more faster if you get bigger amout of records , and it is simplier to create.
( for your example it is 3 tables - one with recipes, another with ingredients and the last one with steps. Alternative is to create table with all known ingredients and use association - eg. table with ID of recipe, ID of ingredient and amount )
您似乎认为必须在此处选择一个或另一个。事实并非如此,XQuery 并不是真正被设置为一个完整的 Web 脚本环境,它只是 SQL 而不是 PHP 的替代品。因此,您当然可以使用 PHP 来完成网站中以 Web 为中心的部分,例如用户登录(也可以在关系数据库中),然后仅将 XQUery 用于您的配方查询层。
一些 XML 数据库(例如 MarkLogic)也可以完成等式的所有 Web 逻辑方面的工作,但它们还没有提供相同丰富的库,因此我肯定会推荐 PHP 或类似的 Web 层数据库。
It seems that you're thinking that you have to choose one or the other here. That isn't the case, XQuery isn't really setup to be a complete web scripting environment, it's a replacement to SQL not PHP. Therefore you can certainly use PHP to do the web focused parts of the site such as user logins (which could also be in a relational DB) then use XQUery just for your recipe querying layer.
Some XML databases such as MarkLogic can also do all the web logic side of the equation but they don't offer the same richness of libraries yet, so I would certainly recommend PHP or something like that for the web tier.