A knowledge graph is a graph of entities, their types and their relationships, organised around a documented vocabulary and maintained as a queryable dataset. It differs from a collection of RDF triples in three respects: entities have stable identifiers, the vocabulary is documented, and the graph is maintained over time. Open data adds a fourth condition: the sources are published under licences that permit reuse, which makes the graph publishable in turn, subject to attribution and share-alike terms.
Building such a graph from open data is not a format conversion. A CSV file and a GeoJSON file can be converted to RDF mechanically, but the result is usually a set of tables in triples, not a graph that answers questions across sources. The work is in modelling, identity and reconciliation.
From open data to a knowledge graph
Open data portals publish files: CSV, JSON, XML, GeoJSON, shapefiles, spreadsheets and PDFs. Each file is designed for a publisher's process, not for integration. Column names differ between releases, codes are undocumented, units are implicit, and the same entity appears under different keys in different files. A knowledge graph imposes a single entity model on this material and keeps links back to the source records.
The first design decision is the set of questions the graph must answer. These are usually called competency questions. A question such as "which bus stops lie in each district, and what population does each route serve?" determines which entities, relationships and identifiers are needed. Without such questions, the graph tends to model everything and answer nothing.
A pipeline for knowledge graph construction
- Scope and questions. Write the competency questions and the expected result shape. Decide which sources are in scope and which are out of scope for the first release.
- Source inventory and licence review. Record the publisher, version, update cadence, attribution requirements and any restrictions on personal data or derived works.
- Profiling. Examine keys, missing values, code lists, units, date formats and coordinate reference systems. A column called
yearmay contain a fiscal year, a calendar year or a string. - Vocabulary design. Reuse existing terms where they fit and define local terms only where they do not. Document the meaning, domain and range of each term.
- Mapping. Transform rows into triples, either with a direct mapping from a relational schema or with an explicit mapping language. Mint IRIs from stable source keys, not from labels.
- Entity resolution. Find duplicates within a source and matches across sources. Use blocking keys, similarity measures and manual review; record the method and confidence for each link.
- Fusion. Choose values when sources disagree, record provenance for the chosen value, and keep conflicting statements when the conflict is informative rather than an error.
- Validation. Parse the output, test constraints, sample the links and compare aggregate counts with the sources. Treat validation as a release gate, not a final inspection.
- Publication and maintenance. Expose dereferenceable IRIs, a dump, an endpoint and dataset metadata. Schedule refresh, change detection and deprecation.
A worked example: a city transport graph
A city publishes three files. stops.csv contains stop_id, name, latitude, longitude and route codes. districts.geojson contains district_code, name and polygon geometry. population.csv contains district_code, year and population. The graph needs bus stops, districts, routes and population observations, linked so that a query can aggregate stops by district and population by district.
stop_idtoex:stop/{id}- Stable source key, not the stop name.
latitudeandlongitudetogeo:latandgeo:long- WGS84, typed as
xsd:decimal. district_codetoex:district/{code}- Authoritative where present.
populationandyeartoex:populationandex:asOf- An observation, not a fixed property.
Each stop receives an IRI derived from the publisher's key. Coordinates become typed literals with a declared reference system. If the stop file has a district code, that code is used. A spatial containment test is a fallback, because a stop on a boundary can fall into either polygon depending on the geometry engine, and a derived district should be marked as derived.
Population is modelled as an observation rather than as a property of the district. A district has a population value for a year, from a source. This allows several years and several sources to coexist. A fuller model uses an observation resource with a value, a time and a provenance record; the simpler form is adequate when only one source and one year are in scope.
Entity resolution is the hardest stage. Stop names repeat across operators, and a name is not an identifier. Matching uses proximity, route overlap and the national stop registry where one exists. A confident match can be asserted with owl:sameAs when the external resource is the same entity; a concept-level equivalence uses skos:exactMatch. A probable match should be recorded as a local link with a confidence value and kept out of identity reasoning.
Failure modes
- Identifier churn. Source keys are reused or reassigned. Version the IRIs and keep the previous identifiers as
owl:sameAsor redirects. - Unit and coordinate errors. Metres mixed with feet, or WGS84 mixed with a local grid. Declare units and reference systems in the data, not only in a README.
- Over-linking.
owl:sameAsto an ambiguous external entity merges unrelated statements. Require evidence and prefer a weaker match predicate where identity is uncertain. - Blank nodes as public identifiers. A blank node cannot be referenced from outside the graph, so it cannot serve as an entity identifier for consumers.
- Licence laundering. Derived data inherits attribution and share-alike requirements. Record the licence per source and check compatibility before publication.
- Stale graph. One-off publication decays. Schedule refresh, detect source schema changes and publish a changelog.
- Aggregation traps. Summing populations across overlapping districts double-counts. Aggregate over distinct entities and state the spatial assumptions.
What makes it a knowledge graph
A graph becomes a knowledge graph when it has an explicit vocabulary, stable entity identifiers, links that carry meaning, provenance for statements and a maintenance process. RDF is a convenient encoding for these properties, but it is not sufficient on its own. A triple store filled with untyped strings and duplicate entities is a data dump with a graph syntax.
The test is a query that crosses sources. If the graph can answer "which districts are served by route 12, and how has their population changed since 2010?" without a manual join in a spreadsheet, the modelling and reconciliation work has succeeded. If it cannot, the missing piece is usually identity rather than syntax.
The construction steps above connect to the rest of the stack. Linked data supplies the publication principles, RDF and SPARQL supply the data model and query language, and ontology design supplies the vocabulary. Tools such as Silk and D2R Server automate link discovery and relational mapping, but they do not make the modelling decisions.