On Thu, Nov 25, 2010 at 8:40 PM, Dave Maharaj <[email protected]> wrote: > 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
No way. You're looking at this as if you're using auto_increment *and they just happen to coincide*. Sure, that happens sometimes, but it's irrelevant. The PK for a given table is completely separate from that of any other table. But where you've really gone wrong is assuming that a UUID would be the same. They shouldn't be, unless you've got something really wrong with the code that's generating them. Not only should there not be the same UUID found within a given table, but it shouldn't appear again in the same database. In any case, ask yourself if you really need a separate profiles table. Couldn't that data be kept in the users table? Why separate it? Unless your users can have multiple profiles, I don't think it's necessary. 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
