Home > Software design >  Is it a bad practice to have two one-to-one relationships between the same tables?
Is it a bad practice to have two one-to-one relationships between the same tables?

Time:12-15

I'm designing a database and found myself in the situation described bellow. I feel like it may be a bad practice, at the same time I can't find a reason why it would be bad, aside from it looks "weird". I have limited experience in the field.

I have two tables proceedings and reports. Proceedings store all proceedings related data and it has a relationship with reports, as every proceeding has one report (1:1).

A few reports (this is sparse) contains references to a related proceeding, a report never contains more than one related proceeding, its either 1 or 0, making it another one-to-one relationship.

How it is

Is this considered a bad practice? If yes, can you explain what kind of problem it could cause?

CodePudding user response:

This looks like a standard database design practice to me. Just because records in two separate tables have a 1:1 relationship, doesn't mean the tables need to be merged. There may be good reasons to keep them separate, and such separation shouldn't seriously hinder well-written database queries. This type of database schema is usually what is implied by the term relational database (RDB) - see this link for more info.

The important part is that the related records in separate tables are identified using an ID which is also an indexed key (likely the primary key), for performance reasons during JOIN queries.

  • Related