locked
Many-to-many relation can be establish without 3rd table RRS feed

  • Question

  • User264732274 posted

    if possible to establish Many-to-many relation between two table without 3rd table then please show with example. thanks

    Friday, September 16, 2016 1:58 PM

Answers

  • User-2057865890 posted

    Hi sudip_inn,

    A many-to-many relationship consists of three tables. Below is a schematic view of the many-to-many relationship.

    In some cases, you may need multiple instances on both sides of the relationship. For example, each order can contain multiple items. And each item can also be in multiple orders.

    For these relationships, we need to create an extra table:

    The Items_Orders table has only one purpose, and that is to create a "Many to Many" relationship between the items and the orders.

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 19, 2016 8:22 AM

All replies

  • User-2057865890 posted

    Hi sudip_inn,

    A many-to-many relationship consists of three tables. Below is a schematic view of the many-to-many relationship.

    In some cases, you may need multiple instances on both sides of the relationship. For example, each order can contain multiple items. And each item can also be in multiple orders.

    For these relationships, we need to create an extra table:

    The Items_Orders table has only one purpose, and that is to create a "Many to Many" relationship between the items and the orders.

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 19, 2016 8:22 AM
  • User-821857111 posted

    if possible to establish Many-to-many relation between two table without 3rd table
    It's not possible.

    Monday, September 19, 2016 8:26 AM
  • User-1404113929 posted

    hi,

    you can create structure many to many relation using 2 tables but, you can not insert data into those tables.

    create table table1(col1 int primary key,col2 int unique);
    create table table2(col2 int primary key,col1 int unique references table1(col1));
    alter table table1 ADD FOREIGN KEY(col2) references table2(col2)

    thanks,

    murali;

    Monday, September 19, 2016 9:24 AM