密钥,超级密钥,最小超级密钥,候选密钥和主密钥之间的差异 [英] Differences between key, superkey, minimal superkey, candidate key and primary key

查看:689
本文介绍了密钥,超级密钥,最小超级密钥,候选密钥和主密钥之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是MySQL的新手,我对遇到的不同术语感到非常困惑.我尝试使用谷歌搜索答案,但结果确实令人困惑,当我尝试理解它时,好像它们是同一回事.

I'm new to MySQL, and I'm really confused about the different terms that I've encountered. I tried googling the answer but the results are really confusing and when I try and understand it just seems like they are the same thing.

键,超级键,最小超键,候选键和主键之间到底有什么区别?

What exactly are the differences among key, superkey, minimal superkey, candidate key and primary key?

推荐答案

在这里我复制粘贴一些我收集的信息

密钥是单个或多个字段的组合.其目的是根据需要访问或检索表中的数据行.在表中定义了键,以便快速,平稳地访问或排序存储的数据.它们还用于在不同表之间创建链接.

Key A key is a single or combination of multiple fields. Its purpose is to access or retrieve data rows from table according to the requirement. The keys are defined in tables to access or sequence the stored data quickly and smoothly. They are also used to create links between different tables.

键的类型

主键 可以唯一标识关系中的行或记录的属性或属性组合称为主键.

Primary Key The attribute or combination of attributes that uniquely identifies a row or record in a relation is known as primary key.

辅助键 作为检索基础的字段或字段组合称为辅助密钥.次要键是一个非唯一字段.一个辅助键值可能引用许多记录.

Secondary key A field or combination of fields that is basis for retrieval is known as secondary key. Secondary key is a non-unique field. One secondary key value may refer to many records.

候选键或备用键 关系只能有一个主键.它可能包含许多可用作主键的字段或字段组合.一个字段或字段的组合用作主键.不用作主键的字段或字段组合称为候选键或备用键.

Candidate Key or Alternate key A relation can have only one primary key. It may contain many fields or combination of fields that can be used as primary key. One field or combination of fields is used as primary key. The fields or combination of fields that are not used as primary key are known as candidate key or alternate key.

复合键或连接键 由两个或多个属性组成的主键称为复合键.

Composite key or concatenate key A primary key that consists of two or more attributes is known as composite key.

排序或控制键 用于对存储的数据进行物理排序的字段或字段组合,称为排序关键字.也称为控制键.

Sort Or control key A field or combination of fields that is used to physically sequence the stored data called sort key. It is also known s control key.

超级键是可以唯一地用于标识数据库记录的属性的组合.一个表可能有许多超级键.候选键是超级键的特殊子集,其中没有任何多余的信息.

A superkey is a combination of attributes that can be uniquely used to identify a database record. A table might have many superkeys. Candidate keys are a special subset of superkeys that do not have any extraneous information in them.

超级键示例: 想象一个具有字段<Name><Age><SSN><Phone Extension>的表.该表有许多可能的超级键.其中的三个是<SSN><Phone Extension, Name><SSN, Name>.在列出的那些记录中,只有<SSN>是候选键,因为其他记录包含唯一标识记录所不需要的信息.

Example for super key: Imagine a table with the fields <Name>, <Age>, <SSN> and <Phone Extension>. This table has many possible superkeys. Three of these are <SSN>, <Phone Extension, Name> and <SSN, Name>. Of those listed, only <SSN> is a candidate key, as the others contain information not necessary to uniquely identify records.

外键 外键是关系中属性的值或属性的组合,其值与另一个关系中的主键匹配.在其中创建外键的表称为从属表.引用外键的表称为父表.

Foreign Key A foreign key is an attribute or combination of attribute in a relation whose value match a primary key in another relation. The table in which foreign key is created is called as dependent table. The table to which foreign key is refers is known as parent table.

这篇关于密钥,超级密钥,最小超级密钥,候选密钥和主密钥之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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