Many to many relation

Basic database relations:

Many to many relation definition:

Relation many to many exist when one value from first database entitiy (table) can be assigned to many values from second entitiy (table) in this databse and one value from second entitiy can be assigned to many values from first entitiy.

Many to many relation example:

Let’s take some example shop database which contains 3 entities: Sellers (this table shows data about shop sales staff), Customers (Customers table contains data about people who bought some products in our shop) and Transactions (Transactions table presents which seller made a transacion with a specific customer).

Also we suppose that one seller can make a transaction  with more than one customer and one customer can make  transactions  with more than one seller.

Many to many relation

Thanks to Transactions table (each seller  and each customer can be assigned to many (more than one) transactions), between Sellers and Customers tables exist many to many relation because one seller can be assigned to more than one (many) customers and one customer can be assignd to more than one (many) sellers.

Many to many relation

In the above example, seller Susan Smith made transactions with 2 customers: James Walker and John Dudley (ID_TRANSACTION values: C102, C104). Customer James Walker made transactions with Susan Smith and one more seller – Kate Anderson  (ID_TRANSACTION value: C105).

Copyright © 2015-2016 • All Rights Reserved •