Section 1 - Instruction

Last time we built basic table structures. Now let's make them smarter! Constraints ensure your data stays clean and complete automatically.

Think of constraints as quality control rules - they prevent bad data from entering your tables.

Engagement Message

What is one type of bad data that a constraint could block?

Section 2 - Instruction

NOT NULL is your first line of defense against incomplete data. It prevents anyone from leaving critical columns empty.

Without NOT NULL, someone could create a customer record with no name or email!

Engagement Message

Which would be worse: a customer with no name or no email address?

Section 3 - Instruction

Adding NOT NULL is simple - just include it after the data type in your column definition:

Now these columns must always have values.

Engagement Message

What happens if someone tries to insert a row without providing the first_name?

Section 4 - Instruction

DEFAULT values automatically fill in columns when no value is provided. They're perfect for timestamps, status flags, or standard settings.

Instead of forcing users to always specify a signup date, let DEFAULT handle it automatically. Here's how to add DEFAULT values to your columns:

CURRENT_DATE automatically inserts today's date.

Engagement Message

Can you think of other columns that would benefit from automatic defaults?

Section 5 - Instruction

IDENTITY columns automatically generate unique numbers for each new row. They're perfect for primary keys when you don't have natural unique identifiers.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal