Many-to-many (data model)

From Wikipedia, the free encyclopedia
An Author can write several Books, and a Book can be written by several Authors

In systems analysis, a many-to-many relationship is a type of cardinality that refers to the relationship between two entities (see also entity–relationship model) A and B in which A may contain a parent row[clarify] for which there are many children[clarify] in B and vice versa. For instance, think of A as Authors, and B as Books. An Author can write several Books, and a Book can be written by several Authors. Because most database management systems only support one-to-many relationships, it is necessary to implement such relationships physically via a third junction table (also called cross-reference table), say, AB with two one-to-many relationships A -> AB and B -> AB. In this case the logical primary key for AB is formed from the two foreign keys (i.e. copies of the primary keys of A and B).

In web application frameworks such as CakePHP and Ruby on Rails, a many-to-many relationship between database tables in a model is sometimes referred to as a HasAndBelongsToMany (HABTM) relationship.[1]

See also

  • Associative Entities

References

  1. ↑ 3.7.6.5 hasAndBelongsToMany (HABTM). Cakephp.org

External links

This article is issued from Wikipedia. The text is available under the Creative Commons Attribution/Share Alike; additional terms may apply for the media files.