HOME

TheInfoList



OR:

In
systems analysis Systems analysis is "the process of studying a procedure or business to identify its goal and purposes and create systems and procedures that will efficiently achieve them". Another view sees system analysis as a problem-solving technique tha ...
, a many-to-many relationship is a type of
cardinality In mathematics, the cardinality of a set is a measure of the number of elements of the set. For example, the set A = \ contains 3 elements, and therefore A has a cardinality of 3. Beginning in the late 19th century, this concept was generalized ...
that refers to the relationship between two
entities An entity is something that exists as itself, as a subject or as an object, actually or potentially, concretely or abstractly, physically or not. It need not be of material existence. In particular, abstractions and legal fictions are usually r ...
, say, A and B, where A may contain a
parent A parent is a caregiver of the offspring in their own species. In humans, a parent is the caretaker of a child (where "child" refers to offspring, not necessarily age). A ''biological parent'' is a person whose gamete resulted in a child, a male ...
instance for which there are many children in B and vice versa. 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 A relational database is a (most commonly digital) database based on the relational model of data, as proposed by E. F. Codd in 1970. A system used to maintain relational databases is a relational database management system (RDBMS). Many relati ...
, 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 In the relational model of databases, a primary key is a ''specific choice'' of a ''minimal'' set of attributes (columns) that uniquely specify a tuple (row) in a relation ( table). Informally, a primary key is "which attributes identify a record ...
for AB is formed from the two
foreign key A foreign key is a set of attributes in a table that refers to the primary key of another table. The foreign key links these two tables. Another way to put it: In the context of relational databases, a foreign key is a set of attributes subject to ...
s (i.e. copies of the
primary key In the relational model of databases, a primary key is a ''specific choice'' of a ''minimal'' set of attributes (columns) that uniquely specify a tuple (row) in a relation ( table). Informally, a primary key is "which attributes identify a record ...
s of A and B). In web application frameworks such as CakePHP and
Ruby on Rails Ruby on Rails (simplified as Rails) is a server-side web application framework written in Ruby under the MIT License. Rails is a model–view–controller (MVC) framework, providing default structures for a database, a web service, and web ...
, a many-to-many relationship between entity types represented by logical model database tables is sometimes referred to as a HasAndBelongsToMany (HABTM) relationship.3.7.6.5 hasAndBelongsToMany (HABTM)
{{webarchive, url=https://web.archive.org/web/20120815165131/http://book.cakephp.org/1.3/view/1044/hasAndBelongsToMany-HABTM , date=2012-08-15 . Cakephp.org


See also

* Associative entity * One-to-one (data model) * One-to-many (data model)


References

Data modeling