超级键和候选键之间有什么区别? [英] What are the differences between a superkey and a candidate key?

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

问题描述

超级键和候选键之间有什么区别?
我已经参考wiki,dotnet蜘蛛和数据库概念第4版的书。但我不能理解的概念。任何人都可以用适当的例子解释它。

解决方案

候选键

例如,一个软件版本可以通过以下方式识别:a。超级密钥主要/次要版本或建立日期(我们假设每晚构建)。



在三个字段中存储日期不是一个好主意,但让我们假装用于演示目的:

 年月日主要未成年人
2008 01 13 0 1
2008 04 23 0 2
2009 11 05 1 0
2010 04 05 1 1

code>(年,主要,次要)或(年,月,日期,主要) )而不是候选键,因为您可以删除 year major ,剩余的列集合将仍然是超级键。



(年,月,日) / code>是候选键,因为您不能从中删除任何字段,而不会破坏唯一性。


What are the differences between a super key and a candidate key? I have already referred to wiki,dotnet spider and also Database Concepts 4th edition book. But I am unable to understand the concept. Can anyone please explain it with proper example?

解决方案

Candidate key is a super key from which you cannot remove any fields.

For instance, a software release can be identified either by major/minor version, or by the build date (we assume nightly builds).

Storing date in three fields is not a good idea of course, but let's pretend it is for demonstration purposes:

year  month date  major  minor
2008  01    13     0      1
2008  04    23     0      2
2009  11    05     1      0
2010  04    05     1      1

So (year, major, minor) or (year, month, date, major) are super keys (since they are unique) but not candidate keys, since you can remove year or major and the remaining set of columns will still be a super key.

(year, month, date) and (major, minor) are candidate keys, since you cannot remove any of the fields from them without breaking uniqueness.

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

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