liveBook · Manning

Not-null constraint

As explained in Rust Servers, Services, and Apps

A NOT NULL constraint requires every row in a database column to contain a non-null value.

A NOT NULL constraint requires a database column to contain a value for every inserted row. In the course schema, tutor_id and course_name cannot be omitted; optional columns remain nullable. section 6.2.1

Course table

The ezy_course_c6 definition marks tutor_id and course_name as INT not null and varchar(140) not null. course_description and other unmarked fields remain optional, matching Option<T> fields in the Rust Course struct. section 6.2.1

How Rust Servers, Services, and Apps covers it

How deep it goes
Defines required columns in SQL and aligns them with non-optional Rust fields, without detailing constraint internals.
Examples
Uses tutor_id and course_name in the ezy_course_c6 SQL table, with psql commands for execution and inspection.
What it assumes
Assumes corresponding Course, CreateCourse, and UpdateCourse structs and a physical database table.
What you can do after
Operate/configure a SQL schema with required columns and verify it through psql.
How it connects
Connects database schema, Rust structs, Option types, primary keys, and default values.

Also explained in

Compare how 6 books explain not-null constraint →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust Servers, Services, and Apps. The section links point to the parts of the book it draws on.