liveBook · Manning

Schema

As explained in Digital Twins in Action

A schema is a formal specification of the concepts, relationships, properties, or structures that organize information in a domain or system.

A schema specifies what data a system exposes and how its parts relate. In a GraphQL API, it is a contract for available queries. For a digital twin, it also models the physical system: spaces contain sensors, and measurements gain meaning from the spaces and sensors they describe. A schema based on the RealEstateCore ontology uses a shared vocabulary rather than an isolated custom model. section 5.6.3

Listing 5.5 GraphQL query schema for a home twin
type Query {  #1
  spaces(space: String!, start_date: String!,
    end_date: String!): [Space!]!
}

type Space {  #2
  name: String!
  sensors: [Sensor!]!
  documents: [Document!]!
  images: [Image!]!
  measurements: [MeasurementGroup!]!
}

type Sensor {
  id: String!
  space: String!
}

type Document {
  id: String!
  url: String!
}

type Image {
  id: String!
  url: String!
}

type MeasurementGroup {
  name: String!
  unit: String
  values: [Measurement!]!
}

type Measurement {
  sensor_id: String!
  timestamp: String!
  value: Float!
}

The home-twin query schema makes those relationships concrete. A query requests spaces within a date range; each space exposes sensors, documents, images, and grouped measurements. Required fields and lists state what clients can expect. section 5.6.3

One query over multiple sources

A smaller weather API exposes a `weather(city)` query. Its resolver first obtains the city’s coordinates from a geocoding API, then requests forecast data from Open-Meteo. The client asks for time, rain, and surface temperature through one GraphQL query rather than coordinating both calls. section 5.6.3

A production schema must evolve without surprising its consumers:

  • Prefer additive fields. Adding `power_kw` can preserve existing consumers; renaming `temperature` to `temp_c` can silently break them. section 10.3.3
  • Keep telemetry ingestion, state storage, analytics, and actuation loosely coupled so a new sensor field does not force every downstream consumer to be redeployed. section 10.3.3
  • Reassess schema choices at industrial data volumes: decisions that work for thousands of daily readings may perform poorly at millions. section 4.5.4

How Digital Twins in Action covers it

How deep it goes
Defines the contract, shows home-twin types and a small working API, then addresses compatibility; it does not specify a migration procedure.
Examples
Uses a home-twin query schema and a city-weather query that combines geocoding with forecast data.
What you can do after
Build it from scratch as a small GraphQL API, and evaluate schema changes for downstream compatibility.
How it connects
Connects GraphQL to ontologies, digital twins, sensor measurements, interoperability, and change management.

Also explained in

Compare how 44 books explain schema →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Digital Twins in Action. The section links point to the parts of the book it draws on.