在关系数据库中存储 XML 会如何违反规范化原则? [英] How would storing XML in a relational database violate Normalization Principles?

查看:76
本文介绍了在关系数据库中存储 XML 会如何违反规范化原则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在本书中:Regina Obe &Leo Hsu, PostgreSQL Up &跑步,第.101.它是作为对 PostgreSQL XML 数据类型的介绍而编写的:

In this book: Regina Obe & Leo Hsu, PostgreSQL Up & Running, p. 101. It is written as an introduction to PostgreSQL XML data-type:

XML 数据类型,类似于 JSON,在关系型中是有争议的"数据库,因为它违反了规范化原则.

The XML data type, similar to JSON, is "controversial" in a relational database because it violates principles of normalization.

不做进一步解释.有人可以详细说明什么是规范化原则以及为什么 XML 确实违反了其中一些原则.

Without further explanation. Could someone detail what is normalization principles and why XML does violate some of those principles.

推荐答案

在书籍和网络上有很多关于关系数据库规范化的教程.参见例如 https://en.wikipedia.org/wiki/Database_normalization

There are many tutorials on relational database normalization in books and on the web. See for example https://en.wikipedia.org/wiki/Database_normalization

第一个范式表示列应该只包含原子"或不可分割"的值——如果你过于严格地解释它意味着你甚至不允许存储日期.将 XML 文档存储在列中肯定违背了该原则.这并不意味着这样做一定是件坏事,只是您需要了解后果(这通常意味着更新数据库并保持一致会更加困难).

First normal form says that a column should contain only "atomic" or "indivisible" values - which if you interpret it over-strictly means you're not even allowed to store a date. Storing an XML document in a column certainly goes against that principle. Which doesn't mean it's necessarily a bad thing to do, just that you need to be aware of the consequences (which generally means that updating the database and keeping it consistent is going to be more difficult).

这篇关于在关系数据库中存储 XML 会如何违反规范化原则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆