A database schema defines the structure of a database, including tables, columns, data types, relationships, and constraints. It acts as a blueprint that tells the database how information is organized and how different pieces of data connect to each other. Schemas ensure data integrity through rules such as primary keys, foreign keys, and uniqueness constraints.
Why it matters
A clear and well-designed schema improves performance, reduces redundancy, and supports accurate queries. Schema decisions have long-term effects on scalability and maintainability. When schema changes are needed, they are typically managed through database migrations.
Examples
Defining a users table with an ID column, email column, and created_at timestamp is part of a schema. Lessons like Tables, Rows, and Columns illustrate how schemas map to relational structures.