Are there 1 to 1 relationships on db tables?

I have a table with a bunch of fields. Fields can be divided into logical groups - for example, information from the project manager of a project. The groups themselves are not candidates for the position, since they do not and should not have their own PCs.

Now, to group them, the fields have prefixes (for example, PmFirstName), but I am considering their breakdown into several tables with a 1: 1 ratio in the main table.

Is there anything that I must observe when I do this? Is this just a bad choice?

I see that maybe my queries will get complicated with all the extra joins, but can this be mitigated with the help of views? If we are talking about a table with less than 100 thousand records, will this have a noticeable effect on performance?

Edit: I will justify the thoughts of the non-entity candidate a little further. This information is entered by our user base. They do not know / do not care about each other. Thus, it is possible that the same user will submit the same name "projectManager" or something else that at the moment will not violate any restriction. It will be determined later for us by pipeline, if we want to correlate entries from individual users. If I gave these things to my own key, they would grow at the same speed as the main table, since they are essentially part of the same object. In the absence of pt, the user selects from the list of available "project managers".

So, given the above, I do not think that they are entities. But maybe not - if you have further thoughts, please write.

+3
source share
5 answers

I usually don’t use 1 to 1 relationships unless there is a specific reason for this. For example, to store rarely used large text or fields like BLOB in a separate table.

I would suspect that there is something else. In the example you are giving - PmFirstName - it looks like there should be one pm_id that refers to the "ProjectManagers" or "Employees" table. Are you sure that none of these groups are candidates for the essence?

+4
source

, . PmFirstName, NULL.

.

+2

1 1 , .

, , ​​ CUSIP, , DatedDate MaturityDate. .

(Treasury, Corporate, Muni, Agency ..) .

. , .

, , (, PmFirstName), 1:1 .

, . PMKey, .

+2

, ? , ?

.

0

, , .

, " " 1:1 , , , . .

PrimaryFirstName, PrimaryLastName, PrimaryPhone, SecondaryFirstName, SecondaryLastName, SEcondaryPhone

"" FirstName, LastName, Phone

"PrimaryId" "SecondaryId", 6 , .

In addition, using SQL, you can separate filegroups and tables by physical location. Thus, you can have a POST table and a COMMENT table, which has a 1: 1 ratio, but the COMMENT table is in a different file group and on a different physical disk with a large amount of memory.

1: 1 does not always smell. If it has no purpose.

0
source

Source: https://habr.com/ru/post/1703977/


All Articles