Schema
What Schema Is
A schema defines the structure that data is expected to follow.
It usually answers structural questions such as:
- Which fields exist?
- What types do they have?
- Which fields are required?
- Which nested structures are allowed?
- Which values are valid?
Schemas are central to storage, interchange, and validation because they make expected shapes explicit.
Core Building Blocks
The exact details depend on the technology, but most schemas define:
Fields: named elements such asname,email, orcreatedAtTypes: string, number, boolean, object, array, and other domain-specific typesConstraints: required fields, min/max limits, patterns, enumsComposition: nesting, references, inheritance, or reusable fragments
What Schema Is Good At
Schema is valuable when the main problem is making data valid, predictable, and interoperable.
Validation: reject malformed or incomplete dataStorage design: define columns, documents, objects, or messagesAPI contracts: specify request and response shapesTooling: generate clients, forms, migrations, and documentation
Schema works especially well when the system needs reliable data exchange.
Schema Versus Ontology
Schema and ontology often coexist, but they answer different questions.
| Concept | Main question |
|---|---|
| Schema | "What shape must this data have?" |
| Ontology | "What does this data mean?" |
A schema may say:
ownerIdis a required stringstatusmust be one ofdraft,active, orarchived
An ontology may say:
ownermust refer to aTeam, not aPersonarchivedprojects cannot be active work itemsProjectandProgramare distinct concepts with different relations
This is the core difference: schema is about structure and validity, while ontology is about semantics and interpretation.
Practical Example
Suppose an API accepts this shape:
{
"projectId": "p-001",
"ownerId": "team-7",
"status": "active"
}
The schema can validate:
projectIdexistsownerIdis a stringstatusis one of the allowed values
But the schema alone usually cannot express the full semantic meaning of ownerId, such as whether it points to a team, a business unit, or a person. That semantic layer is where ontology helps.
Common Mistakes
- Assuming structural validity guarantees semantic correctness
- Mixing business meaning into poorly named primitive fields
- Letting multiple incompatible schemas represent the same concept
- Treating schema evolution as only a technical concern instead of a semantic one
Summary
Schema defines how data is structured and validated.
It is essential for interoperability and quality control, but it does not automatically provide rich semantics. Use schema for shape and validation. Use ontology when meaning and relationships must also be explicit.