Monday, January 30, 2012

Re: Associations & model linking

Ups, Actually i forgot to say: a teacher is ALSO a student!!
I've invented teacher-students names on the fly for a better
explanation!
So every teacher somewhere in the webapp can act as a students.

On Jan 30, 12:32 pm, Thiago Belem <cont...@thiagobelem.net> wrote:
> This shoud work too:
>
> User $belongsTo Group
> User $hasOne Teacher (1:1)
> User $hasOne Student (1:1)
>
> A user don't have multiple (belongsTo/hasMany) students or teachers, he IS
> the teacher OR the student... so hasOne should do the trick.
>
> Cya,
> --
> ***Thiago Belem*
> Desenvolvedor
> Rio de Janeiro - RJ - Brasil
>
> +55 (21) 8865.9250
> thiagobelem.net
> cont...@thiagobelem.net
>
> *Skype / gTalk **»* thiago.belem.web
> *LinkedIn* *»* br.linkedin.com/in/thiagobelem/pt*
> Assando Sites*, curso de CakePHP *»* assando-sites.com.br
>
> 2012/1/30 succer...@tiscali.it <succer...@tiscali.it>
>
>
>
>
>
>
>
> > Hi everybody!
> > I want to know if i'm doing things right, please!
> > I have 3 kind of users: admin,teacher,students, so i've created 3
> > different groups (for ACL).
>
> > For the users, I've made 3 separated tables: users (for login),
> > teachers, and students.
>
> > So:
> > Users $belongsTo Group
> > teachers $belongsTo Users
> > teachers $hasMany users
> > students $belongsTo User
> > students $belongsTo teacher
>
> > Ok?
>
> > Recap:
> > -Users:  id,user,password,teachers_id,students_id,group_id
> > -Teachers:id, ..stuff.. , user_id
> > -Students:id, ..stuff.., teachers_id, user_id
>
> > Is this correct?
> > Thanks :)
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group
> > athttp://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: