MmmVomit Posted October 11, 2007 Share Posted October 11, 2007 I've got a basic many-to-many relationsip set up in my database RECORD ------------- ID RecordData TYPE ------------- ID TypeDescription RECORD_TYPE_JUNCTION -------------- ID RecordID => RECORD.ID TypeID => TYPE.ID What I'd like to do is restrict the specific combinations of types are allowed. In general each RECORD will only get one TYPE, but there are certain combinations of types that I need to make possible. I've come up with a solution by adding a GROUP table. GROUP ----------------- ID Group TypeID => TYPE.ID The data in this table would look something like this. GROUP ----------------- ID Group TypeID 1 1 1 2 1 4 3 1 5 4 2 2 5 2 4 6 3 2 7 3 5 8 3 7 A valid combination of types would be (1, 4, 5), (2, 4), or (2, 5, 7). If a type does not appear in the GROUP table, it is a singleton and is not allowed in combination with any other types, e.g. 6. Any subset of a valid group is allowed, so (4, 5) is allowed, because it is a subset of group 1. Does anyone see drawbacks to this? Is there a better way of doing this? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.