CS4416 Lecture 08 - SQL Constraints
CS4416 Lecture 08 - SQL Constraints
html#lecture
Please note that this lecture is being recorded for academic purposes and will be available on Sulis. Any questions/comments you make during the lecture may be
heard/seen on the recording. The recordings will be retained on Sulis for a period of 13 months. If you have any questions or concerns about this, please contact
[email protected].
Please be advised that you should not copy, modify or distribute recordings of a lecture to which you have access, without first seeking permission to do so.
SQL CONSTRAINTS
CS4416 Lecture 08
Constraints and Triggers
2
Keys
Foreign-key, or referential-integrity
Value-based constraints
Constrain values of a particular attribute
Tuple-based constraints
Relationship among attributes
Assertions: any SQL Boolean expression
Revision: Declaring Single-Attribute Keys
4
x y
R S
R model S
model
(Products) (Sales)
R model S
model
(Products) (Sales)
MySQL Policies:
http://dev.mysql.com/doc/refman/5.7/en/innodb-foreign-key-constraints.html
Example: Setting Policy
16
Model 1001 can be sold only on or after the 1st of March 2018: