Actually, I'm not sure if I explained it right. There isn't a parent table of comment. Comment has a many to one relation to it's reference's (blog, media, etc). The comment for every type of reference is identical, there is no different between them.
While I know my alternative (realistic one) is to create an intermediate table for each reference type possible, that would break the many to one relation (making it many to many) and it would produce a lot of little tables everywhere which aren't needed. My preference is to keep it a many to one relation, and since I'll know what comment type I want based on the context of the user's actions, this seems like a fairly straight forward approach to me with no waste.
For the java I'll be instantiating the comment class w/ generics, so it'll be something like
Comment<Blog> blogComment = new Comment<Blog>();
which will tell the class to use a blog for the reference class. With generics, it seems much better to use the proper class in comment rather then have five of them, four of which aren't being used (plus I don't think you could do that anyway since they would relate to the same column). One of my questions was whether or not Hibernate could deal w/ generics in this way...I'm hoping it can since generics are so powerful, and keep things very organized.
Hopefully that explains better what I have in mind.
|