Hello Hibernator-folk,
I'd like your collective opinion on how to deal with a quaternary association.
This is the ERD.
Code:
+-----------------------------+------------------------+
|TABLE |ENTITY |
+-----------------------------+------------------------+
|tblUsers |User |
|tblUserGroups |UserGroup |
|tblWebEntities |WebEntity |
|tblWebEntityGroups |WebEntityGroup |
+-----------------------------+------------------------+
|tblUserGroupAssignments |UserGroupAssignment |
|tblWebEntitypGroupAssignments|WebEntityGroupAssignment|
+-----------------------------+------------------------+
The first four entities are the ones I'm interested in. If these entities were directly related to each other via a single association table, I'd simply use four composites, with each composite containing references to the other three entities in the association.
But two of these objects (UserGroups and WebEntityGroups) are related through their own respective association tables (tblUserGroupAssignments and tblWebEntitypGroupAssignments). And so I've created additional entities (UserGroupAssignment and WebEntityGroupAssignment) to map these tables to use in the composites.
And now for my questions...
How do I deal with UserGroup and WebEntityGroup? For example, if I query User I'll get back a list of User objects, and each User object has a set of composite objects that--in turn--contain three associated sets (UserGroupAssignment, WebEntity, and WebEntityGroupAssignment).
What is the best way to reference UserGroup from UserGroupAssignment and WebEntityGroup from WebEntityGroupAssignment? Keep in mind I'll also be going the other way, querying UserGroup to see what Users, WebEntities, and WebEntityGroups are associated with any particular UserGroup.
I'm uncertain how to map UserGroup or WebEntityGroup so that I can go the other way, through their respective association tables to the quaternary association table.
Here are some mappings to further illustrate...
This is a mapping for User showing the composite-element tag in action...
This is a mapping for a composite object (PermissionAssignmentForUser) used by User to reference the other three objects in the quaternary association (i.e., UserGroupAssignment, WebEntity, and WebEntityGroupAssignment)...
This is a mapping for the object representing one of the association tables involved in the quaternary association...
I hope this isn't hopelessly confusing; let me know and I'll redo it all using foo, bar, snafu, and fumanchu. An easier way to sum up everything would be to simply ask: how do I deal with entities that are indirectly related in a quaternary association through their own respective association tables?
If you've read this far then you certainly deserve my gratitude. THANK YOU!
-S