Hi guys,
how would you map the following object diagram (with the sensible restriction that User, Product and Stuff go to different tables).
Code:
ICommentable IRateable
^ ^ ^ ^
| \ / |
| \/ |
User Product Stuff
Comment *----------- ICommentable
Rating *---------------- IRateable
Some possibilities that come to my mind:
1) Mapping the many-to-one of Comment and Rating with <any>. (table per concrete class with implicit polymorphism)
2) Using table per concrete class with unions. But I can't figure out any way to avoid duplicated mappings for classes that take part of multiple (interface) hierarchies (Product in the example which is both a ICommentable and a IRateable). And AFAIK these duplicated mappings are forbidden. I could compromise my design and make all of User, Product and Stuff extend some AbstractCommentableRateable class. Of course, besides the crippled design, the unions will then include a third unneeded table for both associations (Stuff for the Commentable one, User for the Rateable one).
Any better idea?
Best regards
-Carlos