SQL 什么是数据库关闭?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6324375/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 10:56:53  来源:igfitidea点击:

What is a database closure?

sqldatabaseclosures

提问by codeObserver

I came across this term called database closure.

我遇到了一个叫做数据库关闭的术语。

I tried to look for it and what exactly it means but I have not found any simple explanation.

我试图寻找它以及它究竟意味着什么,但我没有找到任何简单的解释。

Can someone please explain what the concept of closure is and specifically what is a database closure, if it is good /bad, how it can be used or avoided ?

有人可以解释一下闭包的概念是什么,特别是什么是数据库闭包,如果它是好的/坏的,如何使用或避免它?

Also seems like there is in general a closure term: http://en.wikipedia.org/wiki/Closure_%28computer_science%29which relates to binding of variables to function. Is a database closure related to this ?

似乎还有一个封闭术语:http: //en.wikipedia.org/wiki/Closure_%28computer_science%29,它与变量与函数的绑定有关。数据库关闭是否与此有关?

Thanks!

谢谢!

回答by tushar747

Closure is actually a relatively simple concept. When designing databases we want to know that our database tables have as little redundancy as possible. This means making sure that we can have as little relationships between sets (or tables) as possible.

闭包其实是一个比较简单的概念。在设计数据库时,我们想知道我们的数据库表有尽可能少的冗余。这意味着确保我们可以在集合(或表)之间建立尽可能少的关系。

An example:

一个例子:

If we have two sets X and Y (which you can think of as two tables called X and Y) and they have a relationship with each other as so: X -> Y (Read this as Y is dependent on X)

如果我们有两个集合 X 和 Y(您可以将它们视为两个名为 X 和 Y 的表)并且它们彼此之间具有如下关系:X -> Y(将其理解为 Y 依赖于 X)

And we have another set Z which is dependent on Y: Y -> Z (also read as Y determines Z)

我们还有另一个依赖于 Y 的集合 Z:Y -> Z(也读作 Y 决定 Z)

To find the closure we find the minimum number of tables that we can reach all relationships with. In this case all we need is X.

为了找到闭包,我们找到了可以达到所有关系的最小表数。在这种情况下,我们只需要 X。

So now, when we design our database we know that we only have to have a relationship from X, and Z and Y can actually be derived from X. We can therefore make sure there are no extra relationships in our database which cause redundancy.

所以现在,当我们设计我们的数据库时,我们知道我们只需要有一个来自 X 的关系,而 Z 和 Y 实际上可以从 X 派生出来。因此我们可以确保我们的数据库中没有导致冗余的额外关系。

If you want to read more, closure is a part of a topic called normalisation.

如果您想阅读更多内容,闭包是称为规范化的主题的一部分。

回答by Chains

Closure is mentioned in database theory / set theory discussions -- as in, Dr. Codd / design & normalization kind of stuff. It has to do with finding the minimally representational elements of sets (i.e., without redundancy, etc.). I tried reading-up on it a long time ago, but my eyes went crossed, and I got a really bad headache.

在数据库理论/集合论的讨论中提到了闭包——比如 Codd 博士/设计和规范化之类的东西。它与寻找集合的最小表示元素有关(即,没有冗余等)。很久以前我尝试阅读它,但我的眼睛交叉了,我的头痛非常严重。

If you want to read a decent summary of closure, here is one: http://www.cs.sfu.ca/CC/354/jpei/slides/ClosureDecomposition.pdf

如果你想阅读一个体面的闭包总结,这里有一个:http: //www.cs.sfu.ca/CC/354/jpei/slides/ClosureDecomposition.pdf

回答by Lena Bilous

All operations are performed on an entire relation and result in an entire relation, a concept known as closure. And that is one of relational database systems characteristics

所有操作都在一个完整的关系上执行并产生一个完整的关系,这个概念称为闭包。这是关系数据库系统的特征之一

回答by Ulad Kasach

If we are referring to Closure in the Functional Dependency sense (relating to database design),

如果我们指的是功能依赖意义上的闭包(与数据库设计有关),

The closure of a set F of functional dependencies is the set of all functional dependencies logically implied by F.

函数依赖集 F 的闭包是 F 逻辑隐含的所有函数依赖的集合。

The minimal representation of sets is referred to as the canonical cover: the irreducible set of FD's that describe the closure.

集合的最小表示被称为规范覆盖:描述闭包的 FD 的不可约集合。

回答by Adam Rosenthal

The closure is essentially the full set of attributes that can be determined from a set of known attributes, for a given database, using its functional dependencies.

闭包本质上是完整的属性集,对于给定的数据库,可以使用其功能依赖性从一组已知属性中确定。

Formal math definition:

正式的数学定义:

Given a set of functional dependencies, F, and a set of attributes X. The closure is defined to be the set of attributes Y such that X -> Y follows from F.

给定一组函数依赖 F 和一组属性 X。闭包被定义为一组属性 Y,使得 X -> Y 跟随 F。

Algorithm definition:

算法定义:

Closure(X, F)
1  INITIALIZE V:= X
2  WHILE there is a Y -> Z in F such that:
   - Y is contained in V and
   - Z is not contained in V
3       DO add Z to V
4  RETURN V
Closure(X, F)
1  INITIALIZE V:= X
2  WHILE there is a Y -> Z in F such that:
   - Y is contained in V and
   - Z is not contained in V
3       DO add Z to V
4  RETURN V

It can be shown that the two definition coincide.

可以证明这两个定义是一致的。

A database closure might refer to the closure of all of the database attributes. According to the definitions above, this closure would be the set of all attributes of the database itself.

数据库关闭可能是指所有数据库属性的关闭。根据上面的定义,这个闭包是数据库本身所有属性的集合。

The closure (computer science) term that you linked to is not related to closure in databases but the mathematical closureis.

您链接到的闭包(计算机科学)术语与数据库中的闭包无关,但与数学闭包相关

For a better understanding of functional dependencies and a simple example for closure in databases I suggest reading this.

为了更好地理解函数依赖关系和数据库中闭包的简单示例,我建议阅读本文