SQLEditor supports UNIQUE and CHECK constraints.
A UNIQUE constraint requires that the value in the specified column must be unique within the table.
If multiple columns are specified then each specific combination of values must be unique
For example, if the constraint was
UNIQUE(name,birthday,shoeSize)then each row would have to have a different value for the the combination of name,birthday and shoe size.
row | name | birthday | shoeSize |
---|---|---|---|
1 | joe | 01/01/1900 | 10 |
2 | fred | 01/01/1990 | 9 |
But the following row would be rejected if we tried to insert it.
row | name | birthday | shoeSize |
---|---|---|---|
3 | joe | 01/01/1900 | 10 |
Because it has the same (name,birthday,shoeSize) combination as row 1
A CHECK constraint specifies a particular expression that must be satisfied
An example might be that prices must be greater than zero. This would be expressed as follows:
CHECK(price > 0)
Any price value that wasn't above 0 would then be rejected by the database.
Constraints are edited using the inspector.
Constraints at the table level use the constraint inspector panel.
Use the field inspector
in theUse the Check Constraint subpanel of the field inspector