Or may be, I do not even need a reference table in the middle, because
there is a singular relationship between each pair of models. So
storing the id of the location in each table should be enough to refer
to the correct location. It is a many-to-one relationship.

Thanks
Loke

On Jan 9, 6:27 pm, loke <[email protected]> wrote:
> Well, the situation is like this:
> Locations(id, location_info) is an independent table to store all
> relevant locations.
> Jobs (id, name, location_id) is a table that has exactly one location
> for each job, and stores the location_id from location(id).
> Shops(id, name, location_id) is another table that has exactly one
> location for each shop, and stores the location_id from location(id).
>
> I do understand that I need to have a reference table in the middle of
> each relationship, but am unable to find a definable relationship
> within the scope of CakePHP. HABTM seems to be the closest option, but
> may be I need something different.
>
> Thanks
> Loke
>
> On Jan 8, 2:28 pm, John Andersen <[email protected]> wrote:
>
> > What are the requirements for Model3?
> > Must there be a relationship to Model2 if there is a relationship to
> > Model1 and vice versa?
> > Enjoy,
> >    John
>
> > On Jan 8, 9:05 pm, loke <[email protected]> wrote:
>
> > > I have a relational requirement where more than one models are related
> > > to another model.
>
> > > I want to define the relations with an index table for each
> > > relationship between the two models.
>
> > > Model1 -> Model1_Model3_index -> Model3
>
> > > Model2 -> Model2_Model3_index -> Model3
>
> > > I could see HABTM to be a solution, but the relationship between
> > > Model1-> Model3 and Model2->Model3 has to be a 1 -to- n relationship.
>
> > > Thanks
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

Reply via email to