Re: Setting up table ID's

2009-07-15 Thread Bryan Paddock
What is the purpose of the UUID? The database generates a unique ID for each
user anyways so if it's just for internal usage then just use the ID.
If you need a UUID then i'd recommend adding an extra field in the db for
it.

The correct way to go about it would involve the use of foregin keys.

---

Users
---
id
uuid
name
email
other_fields

Profiles
-
id
user_id  -> foreign key for the User.id field
other_fields

Galleries
---
id
user_id -> foreign key for the User.id field
gallery_name

Albums
--
id
gallery_id-> foreign key for the Gallery.id field
album_name

---

If you need to fetch the users galleries then you'll call

$this->User->Gallery->find('all', array('conditions' => array(
'Gallery.user_id' => $this->Auth->user('id') ) );

And if your model's are associated properly then you'll fetch all the albums
related to that gallery too.

Hope this helps.


On Mon, Jul 13, 2009 at 9:36 PM, Dave Maharaj :: WidePixels.com <
d...@widepixels.com> wrote:

>  I am setting up am app and trying UUID for each user but question I have
> is:
>
> So a User.id is a UUID
> that User hasOne Profile.id which will be the User.id correct?
>
> User.id <= same as => Profile.id
>
> And say a User hasOne Gallery which hasMany Albums and each Album hasMany
> Photos
>
> Would the Gallery.id be the User.id? the Album has its own ID, gallery_id
> which would be the same UUID?
>
> User.id <= same as => Gallery.id
>
> Album.id => int(11)
> Album.gallery_id => the users UUID
>
> Photos.id => int(11)
> Photos.album_id => int(11)
>
> and
> Photos would have their own ID but relate back to the album_id whichc would
> trace back to the Gallery.id and back to its original owner?
>
> Hope that makes sense
>
> Is that the right way to do it?
>
> Thanks,
>
> Dave
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Setting up table ID's

2009-07-13 Thread Dave Maharaj :: WidePixels.com
I am setting up am app and trying UUID for each user but question I have is:
 
So a User.id is a UUID
that User hasOne Profile.id which will be the User.id correct?
 
User.id <= same as => Profile.id 
 
And say a User hasOne Gallery which hasMany Albums and each Album hasMany
Photos
 
Would the Gallery.id be the User.id? the Album has its own ID, gallery_id
which would be the same UUID? 
 
User.id <= same as => Gallery.id 
 
Album.id => int(11)
Album.gallery_id => the users UUID 
 
Photos.id => int(11)
Photos.album_id => int(11)
 
and
Photos would have their own ID but relate back to the album_id whichc would
trace back to the Gallery.id and back to its original owner?
 
Hope that makes sense
 
Is that the right way to do it?
 
Thanks,
 
Dave

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---