pmularien wrote:
What is your navigation pattern? Do you ever want to navigate backwards from a Comment to the parent object, e.g. Article? Or are you always navigating in the manner that the previous poster suggested would befit a one-to-many collection, from the Article/Discussion to related Comments?
We can get away without needing to navigate from the Comment to the parent object - it's a less common usage scenario that we can get around using straight SQL.
I think the crux of the problem is this:
Say we have articles with the following ids:
[10, 11, 12]
And discussions with the following ids:
[10, 11, 12]
There's overlap because they came from a different ID generator, so you need a discriminator in the Comment table indicating which type the foreign key represents:
Code:
[CommentID | ParentID | Discriminator | CommentText]
10 10 ART Blah...
11 11 ART Blah...
12 10 DIS Blah...
13 12 DIS Blah...
In this case the ids overlap because they were generated off of different sequences or identity columns. "Move to a shared id space" you might say. But ideally we'd like to be able to have this work across objects implementing an interface - Commentable. So we could have a shared id space for everything implementing Commentable.
But what if we also have an identical situation with other child objects - Tags that can be applied to anything that's Taggable. Then you'd need a shared id space for both Taggable and Commentable objects, which sounds like GUIDs to me, which I don't want to be forced into.
Thanks for the suggestions so far, but it is still looking to me like I'm going to have to choose between GUIDs or a bunch of subclasses for Comment (and other analogous situations).