database design: can you mix many-to-many and many-to-one relationships?

93 Views Asked by At

Let's say I have two tables, FirstTable and SecondTable. They have a one-to-many relationship, so SecondTable have a foreign key: FirstTableID. I have to redesign the database as in (very) rare cases a SecondTable entity can belong to more (usually 2-3) FirstTable entities too, so that is obviously a many-many relationship.

My question is: the many-to-many relationship can occur very rarely (we sell more copies of the system, and in most copies they always have a one-to-many relationship, guaranteed). Would it be a wise move to keep the foreign key, and to check in the system if its value is 0, then the system would search a relation in the many-many table? We could avoid having an entire redundant table this way, for most cases. But would it violate some database design principle?

1

There are 1 best solutions below

0
On BEST ANSWER

You might avoid a mostly redundant table, but you'll probably end up with a bunch of redundant code instead, two versions of each. I'd keep the design consistent, and avoid having to consider the two alternate cases every time you need to change something.