php - CakePHP: One to One relationship -


i'm bit confused in how cakephp it's database relationship.

for hasone relationship, according documentation:

"user hasone profile"

user hasone profile -> profiles.user_id

array (     [user] => array         (             [id] => 121             [name] => gwoo kungwoo             [created] => 2007-05-01 10:31:01         )     [profile] => array         (             [id] => 12             [user_id] => 121             [skill] => baking cakes             [created] => 2007-05-01 10:31:01         ) ) 

but isn't 1 many relation?

for example (i made these table illustrate confusion):

enter image description here

enter image description here

in case there 2 profiles belonging same user. doesn't mean user hasmany profile?

would make more sense if "user hasone profile" is

enter image description here

enter image description here

so "user hasone profile" "profile hasmany user"?

i'm not sure if i'm understanding correctly.

in example @ documentation when said user has 1 profile means user can have 1 profile.

therefor 1 one relationship. can choose prefer have foreign key, , preferred use on profile table.

your images wrong. in case 1 many. hasmany + belongsto. decided there 1 profile per user, if want have many profiles per user, won't hasone. that's decision.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -