Saturday, April 30, 2011

Re: should teacher and student stay together???

i believe the term your are looking for is 'self referential habtm'
goole for it. there are plenty examples

On Fri, Apr 29, 2011 at 1:53 PM, cricket <zijn.digital@gmail.com> wrote:
> On Fri, Apr 29, 2011 at 11:28 AM, Tan Cheng <davidtan824@gmail.com> wrote:
>> Hi all,
>>
>> A very basic question, I naively believe that there's no dumb
>> question...
>>
>> I'm creating a database, and the users are categorized into teachers
>> and students, obviously, one student has and belongs to many teachers
>> and vice versa, so there is a HABTM relationship between students and
>> teachers.
>>
>> So in cake, which is the better approach?
>>
>> 1) Put them in the "users" table and use a field to distinguish
>> students and teachers, but <b>how do I describe the HABTM relationship
>> between them? Do I need to create a "students_teachers" table?</b>
>
> You could add 2 columns to your users table, model & foreign_key. The
> students & teachers tables can also have a user_id column to associate
> back the other way.
>
>> 2) Create three tables, "students", "teachers", and a
>> "students_teachers" table.
>
> Yes, do that as well. These are not mutually exclusive.
>
> --
> 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
>

--
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: