The cookbook states for foreign key “foreignKey: the name of the foreign key found in the other model. This is especially handy if you need to define multiple hasOne relationships. The default value for this key is the underscored, singular name of the current model, suffixed with ‘_id’. In the example above it would default to 'user_id'.”
Default value meaning that’s is what is suggested to use? All my id’s are UUID CHAR(36) so building this app User.id is say 1111-1111-1111-1111 (just so its easier to read for the sake of this question instead of a real UUID) When a User is created I make the Profile at the same time using the User.id so they are the same User has a Profile so Profile.id = 1111-1111-1111-1111 with Profile.user_id = 1111-1111-1111-1111 Next new User so Profile.id = 2222-2222-2222-2222 with Profile.user_id = 2222-2222-2222-2222 see the redundancy forming? I can simply make Profile.id and relate 'foreignKey' => 'id', for the USER ó PROFILE relation and then everything related to the profile still gets the standard 'foreignKey' => 'profile_id'. Seems like overkill get User / Profile data where JOIN on the exact same data also. I know the foreign key makes since but in this case where everything is related to the Profile other than logging in your never really using the User. So I know I can do it since I currenty have it in my set up my question is since its not following what it should be as outlined why should I not other than “because that’s what the book says” Nothing queries the User other than login Get Profile where Profile.id => Auth->User(‘id’) why have the extra Profile.user_id The single UUID is unique across the db, why would I want User.id = 1111-1111-1111-1111 Profile.id to have 1212-1212-1212-1212 Profile.user_id = 1111-1111-1111-1111 Or User.id = 1111-1111-1111-1111 Profile.id to have 1111-1111-1111-1111 Profile.user_id = 1111-1111-1111-1111 When using User.id = 1111-1111-1111-1111 Profile.id = 1111-1111-1111-1111 Seems most logical Thoughts? Points? Drawbacks? Thanks, Dave Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
