什么是mysql中的组合外键? [英] What is a composite foreign key in mysql?

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

问题描述

在我正在使用的框架的文档中看到这个术语(复合外键)(yii)。什么是复合外键(在mySql数据库中)?



我的猜测是,如果给定两个表之间的关系,则一个表的列与另一个表的id具有完全相同的名称。 )



*免责声明:我进行了尽职调查并使用Google搜索了整整两分钟,但没有发现任何定义的术语定义。

解决方案

组合键 多个属性唯一标识一个实体 发生。这与复合键的不同之处在于组成键的一个或多个属性本身不是简单的键。

例如,你有一个拥有CD收藏的数据库。其中一个实体称为轨道,它保存CD上轨道的细节。这有CD名称,曲目号码的组合键。




轨道实体中的CD名称是一个简单的键,链接到CD实体,但轨道号不是它自己的简单键正确。


Seeing this term (composite foreign key) in the documentation for a framework I am using (yii). What is a composite foreign key (in a mySql database)?

(My guess is that, given a relationship between two tables, one table has a column with the exact same name as the id the other table.)

*Disclaimer: I did my due diligence and Googled this for like two whole minutes but found no conclusive definition for the term..

解决方案

A composite key consists of more than one attribute to uniquely identify an entity occurrence. This differs from a compound key in that one or more of the attributes, which make up the key, are not simple keys in their own right.

For example, you have a database holding your CD collection. One of the entities is called tracks, which holds details of the tracks on a CD. This has a composite key of CD name, track number.

CD name in the track entity is a simple key, linking to the CD entity, but track number is not a simple key in its own right.

这篇关于什么是mysql中的组合外键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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