M:N relationship without a junction table

370 Views Asked by At

Given two tables Student(id,name) and course(course_id,course_name). These two tables have a M:N relationship.

  • Is there any way to implement a M:N relationship in relational database without using a junction table?
  • If not in relational database then in any other database model?
1

There are 1 best solutions below

0
On

Is there any way to implement a M:N relationship in relational database without using a junction table?

Sure, just store an array of "pointers"1 in one of the tables. You can use either an array type natively supported by your DBMS, or encode it in VARCHAR.

However, this will horribly denormalize you database (you'll be violating the 1NF), and I can't imagine why would anybody do that in practice.

Is there any specific reason you want to avoid a junction table?


1 Values of the key in the other table.