Sketching Constraints

Before you create a table with defaults and constraints, sketch your requirements. Figure 3.6 shows defaults and constraints you might use for the titles table.

Figure 3.6. Using Constraints in Creating the titles Table

The sketch includes the name, datatype, and NULL status of each column. In addition, it notes places where constraints might protect the data.

  • Instead of creating indexes on title_id and title, you specify PRIMARY KEY and UNIQUE constraints. The title_id column is the unique identifier for the row and hence a perfect candidate for a PRIMARY KEY constraint. The UNIQUE constraint on title is parallel to the ...

Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.