The HasMany convention should help you set this up. Author, Book, and Publisher. If you plan on attaching the SAME note to several of these, use HasManyToMany.

-----Original Message----- From: David
Sent: Sunday, March 06, 2011 12:53 PM
To: nhusers
Subject: [nhusers] Many-to-many different classes

I am using nhibernate but I seem to be making my life harder and
harder as I plan my design.

I have a bunch of domain objects which are linked together in an
entirely normal way.  For the purposes of example, these could be
Authors, Books and Publishers.

However I would like to extend this so that these items can have other
attributes linked to them, e.g. Notes.  An individual Book could have
multiple notes, as could an Author or Publisher.  The same sort of
system could work for categories, tags[1] or a bunch of other
attributes.

Is there a sensible way of designing a domain model (and database
structure) around this without having a mapping table for each?  I
have not seen any examples where one domain model (e.g. Notes) has
multiple lists of other objects that could relate to it.

I have only seen the following, which could get complicated pretty
quickly and introduces a whole unnecessary layer of complexity:

Author <-> AuthorNotes <-> Notes
Book <-> BookNotes <-> Notes
Publisher <-> PublisherNotes <-> Notes

It would be great to hear about alternative ways of defining these
sorts of relationships.


1 - I know there are alternative methods of implementing this and will
be considering them.

--
You received this message because you are subscribed to the Google Groups "nhusers" 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/nhusers?hl=en.
--
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en.

Reply via email to