What is Schema?
The formal definition of a data structure — its fields, types, and constraints.
Definition
A schema is the contract describing what valid data looks like: which fields exist, what types they hold, which are required, and what relationships and constraints apply. Relational databases enforce schema on write, rejecting malformed rows at the door; document stores often defer to schema-on-read, pushing validation into the application, which is faster to iterate on and easier to get wrong. The concept spans layers—JSON Schema for API payloads, GraphQL SDL for graph types, Zod and Pydantic for runtime validation at application boundaries, Avro and Protobuf for wire formats. Schema evolution is the hard part in production: adding optional fields is safe, removing or retyping them breaks consumers, which is why versioned schemas and compatibility checks belong in CI.

