I’ve been having trouble enforcing my data model in MySQL and I was wondering if there are any better ways to do this.
Model:
Platforms <- Has many groups
Groups <- Has one platform, Has many SymbolSets
SymbolSets <- Belongs to many groups
My problem is that SymbolSets can only belong to groups that have the same platform. So if Platform A has Group A with SymbolSet A then Platform B with Group B shouldn’t be able to get SymbolSet A, but any group in Platform A should be able to get it.
Right now I have a link table between SymbolSets and Groups and I enforce the uniqueness per platform in code, but I’d rather have a solution enforced in the DB so nobody can go muck around with it and break things. I would prefer to not have this many to many relationship in the first place, but that doesn’t really fit our business model.
When a
SymbolSetis to be assigned to aGroup(a new row inSymbolSetToGroup), it first has to be assigned to the samePlatformthat theGroupbelong to (so a new row inSymbolSetAssignedfirst).