Relational DB: Examples of When 1:1 Should be Kept Seperate versus Together

Click For Summary

Discussion Overview

The discussion revolves around the best practices for managing one-to-one (1:1) relationships in relational databases (RDB). Participants explore when it is appropriate to merge two entities into a single entity versus keeping them separate, considering various contexts and implications such as data access, security, and performance.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants suggest that merging entities E1 and E2 should be the default unless there is a compelling reason to keep them separate, such as access restrictions to sensitive information like Social Security Numbers.
  • One participant raises the idea that the unchangeable nature of a 1:1 relationship should be considered, using the example of a shipping address that might need to accommodate more than one address in the future.
  • Another example provided involves a music collection database, where the relationship between albums and tracks is clarified as a one-to-many relationship, questioning its relevance to the 1:1 discussion.
  • A participant proposes a hypothetical scenario involving a Customer table linked to either a National or International shipping table, highlighting the different information contained in each but only one set of shipping information connected to each customer.
  • Technical characteristics of data, such as separating digital images from regular tables, are mentioned as a reason for maintaining separate entities, particularly in medical data systems.
  • Security concerns are highlighted as a classic reason to separate 1:1 data, allowing different access control levels for sensitive information.
  • Efficiency considerations are discussed, including the potential for infrequently accessed data to be stored separately to improve access speed.
  • Participants mention the need for independent updates to attributes of the same entity as a reason for separation, emphasizing the importance of avoiding lock failures in large systems.
  • Historical values and performance considerations are also noted as reasons for separating attributes within a 1:1 relationship.

Areas of Agreement / Disagreement

Participants express multiple competing views on the topic, with no consensus reached regarding the best practices for managing 1:1 relationships in relational databases. Various examples and scenarios are presented, but the discussion remains unresolved.

Contextual Notes

Some limitations include the potential for missing assumptions about the nature of the data and the specific contexts in which these practices apply. The discussion does not resolve the complexities involved in determining when to merge or separate entities.

WWGD
Science Advisor
Homework Helper
Messages
7,785
Reaction score
13,076
Hi All,
The "best practices" in RDB on 1:1 relations between entities are that the two entities E1, E2 should be merged into a single one by default, i.e., unless there is an overwhelming reason to keep them separated.
Can someone provide illustrating examples of when the two entities should be merged and some of when the two should be kept separated? I think this has to see with deciding , in a given context , whether one entity can be more reasonably (within the context) when E1 can be seen as an attribute of E2 . Another reason I can think of is that we may want to keep them separate in order to restrict access to information/attributes in a given table, like, say SSN #.
Thanks.
 
Computer science news on Phys.org
WWGD said:
Hi All,
The "best practices" in RDB on 1:1 relations between entities are that the two entities E1, E2 should be merged into a single one by default, i.e., unless there is an overwhelming reason to keep them separated.
Can someone provide illustrating examples of when the two entities should be merged and some of when the two should be kept separated? I think this has to see with deciding , in a given context , whether one entity can be more reasonably (within the context) when E1 can be seen as an attribute of E2 . Another reason I can think of is that we may want to keep them separate in order to restrict access to information/attributes in a given table, like, say SSN #.
Thanks.

One consideration is whether the 1:1 relationship is unchangeable. Perhaps "shipping address" is a good example. Even if the initial data specification is for one address, it may be wise to allow for more, just in case.
 
  • Like
Likes   Reactions: DaveC426913 and WWGD
I can give you an example: I have created a database of my music collection. The tables are:
  • "Album", containing the title, the media type and the physical placement (where is it?)
  • "Track", containing the track no., the title, the performer and the composer
There would be no sense at all duplicating the "Album" info in each track record.

Of course, there are more tables and more fields, but I have shown you the basics.
 
Svein said:
I can give you an example: I have created a database of my music collection. The tables are:
  • "Album", containing the title, the media type and the physical placement (where is it?)
  • "Track", containing the track no., the title, the performer and the composer
There would be no sense at all duplicating the "Album" info in each track record.

Of course, there are more tables and more fields, but I have shown you the basics.
How does this example help the OP? A track::album relationship is a one-to-many relationship. Of course they're separate tables.
 
DaveC426913 said:
How does this example help the OP? A track::album relationship is a one-to-many relationship. Of course they're separate tables.
Sorry, I did not see that qualification. I do not have a ready example for a one-to-one relationship, but I can think of one based on the union concept in C. Imagine a Customer table which is either linked to a National or an International shipping table. Those two shipping tables will contain different information, but only one set of Shipping information is connected to each customer.
 
Potentially another reason is the technical characteristics of the data. Digital images might be separated from a regular table. And DICOM images, representing CT and MRI scans, or other medical data in the form of a large digital file would be separated using specialist technology.

In fact, all radiology systems are split into a Radiology Information System and a PACS (Picture Archive and Communication System), with the RIS providing the regular functionality (schedluing and patient information etc.) and the PACS specialising in the handling of large digital images. That would be the ultimate in terms of the characteristics of the data driving the design of the system into two separate but integrable parts. Way beyond just database design, in any case!
 
  • Like
Likes   Reactions: WWGD
A classic reason to separate 1:1 data would be security. So it might be okay for some people to see names but not social security numbers. Putting the Socials in another table means you can set completely different access control levels for the sensitive data.

There might also be efficiency reasons. I'd have to think about that. Like maybe, very very rarely accessed data.

One reason I have done it in the past was that I inherited a god-awful, crappy old data model, where a lot of stored procedures, triggers, enforced relationships and existing code get mad if I add any fields at all to my existing table. So my god-awful, crappy workaround has been to create a parallel extension table with 1:1 relationship and just join them whenever I need them.
 
  • Like
Likes   Reactions: WWGD and DaveC426913
There are many reasons for seperating 1:1 relational data here are a few:

1. If there is broad separation of the data's functional use: Example entity 'Person' with attributes relating to Medical Condition and Attributes relating to Salary, these attributes will probably be accessed in different functions or under different security regimes.
2. Access speed, if an attribute of an Entity is a Binary Large Object (BLOB/LOB/CLOB) then seperating it from non-large attributes of the same entity makes sense from a performance point of view (especially if the BLOB is infrequently needed but the other attributes are accessed often.
3. Semi related to point 1, if you need the ability to independantly and concurrently update two attributes of the same entity occurrence, split them. Databases typically lock at row level, so Bob might lock (for update) a row of people_medical while sally locks the equivalent row of people_salary. This can be very important in big systems to avoid lock failures.
4. Separation of historical values for performance, ie People.salary People.last_years_salary (not a great example, but attributes that are unlikely to be needed regfularly)
 
  • Like
Likes   Reactions: WWGD and Silicon Waffle

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 37 ·
2
Replies
37
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 146 ·
5
Replies
146
Views
11K
  • · Replies 19 ·
Replies
19
Views
7K
  • · Replies 2 ·
Replies
2
Views
2K