Database schema
The blueprint of a database: which tables exist, their columns and how they connect.
A database schema is the description of how a database is organized: which tables it has, which columns each table has, what type of value goes in each column (a number, a date, some text), which columns are required, and how tables relate to each other. It describes the shape of the data, not the data itself.
Take an online shop. The schema might say there is a customers table with an id, a name and an email that cannot be empty, and an orders table with an id, a customer_id, a total with two decimals and a created_at date. With that in place, the database refuses an order with a total of "banana" or with no customer. In SQL, the schema is written with commands like CREATE TABLE and changed with ALTER TABLE.
Schemas change as products change, and that is delicate: renaming a column can break every report and app that reads it. Teams handle this with migrations, small versioned scripts that change the schema step by step and can be reviewed like code. The word also has a narrower meaning in some databases, such as PostgreSQL, where a schema is a named folder that groups tables.
Keep in mind
- Defines tables, columns, data types, required fields and relationships.
- Lets the database reject data with the wrong shape.
- Written and changed in SQL, ideally through versioned migrations.
- A warehouse checks the schema on write; a data lake applies it on read.