Constraints Triggers Motivation and overview Jennifer Widom Constraints

  • Slides: 10
Download presentation
Constraints & Triggers Motivation and overview Jennifer Widom

Constraints & Triggers Motivation and overview Jennifer Widom

Constraints & Triggers Constraints and Triggers § For relational databases § SQL standard; systems

Constraints & Triggers Constraints and Triggers § For relational databases § SQL standard; systems vary considerably (Integrity) Constraints constrain allowable database states Triggers monitor database changes, check conditions and initiate actions Jennifer Widom

Constraints & Triggers Integrity Constraints Impose restrictions on allowable data, beyond those imposed by

Constraints & Triggers Integrity Constraints Impose restrictions on allowable data, beyond those imposed by structure and types Examples Jennifer Widom

Constraints & Triggers Integrity Constraints Impose restrictions on allowable data, beyond those imposed by

Constraints & Triggers Integrity Constraints Impose restrictions on allowable data, beyond those imposed by structure and types Why use them? Jennifer Widom

Constraints & Triggers Integrity Constraints Impose restrictions on allowable data, beyond those imposed by

Constraints & Triggers Integrity Constraints Impose restrictions on allowable data, beyond those imposed by structure and types Classification Jennifer Widom

Declaring and enforcing constraints Declaration § With original schema Constraints & Triggers § Or

Declaring and enforcing constraints Declaration § With original schema Constraints & Triggers § Or later Enforcement § Check after every modification § Deferred constraint checking Jennifer Widom

Constraints & Triggers “Event-Condition-Action Rules” When event occurs, check condition; if true, do action

Constraints & Triggers “Event-Condition-Action Rules” When event occurs, check condition; if true, do action Examples Jennifer Widom

Constraints & Triggers “Event-Condition-Action Rules” When event occurs, check condition; if true, do action

Constraints & Triggers “Event-Condition-Action Rules” When event occurs, check condition; if true, do action Why use them? Jennifer Widom

Triggers in SQL “Event-Condition-Action Rules” Constraints & Triggers Create Trigger name Before|After|Instead Of events

Triggers in SQL “Event-Condition-Action Rules” Constraints & Triggers Create Trigger name Before|After|Instead Of events [ referencing-variables ] [ For Each Row ] When ( condition ) action Jennifer Widom

Constraints & Triggers Constraints and Triggers § For relational databases § SQL standard; systems

Constraints & Triggers Constraints and Triggers § For relational databases § SQL standard; systems vary considerably (Integrity) Constraints constrain allowable database states Triggers monitor database changes, check conditions and initiate actions Jennifer Widom