开发者

XML native database vs. Relations DB -- PHP vs. 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 k开发者_如何学运维now 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.


some simple determination theory without looking any strong requirements or something. first where is your data-source gonna be.

  1. if your data is being generated through a user input screens.
  2. if your data is well validated and processed by a single application( e.g) web ).
  3. if your data properties and features are pretty much freezed and no new dimension to it.
  4. if your data is of transaction nature.

then you can think of relation - db.

  1. if your data is coming from different datasources like flat file, xml, internet screen scraping , etc etc.
  2. comparatively less amount transaction
  3. data properties are fluid and can have various slice / dimension to it.
  4. ready to work with functional languages like XQuery or Xmllized language like XSLT

then Xml Database is the key.


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 )


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜