oracle中dbms_如何在DBMS中找到关系的最高范式?

oracle中dbms

To find the highest normal form of a relation, you have to first understand the basics of Functional dependency, Candidate keys, and Normal Forms.

查找关系的最高范式 ,您必须首先了解功能依赖项 ,候选键和范式的基础。

In relation, a Functional Dependency P holds Q (P->Q) if two tuples having similar values of attributes for P also have similar values of attributes for Q i.e. P distinctively decides Q.

相对地,如果具有相似属性值P的两个元组也具有相似属性值Q,P独特地决定Q ,则功能相关性P保持Q(P-> Q)

In a Database, Functional dependency performs assistance as a restriction between two sets of attributes.

在数据库中,功能依赖项作为辅助功能来限制两组属性。

A Candidate Key in a relation is a minimal set of attributes of which can be used to identify a tuple distinctively. A candidate key is a column or set of columns in a table or relation that can distinctly identify any database collection of record without indicating towards any other data. Each table may contain one or more candidate keys, but one candidate key is distinct in each table or relation, and it is called the primary key. The primary key is the best among the candidate keys which is usually used for identification.

关系中的候选关键字是属性的最小集合,可用于区别性地标识元组。 候选键是表或关系中的一列或一组列,它们可以清楚地标识记录的任何数据库集合,而无需指示其他任何数据。 每个表可以包含一个或多个候选键,但是一个候选键在每个表或关系中都不同,因此称为主键。 主密钥是通常用于标识的候选密钥中最好的。

The process of Normalization is to minimize redundancy from a database table or relation or a set of relations. Insertion, Deletion and Updation anomalies may cause by redundancy. So, it aids to reduce the redundancy in relations.

规范化的过程是最小化数据库表或关系或一组关系的冗余。 插入,删除和更新异常可能是由冗余引起的。 因此,它有助于减少关系中的冗余。

Normal forms are used to eliminate or minimize redundancy in database tables or relations. These Normal Forms are:

范式用于消除或最小化数据库表或关系中的冗余。 这些范式为:

  1. First Normal Form

    第一范式

  2. Second Normal Form

    第二范式

  3. Third Normal Form

    第三范式

  4. Boyce-Codd Normal Form (BCNF)

    博伊斯·科德范式(BCNF)

Steps to follow to find the highest normal form of a relation

查找关系的最高范式的步骤

  1. The first step is to find all feasible candidate keys of the relation and its attributes.

    第一步是找到该关系及其属性的所有可行候选键。

  2. The second step is to organize into two categories all the attributes of the relation:

    第二步是将关系的所有属性分为两类:

    1. Prime attributes
    2. Non-prime attributes
  3. Third and the last step is to examine to determine for 1st normal form and then 2nd and so on. If the process is unsuccessful in satisfying nth normal form condition, then the highest normal form will be n-1.

    第三步也是最后一步是检查确定第一个范式,然后确定第二个,依此类推。 如果该过程不能满足第n个范式条件,则最高范式将为n-1。

例子 (Examples)

Problem 1) Find the highest normal form of a relation R(P, Q, R, S, T) with Functional dependency set as (QR->S, PR->QT, Q->T).

问题1)找到功能依赖项设置为(QR-> S,PR-> QT,Q-> T)的关系R(P,Q,R,S,T)的最高范式。

Solution:

解:

Step 1:

第1步:

As the relation (PR)+ = (P, Q, R, S, T) is given, but not a single of its subset can determine all attributes of relation, So PR will be candidate key. P or R can’t be derived from any other attribute of the relation, so there will be only one candidate key (PR).

由于给出了关系(PR)+ =(P,Q,R,S,T),但没有一个子集可以确定关系的所有属性,因此PR将成为候选关键字。 P或R不能从关系的任何其他属性派生,因此将只有一个候选键(PR)。

Step 2:

第2步:

  1. The attributes which are part of candidate key (P, R) are Prime attributes.

    属于候选键(P,R)的属性是素数属性。

  2. The others will be non-prime attributes (Q, R, S).

    其他将是非素数属性(Q,R,S)。

Step 3:

第三步:

A Relational Database Management System does not enable multi-valued or composite attribute. So, the relation R(P, Q, R, S, T) is in 1st normal form.

关系数据库管理系统不启用多值或复合属性。 因此,关系R(P,Q,R,S,T)为第一范式。

Because QR->S is in 2nd normal form (QR is not a proper subset of candidate key PR) and PR->QT is in 2nd normal form (PR is candidate key) and Q->T is in 2nd normal form (Q is not a proper subset of candidate key PR).So, the relation is in 2nd normal form.

因为QR-> S为第二范式(QR不是候选关键字PR的适当子集),而PR-> QT为第二范式(PR为候选关键字),而Q-> T为第二范式(Q不是候选密钥PR的适当子集)。因此,该关系为第二范式。

Because in QR->S (neither QR is a super key nor S is a prime attribute) and in Q->T (neither Q is a super key nor T is a prime attribute) but to satisfy 3rd normal form, either LHS of a Functional Dependency should be super key or RHS should be prime attribute. So, the relation is not in 3rd normal form.

因为在QR-> S中(QR既不是超键也不是S是素数属性),而在Q-> T中(Q既不是超键也不是T是素数属性)但是要满足第三范式,所以LHS功能依赖关系应该是超级键,RHS应该是主要属性。 因此,该关系不是第三范式。

So, the highest normal form of relation will be 2nd Normal form.

因此,关系的最高范式将是第二范式。

Problem 2) Find the highest normal form of a relation R (P, Q, R, S, T) with Functional Dependency set (Q->P, P->R, QR->S, PR->QT).

问题2)找到具有功能相关性集(Q-> P,P-> R,QR-> S,PR-> QT)的关系R(P,Q,R,S,T)的最高范式。

Solution:

解:

Step 1:

第1步:

As the relation (PR) + = (P, Q, R, S, T) is given, Q will be a candidate key. Q can be derived from PR using PR->Q (Decomposing PR->QT to PR->Q and PR->T). So PR will be super key but (R) + ={R} and (P) + = {P, R, Q, S, T}. So P (subset of PR) will be a candidate key.

由于关系(PR)+ =(P,Q,R,S,T),Q将成为候选关键字。 可以使用PR-> Q(将PR-> QT分解为PR-> Q和PR-> T)从PR导出Q。 因此PR将是超级键,但(R)+ = {R}和(P)+ = {P,R,Q,S,T}。 因此,P(PR的子集)将成为候选关键字。

So there will be two candidate keys {P, Q}.

因此将有两个候选键{P,Q}。

Step 2:

第2步:

  1. The attributes which are part of candidate key (P, Q) are Prime attributes.

    属于候选键(P,Q)的属性是素数属性。

  2. The others will be non-prime attributes (R, S, T).

    其他将是非素数属性(R,S,T)。

Step 3:

第三步:

A Relational Database Management System does not enable multi-valued or composite attribute. So, the relation R (P, Q, R, S, T) is in 1st normal form.

关系数据库管理系统不启用多值或复合属性。 因此,关系R(P,Q,R,S,T)处于第一范式。

The relation is in 2nd normal form because Q->P is in 2nd normal form (Q is a super key) and P->R is in 2nd normal form (P is super key) and QR->S is in 2nd normal form (QR is a super key) and PR->QT is in 2nd normal form (PR is a super key).

该关系为第二范式,因为Q-> P为第二范式(Q为超级键),而P-> R为第二范式(P为超级键),而QR-> S为第二范式。 (QR是超级键),PR-> QT为第二范式(PR是超级键)。

Because LHS of all Functional Dependencies are super keys, the relation is in 3rd normal form.

因为所有功能依赖项的LHS都是超键,所以该关系为第三范式。

The relation is in BCNF as all LHS of all Functional Dependencies are super keys.

该关系在BCNF中,因为所有功能依赖项的所有LHS都是超级键。

So, the highest normal form is BCNF.

因此,最高范式是BCNF。

Problem 3) Find the highest normal form of a relation R (P, Q, R, S, T) with Functional Dependency set (P->S, Q->P, QR->S, PR->QT).

问题3)找到具有功能相关性集(P-> S,Q-> P,QR-> S,PR-> QT)的关系R(P,Q,R,S,T)的最高范式。

Solution:

解:

Step 1:

第1步:

As the relation (PR) + = (P, Q, R, S, T) is given, but not a single of its subset can determine all attributes of relation, so PR will be candidate key. P can be derived from Q, so we can replace P in PR by Q. So QR will also be a candidate key.

由于给出了关系(PR)+ =(P,Q,R,S,T),但是没有一个子集可以确定关系的所有属性,因此PR将成为候选关键字。 P可以从Q派生,所以我们可以用Q代替PR中的P。因此QR也是候选关键字。

So the two candidate keys will be (PR, QR).

因此,两个候选键将是(PR,QR)。

Step 2:

第2步:

  1. The attributes which are part of candidate key (P, Q, R) are Prime attributes.

    属于候选键(P,Q,R)的属性是素数属性。

  2. The others will be non-prime attributes (S, T).

    其他将是非素数属性(S,T)。

Step 3:

第三步:

A Relational Database Management System does not enable multi-valued or composite attribute. So, the relation R (P, Q, R, S, T) is in 1st normal form.

关系数据库管理系统不启用多值或复合属性。 因此,关系R(P,Q,R,S,T)处于第一范式。

Because P->S is partial dependency (P which is a subset of candidate key PR is determining non-prime attribute S), the relation is not in 2nd Normal form because the 2nd normal form does not enable partial dependency.

因为P-> S是部分依赖关系(作为候选键PR的子集的P正在确定非主要属性S),所以该关系不是第二范式,因为第二范式不允许部分依赖。

So, the highest normal form will be 1st Normal Form.

因此,最高范式将是第一范式。

翻译自: https://www.includehelp.com/dbms/how-to-find-the-highest-normal-form-of-a-relation.aspx

oracle中dbms

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值