In your Note table, you can have several foreign keys: thinkTopicFK,
projectFK, categoryFK, assetFK.  Then map each FK appropriately, so
your Note class ends up with a getThinkTopic(), getProject(),
getCategory(), and getAsset() .  On the other side, you'll have
getNotes() (in your ThinkTopic class, for example).  Of course, on the
Note side, most of those will return empty lists, but I'm assuming
you'll be drilling down from the other side?  If you care about going
from Note back the other way, you may want a discriminator column or
something to identify the type of note and use inheritance.

mrg


On Tue, Apr 12, 2011 at 3:43 PM, Tony Giaccone <[email protected]> wrote:
> This is more of a generic question, though I'm interested in how it might be
> implemented in Cayenne as well.
>
>
> I have a number of entities, Think Topic, Project, Category, Asset.  On each
> one I need to model a to many relationship to Notes, Where a Note is an
> object with a subject and a date created and content.
>
> I"m not sure what the best strategy is to map each of these different
> entities. I really don't want to create 4 note tables, So that there's a
> Topic Note table, and a Project  Note table and  well you get the idea.
>
> I could put a discriminator on the table, so that each entry has it's own
> "type" that would solve part of the problem, but they I have to create the
> foreign keys relationship.
>
> So I'm just looking for some advice. Have you dealt with a similar
> situation, and how did you model in general this solution and in Cayenne in
> particular.
>
> Thanks for the help
>
>
> Tony Giaccone
>

Reply via email to