If we have something like this in UML:
| Championship | —————> | Team |
Multiplicity: * ——-> 5…*
Each championship has 5 or more teams, how can we control this ‘five or more teams’ in T-SQL?
Since we have a relationship many to many, we will have intermediate table ( example: tbl_champ_team) with ids from both sides. But how to control that each championship should have 5 or more teams?
Some CHECK when create table? some trigger?
Short answer is that no you can’t do that via a check constraint. Yes, you could apply a trigger to the intersecting table that would make make sure the rowcount of inserted is 5 or more, although I would strongly argue against that.
It seems to me that what you’re after is the implementation of a business rule, not a data rule, and if so then this validation should be done there.