← Module 05 · Database & SQL
05 · DATABASE & SQL · NEW TOPIC

Schema

A database schema is the blueprint that defines how database data and objects are structured.

01 · What is it?

A schema is the blueprint for a database.

It describes which objects exist, how they are organized, and what rules connect them. A schema can define tables, columns, data types, relationships, constraints, and indexes.

Simple Definition: A schema describes the shape and rules of database data.

02 · Think of it like…

Think of a schema as the floor plan for an organized building.

The building is the database. Rooms are tables, labeled spaces are columns, and doors between rooms are relationships. The floor plan tells people where things belong before anything is stored.

DATABASE→SCHEMA→TABLES→ROWS

03 · What does it do?

A schema gives the database a shared structure and set of rules. It helps software know:

What can existTables, views, functions, and other objects.
What data looks likeColumns, data types, and allowed values.
How data connectsRelationships between tables and records.
What rules applyConstraints that protect data quality.
How to find itIndexes that support efficient access.

04 · Where is it used?

Schemas are used anywhere an application needs structured, reliable data.

Product databasesUsers, orders, products, and payments.
Team-owned dataSeparate namespaces for different services or teams.
Database toolsObject browsers and query tools use schemas to organize what they show.
Application deliveryMigrations create and update schema structure across environments.

05 · Example

A migration can define a schema and then create a table inside it.

CREATE SCHEMA shop;

CREATE TABLE shop.orders (
  order_id INTEGER PRIMARY KEY,
  customer_id INTEGER NOT NULL,
  total DECIMAL(10, 2) NOT NULL,
  created_at TIMESTAMP NOT NULL
);
Schema objectRole
shopThe schema namespace.
ordersA table inside that schema.
order_idA column with a primary-key rule.
created_atA column with a timestamp data type.

06 · How it connects

Application
SQL migration
Schema
Tables & rules
Query results

The application sends SQL or uses a data-access layer; the schema gives those operations a known structure to work with.

07 · Do Not Confuse

Schema ≠ Database

A database is the larger storage system. A schema is an organized structure inside it.

Schema ≠ Table

A schema can contain many tables. A table stores one kind of structured records.

Schema ≠ SQL

SQL is the language used to define or work with data. A schema is the structure being described.

Schema ≠ Data

The schema defines the shape and rules; rows are the actual stored values.

09 · What to Remember

A schema is the blueprint that defines the structure and rules of database objects.

Tables, columns, relationships, constraints, and indexes can all be part of that structure.

SQL migrations change the schema so application code and database structure stay aligned.

Schema→Tables→Rows
↑