Atomic constraint:
- values cannot be broken down into other attributes of the same type
- check if that attribute can be further broken down into a relation
Key constraint
- Each primary key must be unique
Uniqueness Constraint
- All tuples must be unique
- By product of key constraint
Domain constraint
- As name suggests, the values for each attribute must meet their predefined domains
Custom domains
CREATE DOMAIN <domain_name> AS <type>
CHECK <contraint>
// Example:
CREATE DOMAIN COMPANY_SALARY AS INTEGER
CHECK (300000 <= VALUE AND VALUE <= 2000000);
CREATE DOMAIN GPA AS DOUBLE(1, 2)
CHECK (0.0 <= VALUE AND VALUE <= 4.3);
CREATE DOMAIN WEEKDAY AS CHAR(3)
CHECK (UPPER(VALUE) IN (‘MON’, ‘TUE’, ‘WED’, ‘THU’, ‘FRI’));
Non-Null Constraint
- Essentially, some attributes are defined with the
NOT NULL attribute
- Then, any insert must have a non-null value for that attribute
Entity Integrity Constraint
- The primary key being inserted can never be
NULL
Referential Integrity Constraint