Should you ever have one-to-one relationships between entities?

One-to-one relationships occasionally evolve into one-to-many relationships. Once that happens, your team has a tricky job of refactoring the datastore, the backend to allow that change. For example, some time ago, our app used to have one-to-one relationships between doctors and wards. But doctors are not always paid handsomely, some double in other wards. So now we have a one-to-many relationship between doctors and wards. An additional problem is DOCTOR still, to this day, has columns linking it to wards and positions (for example, a surgeon in a surgery ward). The resulting inconsistency has led to some bugs. So should you have one-to-one relationships between entities at all? Maybe, you should always, 100% of the time, model entity relationships as one-to-many, shouldn't you? One-to-one may be seen simply as a special case of one-to-many. The assumption "Oh, there's no way this would ever become one-to-many" has failed so many times, it's dangerous and has no significant benefits (performance my **s). Am I wrong?

May 6, 2025 - 12:11
 0

One-to-one relationships occasionally evolve into one-to-many relationships. Once that happens, your team has a tricky job of refactoring the datastore, the backend to allow that change.

For example, some time ago, our app used to have one-to-one relationships between doctors and wards. But doctors are not always paid handsomely, some double in other wards. So now we have a one-to-many relationship between doctors and wards. An additional problem is DOCTOR still, to this day, has columns linking it to wards and positions (for example, a surgeon in a surgery ward). The resulting inconsistency has led to some bugs.

So should you have one-to-one relationships between entities at all?

Maybe, you should always, 100% of the time, model entity relationships as one-to-many, shouldn't you? One-to-one may be seen simply as a special case of one-to-many. The assumption "Oh, there's no way this would ever become one-to-many" has failed so many times, it's dangerous and has no significant benefits (performance my **s). Am I wrong?