relational-database - 何时或在数据库中使用多对多关系?

标签 relational-database

我想知道在什么情况下我们会创建多对多关系。这样做有什么必要?

最佳答案

快速搜索大有帮助。尽管以下是针对 MS Access 的,但概念对于任何关系数据库都是相同的。

通过:office.microsoft.com - Create a many-to-many relationship :

You have a many-to-many relationship when a single record in one table can relate to many records in another, and a single record in that second table can also relate to many records in the first. For example, say your company has several types of computers and several technicians, with each technician certified to work on some, but not all, of the computers. Each technician can be related to more than one computer, and in turn, each computer can be related to more than one technician.

To track who can work on a given machine, you create a many-to-many relationship by adding the primary keys from both sides of the relationship to a third table, called a junction or link table. In other words, a many-to-many relationship is really just a pair of one-to-many relationships.



enter image description here

关于relational-database - 何时或在数据库中使用多对多关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21338554/

相关文章:

sql - 如何建立外键关系

mysql - 将 varchar 值转换为 mysql 中的主键

database-design - 你可以有2个外键而没有主键吗?

mysql - 在 mysql 中将 SUM 与多个连接一起使用

sql - 相似结构的理想数据库模式

sql - 规范化自引用属性

database - 用于记录用户操作的优雅模式

php - 构建PHP函数以检索各种mySQL数据库查询并通过外键关系正确遍历多个表

php - 使用关系 AR 检索 "OR"条件

php - 在 phpmyadmin 数据库设计器中建立关系有什么意义?