Normalised database with one-to-one relationship

database-design

Is it bad practice to use a 1-1 relationship between two logically distinct tables: the user details and the user configuration settings? Each configuration record would have a single unique user ID, but they seemed separate enough to warrant two tables rather than one big one. I ask because the WikiBook for my school course said that I should only use 1-Many relationships.

In the User table I will be storing details such as their username, id and authorisation token for an external system. In the Config table I will be storing settings such as whether to show a welcome message, which are changeable through the settings page.

Best Answer

The attributes should be split in 2 tables because the configuration details are not depending on the user but on the configuration of an external system. If a user can have only 1 configuration then you must use an 1-1 relation. If a user can have multiple configurations then you must use the 1-M relation.

This is the theory. If you want (in case of a 1-1 relation) put all in 1 table than this is also 'allowed'. Remember well that if one day the relation becomes 1-M that you are in problems. This is also why it is preferred to split the information into 2 tables.