Hello group,

I have a similar question:

I got 2 models, that are almost identical - the only difference is,
that they have a belongsTo field, that is linked to different models.
Controllers and views are all the same, so I think to really use two
models is not very DRY. The models

post_reminders
===========
id
post_id
user_id
comment

section_reminder
=============
id
section_id
user_id
comment

My 1st thought was to put them into one table like that:

reminders
=======
id
foreign_type
foreign_id
user_id
comment

but with that i cannot use assocations by default (I would need two
queries). Maybe anyone out there has an advice on how to solve this
(with a new parent class maybe?)

Thanks,
harpax

On 27 Mai, 10:22, Braindead <[email protected]> wrote:
> Well, my problem is not directly related to CakePHP, but as it's about
> database design maybe I'll get some good answers.
>
> On my page I have news, downloads and users. These three can be
> commented. Additionally I have a shoutbox and a guestbook. The
> comments, shoutbox and guestbook have all the same fields. So they
> could reside in the same table.
>
> Is it best practice to only have one table for all comments (news,
> downloads, users), the shoutbox and the guestbook and actually filter
> based on a type column? Or is it better to separate everything into
> it's own table?
>
> Using only one table has the advantage, that I could use only one
> controller and a limited set of views, where as using multiple tables
> would mean multiple controllers and duplicated views (as they are all
> nearly the same).
>
> So what do you recomment?
--~--~---------~--~----~------------~-------~--~----~
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