Glossaire
DataIA

Schema

Aussi : Data Schema, Database Schema, Data Model Definition

A schema is the formal blueprint that defines how data is structured, named, typed, and related within a database, file, or message.

What It Is

A schema is a formal definition of how data is organized. It specifies the entities (tables, objects, or fields), their names, their data types, and the relationships and constraints that connect them. Think of it as the blueprint for data: it describes the shape that data must follow before any actual values are stored or exchanged.

Schemas appear in many contexts:

  • Database schema: tables, columns, primary and foreign keys, indexes, and constraints in a relational system.
  • Data interchange schema: structures like JSON Schema, Avro, Protobuf, or XSD that validate messages passed between systems.
  • Analytics schema: dimensional models such as star or snowflake schemas used in data warehouses.

Why it matters

A schema is the contract between the people and systems that produce data and those that consume it. Without it, data quality and interoperability break down.

  • Consistency: every record follows the same rules, so a field like `birth_date` always holds a valid date.
  • Validation: invalid or malformed data can be rejected early, before it pollutes downstream reports or models.
  • Communication: teams in data, marketing, finance, and AI can agree on field meanings without ambiguity.
  • Governance: schemas support lineage, access control, and regulatory compliance.

For AI workflows, schemas matter because models depend on stable, well typed feature inputs. A silent schema change (a column renamed or a type altered) can degrade a model without raising an obvious error.

How it is used in practice

In practice, teams design a schema before building pipelines, then enforce it with validation tools. A schema-on-write approach validates data as it is stored (typical of relational databases). A schema-on-read approach applies structure when the data is queried (common in data lakes). Modern platforms often use a schema registry to version schemas and manage compatibility as systems evolve.

Concrete Example

A `customers` table might define:

  • `customer_id`: integer, primary key, not null
  • `email`: string, unique, not null
  • `signup_date`: date
  • `country`: string, max length 2

An order record references `customer_id` as a foreign key. The schema guarantees every order links to a real customer, and that `email` is never empty, keeping the dataset reliable for analytics and AI.

Schema as a Data Blueprintcustomerscustomer_id : int (PK)email : string (unique)signup_date : datecountry : string(2)not null constraintsordersorder_id : int (PK)customer_id : int (FK)amount : decimalorder_date : dateFK linkNames, types, keys, and relationships define the contract
A relational schema defines fields, types, keys, and the relationship between tables.