候选键有什么意义? [英] What's the point of a candidate key?

查看:27
本文介绍了候选键有什么意义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对数据库管理还很陌生,这个问题似乎永远不会超过一句话回答.所有其他 SO 答案都说候选键是最小的超级键."这对我来说毫无意义.

I'm fairly new to database management and this question never seems to be answered in more than one sentence. All other SO answers say "A candidate key is a minimal super key." That means nothing to me.

候选键应该指定数据库记录的唯一性,对吗?主键是候选键.如果主键已经指定了唯一性,那么添加更多候选键有什么意义?

A candidate key is supposed to specify uniqueness of a db record, correct? And a primary key is a candidate key. If a primary key already specifies uniqueness, what's point of adding more candidate keys?

我看到过如下示例记录:

I have seen example records like the following:

员工(ID、姓名、电话号码)

Employee(ID, Name, PhoneNumber)

其中 ID 是主键,PhoneNumber 是候选键.据我所知,ID足以指定员工记录的唯一性.尽管 PhoneNumbers(可能)是唯一的,但将它们指定为候选键对我来说似乎并不最小".

where ID is the primary key and PhoneNumber is a candidate key. From what I see, the ID is enough to specify the uniqueness of an employee record. Although PhoneNumbers are (probably) unique, specifying them as a candidate key does not seem "minimal" to me.

推荐答案

这意味着如果 PhoneNumber 确实是候选键,您可以删除 ID 列并使用 PhoneNumber 代替.换句话说,它是唯一键的候选.

It means that if PhoneNumber was indeed a candidate key you could delete the ID column and use PhoneNumber instead. In other words, it is a candidate for being a unique key.

维基百科有更多你想看的正式定义.

Wikipedia has a more formal definition that you many want to look at.

这篇关于候选键有什么意义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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