Chapter 7 Constraints and Triggers Keys and foreign keys Constraints on attributes and tuples Modification of constraints Assertions triggers
Chapter 7 Constraints and Triggers z Keys and foreign keys z Constraints on attributes and tuples z Modification of constraints z Assertions z triggers
Why use integrity constraints? To catch data-entry errors. o As correctness criteria when writing database updates. To enforce consistency across data in the database. To tell the system about the data it may choose to store the data or process a queries accordingly
Why use integrity constraints? zTo catch data-entry errors. z As correctness criteria when writing database updates. zTo enforce consistency across data in the database. zTo tell the system about the data - it may choose to store the data or process a queries accordingly
Constraints and Triggers A constraint is a relationship among data elements that the DBMS is required to enforce. -Example:key constraints. Triggers are only executed when a specified condition occurs,e.g., insertion of a tuple. Easier to implement than many constraints
Constraints and Triggers zA constraint is a relationship among data elements that the DBMS is required to enforce. – Example: key constraints. zTriggers are only executed when a specified condition occurs, e.g., insertion of a tuple. – Easier to implement than many constraints
Types of Constraints (1)Non-null,unique (2)Key (3)Referential integrity(Foreign-keys) (4)Attribute-based Check (5)Tuple-based Check (6)General assertions global constraints
Types of Constraints (1) Non-null, unique (2) Key (3) Referential integrity (Foreign-keys) (4) Attribute-based Check (5) Tuple-based Check (6) General assertions = global constraints
Constraints with key,not null and unique key constraints:not null,unique. o Not null constraints:not null. .Unique constraints can be null, but unique. Many unique constraints in a table, but only one key constraints. Key constraint forbids null's in the attributes of the key,but unique permits them
Constraints with key, not null and unique zkey constraints: not null, unique. zNot null constraints: not null. zUnique constraints : can be null, but unique. zMany unique constraints in a table, but only one key constraints. zKey constraint forbids null’s in the attributes of the key,but unique permits them