cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tony Giaccone <>
Subject Re: Mapping Question
Date Wed, 13 Apr 2011 20:16:21 GMT
Yeah, that was my first thought. Scary when you and I think alike.
Conceptually it's clear, and clean, but then you have this set of sparsely
populated foreign keys. After all only one of them is ever going to have a
value in it.    That idea just irks me, it seems wasteful. But really in
these days of terabyte drives should I even let that thought enter my mind.
 I think having grown up in a world where 8k of memory was all you had,
there's always a feeling of hating to waste bytes..  But that was 30+ years
ago,  gots to live in the present. :-)

On Wed, Apr 13, 2011 at 8:39 AM, Michael Gentry <>wrote:

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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message