I was following a discussion on a forum where they have posted a question like this--> enter image description here

Some people are saying that we can merge A,B,C in a single table and m:n relation of A and C in another table having foreign key. Thus 2 tables are required. Where as another person is saying that A,B,C cannot be merged as if we merge A,B,C then it means that the A and C sharing the same row must have relation. So we need at-least 3 tables, one for AB another for BC and another one for AC. So which is correct? 2 tables or 3 tables. I am pretty much confused with this.


The issue is that it cannot really be answered unless you give more constraints.

It can be implemented using only one table. Ugly but doable. Each record would be the union o fields needed plus one “type” field. There will be very little of help from the database in keeping referential integritet.

| cite | improve this answer | |
  • $\begingroup$ If we do it using only 1 table then A and C of the same row must relate to each other,which is not the case here as A and C has m:n relation....so how can we do it using 1 table? $\endgroup$ – Turing101 Sep 18 '19 at 7:12
  • $\begingroup$ The point is that it will be ugly. Each record will have two references. Let us call them left and right. The record will have a type field with values A,B,C,R1,R2,R3. Add all Fields in A,B andC. The rest is up to the programmet. It will allow all kinds of weird ettors. $\endgroup$ – ghellquist Sep 18 '19 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.