建模。Xml vs. 关系型数据库[英] Modeling: Xml vs. Relational Database

本文是小编为大家收集整理的关于建模。Xml vs. 关系型数据库的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我想知道是否有最佳实践可以在何时应该使用XML建模系统之间,以及何时应该使用关系数据库对其进行建模(我知道您可以将XML存储在数据库中,但是之间存在巨大区别,但是使用归一化DB表并使用XML-Schema对系统进行建模.为了具体的清酒,假设您正在健身房进行锻炼. "卧推"实际上是一个充斥的家族,而不是一个练习.您可以躺在长凳上或球上.您可以强迫自己恢复平坦或允许作弊.您可以使用哑铃,杠铃,电缆或通用机器.如果您使用的是哑铃,则可以交替进行交替或同时推动.您可以有一个倾斜,降低或平坦的表面.我的想法是,由于我尚未想到的复杂性(以及可能的复杂性),最好使用XML对此进行建模.这是一个很好的评估吗?应该考虑其他哪些重要因素?

附录:当我说XML时,我脑海中拥有的技术之一是RDF(尽管我不希望将讨论限制为此),这似乎与实施相比具有优点和缺点在数据库表中的设计.我不确定某些用户对XML的感觉是否会一直延伸到RDF(也许是这样),但这也许会有助于将对话集中在一点上.

推荐答案

您的运动示例可以通过多种方式进行建模.为了在XML的层次模型何时显示优势的问题上进行一些经验和智慧,请阅读Ron Burrett:

在某些情况下,当要存储的内容是半结构的情况下,天然XML DBS显示出RDB的巨大优势. @smout,将将客户合同库数据存储在RDB中更容易,更安全 - 但是当您还必须存储合同时会发生什么?

rdf与关系模型和XML模型形成对比. RDF是为数据的"开放世界"表示设计的,您永远无法确定您必须在计算时了解所有内容. RDF可以在XML中表达的事实很方便,但偶然.它还有其他表达式.

在EMC XML Technologies和Marklogic上也进行一些阅读.

其他推荐答案

在1960年代,数据管理系统的发明/构思/阐述都是基于可以在层次上组织数据的想法.我是其中之一.这些系统的谬误/缺陷/缺点/缺点对任何人的使用都立即变得清晰起来(一方面,它们倾向于导致"查询偏见":在层次结构系统中,通常很容易查询给定客户的合同,并且同时,几乎不可能查询哪些客户参与给定合同).

所有这些缺陷最终都导致了关系模型的发明.

因此,如果您想知道XML是否适合作为任何数据管理问题的解决方案,请问自己:" XML本质上是XML层次结构吗?".

XML在市场上的成功仅证明了"不知道历史注定要重复历史的人"的观察的正确性.

其他推荐答案

通常,XML只是一种临时文件格式,可以将数据从一个系统发送到另一个系统.或存储一小部分数据,例如配置选项和更多数据.如果您的数据需求很小,并且您正在处理单用户的情况,则XML会很好.

如果您必须处理多用户环境,则仍然可以使用XML,但是您需要围绕它创建一个复杂的业务层,并跟踪所有用户的修改,并基本上添加了许多多用户功能普通的RDBMS标准提供. 如果您有很多数据,那么您的XML文件就会变得太大. XML标准有点肿,如果您必须使用500 MB的XML文件,希望您有很多耐心.

当然还有其他选择.我曾经创建了一个简单的Web爬行者,该搜寻器将下载一个网页,在其中提取所有URL,然后为每个URL重复此操作.它使用了大约20个线程,这些线程都下载了页面,并且URL的数量将成千上万.我想避免两次下载单个URL,因此我不得不过滤出重复项.考虑到数据量,使用XML将进行噩梦.使用数据库是过分的,因为我所需要的只是一个带有单个字段的表:URL.因此,我编写了一种特殊的哈希算法,并创建了我自己的基于文件的哈希表解决方案.这也是真的很快,如果不必下载该页面,请检查每秒数千个URL ...

在这样的情况下,我将通过为XML使用某些建模工具创建一个简单的XML模式. (Altova的XMLSpy擅长于此.)当我认为我的数据适合此XSD时,我开始创建一个数据库,其中每个元素都会转换为表.结果,我将拥有一个良好的关系数据库以及XML格式的一些定义,可用于导入/从数据库导入/导出相同的数据.

本文地址:https://www.itbaoku.cn/post/597669.html

问题描述

I am wondering if there are best practices for deciding between when a system should be modeled using XML and when it should be modeled using a relational database (I know you can store XML in a database, but there is an enormous difference between modelling a system using normalized db tables and modelling a system using XML-Schema). For concreteness sake, let's say you were modeling exercises in a gym. The "bench press" is actually a family of exericses, not a single exercise. You can lie down on a bench, or a ball. You can force you're back flat or allow cheating. You can use dumbells, barbells, cables or a universal machine. If you are using dumbells you can alternate arms or push simultaneously. You can have an inclined, declined or flat surface. My thinking is that due to the complexity (and possible complexity that I have yet to think of) that this would best be modelled using xml. Is this a good assessment? What other important factors should be considered?

Addendum: When I said XML, one of the technologies I had in the back of my mind was RDF (though I did not wish to limit the discussion to that), which would seem to have pros and cons compared to implementing the design in database tables. I'm not sure if the general antipathy some users feel towards XML would extend all the way to RDF (maybe so) but perhaps that will help focus the conversation a little.

推荐答案

Your exercise example could be modeled in many ways. For some experience and wisdom on the question of when xml's hierarchical model shows an advantage, read Ron Burrett:

http://www.rpbourret.com/xml/XMLAndDatabases.htm

There are cases where native xml DBs show enormous advantages of RDBs when the content to be stored is semi-structured. @Smout, es it is easier and safer to store the customer-contract-customer data in an RDB -- but what happens when you also have to store the contract?

RDF contrasts with both relational models and with xml models. RDF is designed for an "open-world" representation of data in which you can never be sure that you know everything at the time you have to compute. The fact that RDF can be expressed in xml is convenient, but incidental. It has other expressions as well.

Do some reading at EMC XML Technologies and MarkLogic as well.

其他推荐答案

In the 1960's, data management systems were invented/conceived/elaborated which were all based on the idea that data can be organized hierarchically. IMS being one of them. The fallacies/deficiencies/shortcomings of those systems immediately became clear to anyone intensively using them (for one, they tend to lead to 'query biases' : in hierarchical systems, it is often easy to query which contracts exist for a given customer, and at the same time almost impossible to query which customers are involved in a given contract).

All those deficiencies have ultimately led to the invention of the relational model.

So if you want to know whether XML is suitable as a solution for ANY DATA MANAGEMENT PROBLEM WHATSOEVER, ask yourself this : "is XML hierarchical in nature or not ?".

The success of XML in the marketplace only proves the correctness of the observation that "those who don't know history are doomed to repeat it".

其他推荐答案

In general, XML is just a temporary file format to send data from one system to another. Or to store a small set of data, like configuration options and a bit more data. If your data needs are small and you're dealing with a single-user situation, XML will be just fine.

If you have to deal with a multi-user environment, you can still use XML but you would need to create a complex business layer around it, keeping tracks of modifications by all users and basically adding lots of multi-user functionality that a normal RDBMS offers as standard. If you have lots of data, there is a risk that your XML file becomes too big. The XML standard is a bit bloated and if you have to work with XML files of 500 MB each, I hope you have lots and lots of patience.

There are, of course, other alternatives. I created a simple web crawler once which would download a webpage, extract all URLs in it and then repeat this action for every URL. It used about 20 threads that were all downloading pages and the number of URLs would grow into millions. I wanted to avoid downloading a single URL twice so I had to filter out duplicates. Using XML would a nightmare, considering the amount of data. Using a database was overkill since all I needed was a single table with a single field: URL. So I wrote a special hashing algorithm and created my own file-based hashing table solution. It was really fast too, checking several thousands of URL's per second, if it didn't have to download that pages...

With situations like this exercise, I would start by creating a simple XML schema by using some modeling tool for XML. (Altova's XMLSpy is good at this.) When I think my data would fit nicely in this XSD, I start to create a database, where every element will be converted to a table. As a result, I would have a good, relational database plus some definition for an XML format that can be used to import/export the same data to/from the database.