热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

您何时选择将XML存储在关系数据库中?[重复]-WhendoyouopttostoreXMLinarelationaldatabase?[duplicate]

PossibleDuplicate:WhywouldIeverchoosetostoreandmanipulateXMLinarelationaldatabase?

Possible Duplicate:
Why would I ever choose to store and manipulate XML in a relational database?

可能重复:为什么我会选择在关系数据库中存储和操作XML?

Although this question on the surface appears to be a rehash of what's already been previously asked, I'll state up front that it is not. My question is not how to store or retrieve XML from a relational database. The question at hand is much more fundamental than that:

虽然表面上的这个问题似乎是对之前已经提出过的问题的重新讨论,但我会事先说明事实并非如此。我的问题不是如何从关系数据库中存储或检索XML。手头的问题远不止于此:

What type of data do you usually store in XML format in your database? What are your design decisions for doing so? Are you willing to give up the 'relational' aspect of your database by putting certain parts of your model into an XML blurb? Things such as preferences or configuration files can be stored as XML in a relational database, but should you do it?

您通常在数据库中以XML格式存储哪种类型的数据?这样做的设计决定是什么?您是否愿意通过将模型的某些部分放入XML模糊中来放弃数据库的“关系”方面?诸如首选项或配置文件之类的东西可以作为XML存储在关系数据库中,但是你应该这样做吗?

6 个解决方案

#1


3  

Never.

决不。

Storing data to which there is some kind of recognisable structure as XML, instead of as relational data, means abandoning the power of the relational algebra to operate on that data.

将存在某种可识别结构的数据存储为XML而不是关系数据意味着放弃关系代数的功能来操作该数据。

If that is your very intention, fine, but then be plain honest about it and just don't bother to use a relational DBMS at all, just dump your XML in some local/pseudolocal file.

如果这是你的意图,那很好,但是然后对它真诚,​​只是根本不打算使用关系DBMS,只需将XML转储到某个本地/伪局部文件中。

(Observe that anything stored in a filesystem constitutes a database too, so it's not like that solution means that you are "not using a database". You're just not using one that is managed relationally, which was your very intention to boot.)

(观察文件系统中存储的任何东西也构成了数据库,所以它并不像解决方案意味着你“不使用数据库”。你只是没有使用一个关系管理的,这是你打算引导的。 )

#2


2  

My experience with storing XML in a relational database is usually storing serialized objects for either historical purposes or as part of a persistence strategy with the assumption that I will later retrieve this XML and rehydrate it into an object.

我在关系数据库中存储XML的经验通常是为了历史目的或作为持久性策略的一部分存储序列化对象,并假设我稍后将检索此XML并将其重新水合为对象。

#3


2  

The only reason, IMHO, to put XML in a database is if you need to interact, edit, or change the data with your project. If you are simply reading and using the XML Data, just throw it in a file. But if that data is being modified or added to with the application, its better to use a DB for that and you don't really need XML at all, since the table will describe the structure of the data.

恕我直言,将XML放入数据库的唯一原因是,您需要与项目进行交互,编辑或更改数据。如果您只是阅读和使用XML数据,只需将其放入文件即可。但是,如果正在修改该数据或将其添加到应用程序中,那么最好使用数据库,而您根本不需要XML,因为该表将描述数据的结构。

#4


1  

Your code may want to process XML data in the following ways:

您的代码可能希望以下列方式处理XML数据:

  1. Only persist it in the database, do all the processing in the business layer, e.g. a queue or audit trail of SOAP messages to/from a web service. For this I would use a simple text column.
  2. 只在数据库中保留它,在业务层中进行所有处理,例如, SOAP消息到/来自Web服务的队列或审计跟踪。为此,我将使用一个简单的文本列。
  3. Persist it in the database and run occasional queries in the database layer, e.g. an XHTML document that users could search. For this I would use the xml data type in SQL Server 2005 or above, or the equivalent in other DBMSs.
  4. 将其保留在数据库中并在数据库层中偶尔运行查询,例如用户可以搜索的XHTML文档。为此,我将使用SQL Server 2005或更高版本中的xml数据类型,或其他DBMS中的等效类型。
  5. Full-scale complex relational queries in the database layer, e.g. a blob of relational data that was merely serialised to XML and must now be stored in its proper form. This would obviously be stored in the set of tables that matched the deserialised data structure.
  6. 数据库层中的全尺寸复杂关系查询,例如,一小段关系数据,仅仅序列化为XML,现在必须以适当的形式存储。这显然存储在与反序列化数据结构匹配的表集中。

#5


0  

I tend to store xml blurbs (or other opaque data such as json serialized) when the data itself does not need to have relationships.

当数据本身不需要关系时,我倾向于存储xml blurbs(或其他不透明数据,如json序列化)。

#6


0  

I use these conditions for storing XML data in a database.

我使用这些条件将XML数据存储在数据库中。

  1. I don't have the time to develop the relational tables (really, I sometimes start off this way just to get a prototype up and running).

    我没有时间开发关系表(实际上,我有时会以这种方式开始,只是为了让原型启动并运行)。

  2. The data is much to large and complex in structure to break into tables without considerable effort

    数据非常庞大且结构复杂,无需付出相当大的努力即可打入表格

In general I like to store relational data in my database, but imagine I have an object that represents all the data required to render a web page (I mean everything, fonts, images the lot), Its going to be incredibly complex, storing it in a table structure will serve to really only casue me maintenace issues - the structure is fluid. it would also cause me query issues - imagine the number joins I would need to do, and the time it would take.

一般来说,我喜欢在我的数据库中存储关系数据,但想象一下,我有一个对象代表渲染网页所需的所有数据(我的意思是一切,字体,图像),它会非常复杂,存储它在一个表格结构中将真正只是为了维护我的维护问题 - 结构是流动的。它也会引起我的查询问题 - 想象一下我需要做的数字连接,以及它需要的时间。


推荐阅读
  • 本文介绍了如何使用php限制数据库插入的条数并显示每次插入数据库之间的数据数目,以及避免重复提交的方法。同时还介绍了如何限制某一个数据库用户的并发连接数,以及设置数据库的连接数和连接超时时间的方法。最后提供了一些关于浏览器在线用户数和数据库连接数量比例的参考值。 ... [详细]
  • 本文详细介绍了Linux中进程控制块PCBtask_struct结构体的结构和作用,包括进程状态、进程号、待处理信号、进程地址空间、调度标志、锁深度、基本时间片、调度策略以及内存管理信息等方面的内容。阅读本文可以更加深入地了解Linux进程管理的原理和机制。 ... [详细]
  • web.py开发web 第八章 Formalchemy 服务端验证方法
    本文介绍了在web.py开发中使用Formalchemy进行服务端表单数据验证的方法。以User表单为例,详细说明了对各字段的验证要求,包括必填、长度限制、唯一性等。同时介绍了如何自定义验证方法来实现验证唯一性和两个密码是否相等的功能。该文提供了相关代码示例。 ... [详细]
  • 本文介绍了一种轻巧方便的工具——集算器,通过使用集算器可以将文本日志变成结构化数据,然后可以使用SQL式查询。集算器利用集算语言的优点,将日志内容结构化为数据表结构,SPL支持直接对结构化的文件进行SQL查询,不再需要安装配置第三方数据库软件。本文还详细介绍了具体的实施过程。 ... [详细]
  • 安装mysqlclient失败解决办法
    本文介绍了在MAC系统中,使用django使用mysql数据库报错的解决办法。通过源码安装mysqlclient或将mysql_config添加到系统环境变量中,可以解决安装mysqlclient失败的问题。同时,还介绍了查看mysql安装路径和使配置文件生效的方法。 ... [详细]
  • 本文详细介绍了MysqlDump和mysqldump进行全库备份的相关知识,包括备份命令的使用方法、my.cnf配置文件的设置、binlog日志的位置指定、增量恢复的方式以及适用于innodb引擎和myisam引擎的备份方法。对于需要进行数据库备份的用户来说,本文提供了一些有价值的参考内容。 ... [详细]
  • 本文介绍了Oracle数据库中tnsnames.ora文件的作用和配置方法。tnsnames.ora文件在数据库启动过程中会被读取,用于解析LOCAL_LISTENER,并且与侦听无关。文章还提供了配置LOCAL_LISTENER和1522端口的示例,并展示了listener.ora文件的内容。 ... [详细]
  • 本文讨论了在数据库打开和关闭状态下,重新命名或移动数据文件和日志文件的情况。针对性能和维护原因,需要将数据库文件移动到不同的磁盘上或重新分配到新的磁盘上的情况,以及在操作系统级别移动或重命名数据文件但未在数据库层进行重命名导致报错的情况。通过三个方面进行讨论。 ... [详细]
  • 本文讨论了clone的fork与pthread_create创建线程的不同之处。进程是一个指令执行流及其执行环境,其执行环境是一个系统资源的集合。在调用系统调用fork创建一个进程时,子进程只是完全复制父进程的资源,这样得到的子进程独立于父进程,具有良好的并发性。但是二者之间的通讯需要通过专门的通讯机制,另外通过fork创建子进程系统开销很大。因此,在某些情况下,使用clone或pthread_create创建线程可能更加高效。 ... [详细]
  • MyBatis多表查询与动态SQL使用
    本文介绍了MyBatis多表查询与动态SQL的使用方法,包括一对一查询和一对多查询。同时还介绍了动态SQL的使用,包括if标签、trim标签、where标签、set标签和foreach标签的用法。文章还提供了相关的配置信息和示例代码。 ... [详细]
  • r2dbc配置多数据源
    R2dbc配置多数据源问题根据官网配置r2dbc连接mysql多数据源所遇到的问题pom配置可以参考官网,不过我这样配置会报错我并没有这样配置将以下内容添加到pom.xml文件d ... [详细]
  • 本文介绍了将mysql从5.6.15升级到5.7.15的详细步骤,包括关闭访问、备份旧库、备份权限、配置文件备份、关闭旧数据库、安装二进制、替换配置文件以及启动新数据库等操作。 ... [详细]
  • 本文介绍了在CentOS上安装Python2.7.2的详细步骤,包括下载、解压、编译和安装等操作。同时提供了一些注意事项,以及测试安装是否成功的方法。 ... [详细]
  • 海马s5近光灯能否直接更换为H7?
    本文主要介绍了海马s5车型的近光灯是否可以直接更换为H7灯泡,并提供了完整的教程下载地址。此外,还详细讲解了DSP功能函数中的数据拷贝、数据填充和浮点数转换为定点数的相关内容。 ... [详细]
  • SpringMVC接收请求参数的方式总结
    本文总结了在SpringMVC开发中处理控制器参数的各种方式,包括处理使用@RequestParam注解的参数、MultipartFile类型参数和Simple类型参数的RequestParamMethodArgumentResolver,处理@RequestBody注解的参数的RequestResponseBodyMethodProcessor,以及PathVariableMapMethodArgumentResol等子类。 ... [详细]
author-avatar
txy001美丽人生_618
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有