Many-to-many_(data_model)

Many-to-many (data model)

Many-to-many (data model)

Systems analysis concept


In systems analysis, a many-to-many relationship is a type of cardinality that refers to the relationship between two entities,[1] say, A and B, where A may contain a parent instance for which there are many children in B and vice versa.

An Author can write several Books, and a Book can be written by several Authors
The Author-Book many-to-many relationship as a pair of one-to-many relationships with a junction table

Data relationships

For example, think of A as Authors, and B as Books. An Author can write several Books, and a Book can be written by several Authors. In a relational database management system, such relationships are usually implemented by means of an associative table (also known as join table, junction table or 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 entity types represented by logical model database tables is sometimes referred to as a HasAndBelongsToMany (HABTM) relationship.[2]

See also


References


Share this article:

This article uses material from the Wikipedia article Many-to-many_(data_model), and is written by contributors. Text is available under a CC BY-SA 4.0 International License; additional terms may apply. Images, videos and audio are available under their respective licenses.