Intro to Database Systems - Part 11 to 13 : Integrity Constraints
Constraints are there to impose restrictions on what data is allowed in the database. The basic E/R model introduces us to 2 types of constraints:
The relational model allows us to be more flexible. It imposes bounds on attributes. For now, we are able to force an attribute to be:
- non null
- of a specific domain (integer, string, etc)
But what if we need to express the situation of a student that can only take some courses if his GPA > 3.0? What if, in order to be a teacher assistant, you need to have successfully passed that course with an A or you need to have a 3.0 of cumulative GPA? By introducing the SQL keyword CHECK, we introduce 2 new notions:
- attribute-based checks : fancy name to mention that we are imposing a constraint on a column
- tuple-based checks: imposing constraints on rows.
We are introducing checks (and in general, constraints), for...
Continue reading →