I was reading a book and it talks about a User
has some more UserDetail
, and so the UserDetail
will have a user_id
pointing back to the Users table. I kind of forgot that, does it help at all to has a field in Users
table to have a user_detail_id
to point at the UserDetail record?
This is so in Ruby on Rails too, that the Users
table doesn't have a user_detail_id
, but the UserDetail
table has a user_id
. And the User
model use has_one :user_detail
, while the UserDetail
model use belongs_to :user
.
It kind of makes sense that if it is a one-to-many relationship, then at the "Many" side, we have an foreign_id
pointing back to the "One" side, but the "One" side doesn't need to point to the "Many" side, so it looks like a one-to-one doesn't need to have it pointing both ways too, as one side is enough.