What are advantages of using a one-to-one table relationship? (MySQL)
Posted
by byronh
on Stack Overflow
See other posts from Stack Overflow
or by byronh
Published on 2010-03-26T07:55:11Z
Indexed on
2010/03/26
8:03 UTC
Read the original article
Hit count: 113
What are advantages of using a one-to-one table relationship as opposed to simply storing all the data in one table? I understand and make use of one-to-many, many-to-one, and many-to-many all the time, but implementing a one-to-one relationship seems like a tedious and unnecessary task, especially if you use naming conventions for relating (php) objects to database tables.
I couldn't find anything on the net or on this site that could supply a good real-world example of a one-to-one relationship. At first I thought it might be logical to separate 'users', for example, into two tables, one containing public information like an 'about me' for profile pages and one containing private information such as login/password, etc. But why go through all the trouble of using unnecessary JOINS when you can just choose which fields to select from that table anyway? If I'm displaying the user's profile page, obviously I would only SELECT id,username,email,aboutme etc. and not the fields containing their private info.
Anyone care to enlighten me with some real-world examples of one-to-one relationships?
© Stack Overflow or respective owner