Build the mental model
A server instance contains databases; a database contains schemas; and a schema contains tables and other objects. Schemas are useful naming and permission boundaries. Instead of placing every project object in the default `public` schema, this course uses an `app` schema.
Connect it to a real scenario
Create `app.users` with an identity primary key, email, display name, active flag, and creation time. Schema-qualified names reduce accidental reliance on `search_path` and make the referenced object explicit.
Try the working example
CREATE SCHEMA IF NOT EXISTS app;
CREATE TABLE app.users (
user_id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
email text NOT NULL UNIQUE,
display_name text NOT NULL,
is_active boolean NOT NULL DEFAULT true,
created_at timestamptz NOT NULL DEFAULT now()
);
\d app.users`psql` describes the new `app.users` table, its columns, and constraints.5-minute try-it
Create `app.categories` yourself with an identity key, unique name, and creation time.
One important caution
Quoted MixedCase identifiers require quotes in every query. Prefer consistent lowercase snake_case names.
PostgreSQL — Data Definition — PostgreSQL Global Development Group