Semantic Web, Ontologies and Knowledge Graphs #
A library may record books, authors and loans in several systems. Giving each entity a stable identifier and agreeing what relationships such as wrote and loaned to mean lets software join data across those systems.
1. From triples to an ontology ☆ #
RDF represents facts as subject–predicate–object triples. The object can be a resource identifier or a literal, such as a title. RDFS adds vocabulary for classes, subclasses, and property domains and ranges. OWL can express richer axioms about classes and properties. SPARQL queries RDF graphs by matching triple patterns.
An ontology describes the concepts, relationships and rules of a domain. A knowledge graph records concrete entities and their relationships. A graph can use the ontology to support inference.
@prefix ex: <https://example.org/library/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
ex:Novel rdfs:subClassOf ex:Book .
ex:RiverStories a ex:Novel ;
ex:writtenBy ex:Aisha ;
rdfs:label "River Stories" .
Under RDFS inference, ex:RiverStories is also an ex:Book. A query can find items written by Aisha using the pattern ?item ex:writtenBy ex:Aisha. Queries that rely on inferred types need an entailment-aware store, precomputed inferred triples or an explicit traversal of subclass links. Under the open-world assumption, a missing fact may simply be unknown.
2. Designing and learning an ontology #
Start with questions the data should answer, such as “Which titles were written by Aisha?” Define classes and relationships around those questions. Reuse an existing vocabulary where it fits, check ambiguous terms with domain experts, and test real records and queries.
Ontology learning proposes terms and relationships from data. A pattern such as “novels and other books” can suggest that Novel is a subclass of Book. A reviewer checks whether the proposed relationship holds for the domain and reconciles it with existing definitions.
3. Building and maintaining a knowledge graph #
- Extract entities and relationships from text or map fields from structured sources.
- Resolve identities so that two authors with the same name stay distinct and variant names for the same author can be merged.
- Map each relationship to the agreed vocabulary. Attach source provenance, particularly when records can disagree or go out of date.
- Validate the graph with sample queries and consistency checks. Review uncertain matches and retain a way to correct them.
A knowledge graph is useful when the relationship itself matters. A vector search can find passages about a book, while the graph can follow the explicit path from the book to its author and then to other titles.