Sunday, November 30, 2008

Re: Understanding if a model-controller couple is needed

The answer as always is "it depends" (but in this case I think the
answer is yes you need a model for the review).

First I would suggest that your movies_reviewers might be named
reviews, since it sounds like that is what you're putting in it.

If you will be accessing data from the review, then you need a model
for it. Personally I tend to model the relationships of all of the
tables using "cake bake", then go back and make sure all the
relationships are reflected in the models that I will be driving my UI
with.

Are your relationships really HABTM, or are they parent-child? I would
think that you'd have:

1. Movies has many Reviews
2. Reviewers has many Reviews
3. Reviews belong to Movies and Reviewers

On Nov 29, 11:43 am, Fabio M <fabio.mess...@gmail.com> wrote:
> Hi all. This is my first message here.
> I want to make it clear first that I read the (almost) whole
> documentation and now I'm going to develop a first application. I
> still have a doubt about dealing with HABTM relationship.
>
> I give you the precise picture.
>
> I have two entities: movie (motion picture) and reviewer. These are in
> a HABTM relationship, which represents the review. I'll create the
> conventional db tables: movies, reviewers and movies_reviewers. Note
> that movies_reviewers isnt just a join-table, it includes other
> informations beyond the foreign key (the vote of the review, the text
> of the review).
>
> Now I ask: do I need a model for the review? Is the review an object
> in my application?
>
> If so, which table should this model class be linked to? Directly to
> join-table?
>
> Should I make a whole another design? Dont know...  with three
> entities (movie, review, reviewers) and two merely associative
> relationships (with a movie_id and a reviewer_id in the reviews
> table)?
>
> Thank you. And forgive me for bad explanation and for not having found
> this topic in other threads. I'm italian and I'm a bit in difficulty
> at retrieving technical infos in a foreign language.
>
> Thank you in advance.  : )
>
>                       Fabio M
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: