什么是mysql中的组合外键? [英] What is a composite foreign key in mysql?
问题描述
在我正在使用的框架的文档中看到这个术语(复合外键)(yii)。什么是复合外键(在mySql数据库中)?
(我的猜测是,如果给定两个表之间的关系,则一个表的列与另一个表的id具有完全相同的名称。 )
*免责声明:我进行了尽职调查并使用Google搜索了整整两分钟,但没有发现任何定义的术语定义。
组合键
由 多个属性唯一标识一个实体 发生。这与复合键的不同之处在于组成键的一个或多个属性本身不是简单的键。
轨道实体中的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屋!