6.3. SQL Constraints

  • Does something automatically

  • Prevents from duplicating information

  • Prevents from loss of integrity

../../_images/sql-constraints.png
../../_images/sql-literalvalue.png

6.3.1. NOT NULL

  • Ensures that a column cannot have a NULL value

6.3.2. UNIQUE

  • Ensures that all values in a column are different

6.3.3. PRIMARY KEY

  • Uniquely identifies each row in a table

  • A combination of a NOT NULL and UNIQUE

6.3.4. FOREIGN KEY

  • Uniquely identifies a row/record in another table

6.3.5. CHECK

  • Ensures that all values in a column satisfies a specific condition

6.3.6. DEFAULT

  • Sets a default value for a column when no value is specified

6.3.7. INDEX

  • Used to create and retrieve data from the database very quickly

  • Analog to notebook calendar tabs

../../_images/sql-index-notebookcalendar.png