A NOT NULL constraint requires a column to contain a value. It prevents missing or unknown values from entering places where the database needs reliable information. section 6.10 section 1.10
A product table
In a product table, name, description, price, and manufacturer can be declared NOT NULL. Every inserted product must then provide all four values. Without the constraint, a missing price could make calculations produce NULL because arithmetic involving an unknown value remains unknown. section 1.10
CREATE TABLE product ( product_id INT PRIMARY KEY, name TEXT NOT NULL, description TEXT NOT NULL, price DECIMAL(5, 2) NOT NULL, manufacturer TEXT NOT NULL );
This CREATE TABLE definition shows NOT NULL applied alongside data types and a primary key. section 1.10
Apply NOT NULL when a column must always have information:
- Mark critical operational data such as usernames, email addresses, passwords, names, or login times. section 6.10
- Use it for legally or compliantly required values, such as date of birth in an option-trading application. section 6.10
- Consider it for foreign keys when the relationship requires every row to reference another table. section 6.10
- Do not repeat NOT NULL for a primary key: PRIMARY KEY already implies and enforces it. section 6.10
Choose the constraint from the data requirements. Review each attribute, identify information that cannot be missing, and add NOT NULL in the column definition. section 8.11





