Continuing on my theme of ORM constraint primers, I thought I’d cover a bit about the frequency constraint.
Adding a frequency constraint to a role means that once the role is populated with a given object instance, that same object instance must populate the role between some minimum and some maximum number of times.
For example, if let’s suppose we have the fact "IT Solution has Advantage (name)" -- where the possible advantages are: good, fast, and cheap. Long time readers might recall (and the more cynical new readers also have a good idea) where this is going.
The fact has no mandatory constraints as we have all seen IT Solutions that are not good, delivered fast, nor cheap. Then, the realists among us will declare that for any given IT Solution, you can pick up to two. We implement this as a frequency constraint that has a range of between 1 and 2. This means that for any given IT solution that plays a role in this fact, it must be there at least once and at most twice.

Now, I need to mention a few technical points. The default and lowest minimum of a frequency constraint is 1. This doesn’t mean that every IT solution known to the system must play a role in this fact (which is what a mandatory constraint does). Instead, it means that if a given IT Solution plays a role in this fact, it must play the role at least once.
The maximum of a frequency constraint must be equal to or greater than the minimum for hopefully obvious reasons (try adding at least two but at most one instances of an object to a fact).
The default and lowest maximum of a frequency constraint is 2. First of all, it cannot be 0 because it has to be greater than or equal to the minimum (when as per the above, its lowest value is one). If the maximum were set to 1, the object could play the role at most once, which is what a uniqueness constraint over the role does. Therefore, if you want to supply a maximum, it has to be 2 or more. You can, however, supply no maximum, which means the object could play the role an unlimited number of times (assuming of course that all other constraints, such as uniqueness, can also be met).
Notice that the minimum can be more than 1. This means that if a given object were to play a role in this fact, it must play that role 2, 3, or whatever many times. Likewise, you could add a constraint that says the given object has to play the role at least 2 but at most 4 times.
If you want to ensure that every object plays some role exactly 2 times, you would set the minimum frequency to 2 and add a mandatory constraint. The latter makes sure that the every object plays a role in the fact while the former makes sure it plays that role twice.
Finally, note that frequency constraints can be applied to combinations of roles and it acts the same way. For example, given the fact “Presenter was given Rating on Date by Person” and a business rule that says for any given Presenter given any rating on a given Date, the presenter must be rated at least twice and at most 4 times on that same date. To implement this, you merely select the two roles (Presenter and Date) and set the minimum to 2 and the maximum to 4. This is illustrated below with the uniqueness constraint (across Presenter, Date, and Person) omitted because it happens to overlap with the role connector thus making the frequency constraint hard to see.
