TrustGraphGet Started
key conceptsintermediate

Semantic Web

Understand the Semantic Web vision of machine-readable, interconnected data. Learn about RDF, SPARQL, linked data, and how TrustGraph implements Semantic Web principles.

9 min read
Updated 12/24/2025
TrustGraph Team
#semantic-web#rdf#linked-data#sparql#w3c

Semantic Web

The Semantic Web is a vision of the World Wide Web where data is structured, linked, and annotated with meaning (semantics) so that machines can understand and reason about information. Rather than web pages for humans, the Semantic Web creates a web of data that machines can process intelligently. TrustGraph implements Semantic Web principles through Knowledge Graphs, RDF support, and semantic standards.

The Vision: From Documents to Data

Traditional Web (Web 1.0/2.0)

<!-- Human-readable HTML -->
<div>
  <h1>Alice Johnson</h1>
  <p>Works at TechCorp since 2020</p>
  <p>Email: alice@techcorp.com</p>
</div>

Problems:

  • ❌ Machines can't understand meaning
  • ❌ Data locked in HTML structure
  • ❌ No way to link related data across sites
  • ❌ Can't query or reason about information

Semantic Web (Web 3.0)

# Machine-readable RDF
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix org: <http://www.w3.org/ns/org#> .

<http://example.org/people/alice> a foaf:Person ;
    foaf:name "Alice Johnson" ;
    foaf:mbox <mailto:alice@techcorp.com> ;
    org:memberOf <http://example.org/orgs/techcorp> ;
    org:memberSince "2020-01-15"^^xsd:date .

<http://example.org/orgs/techcorp> a org:Organization ;
    foaf:name "TechCorp" .

Benefits:

  • ✅ Machines understand meaning (Person, Organization, memberOf)
  • ✅ Data is structured and queryable
  • ✅ Links across datasets (URIs)
  • ✅ Can reason and infer new knowledge
  • ✅ Interoperable standards (RDF, OWL, SPARQL)

Core Semantic Web Technologies

1. RDF (Resource Description Framework)

RDF represents knowledge as triples: Subject-Predicate-Object

# RDF Triples
<Alice>     <worksAt>      <TechCorp>
(Subject)   (Predicate)    (Object)

<TechCorp>  <locatedIn>    <San Francisco>
<Alice>     <hasSkill>     <Python>
<Python>    <type>         <ProgrammingLanguage>

RDF in TrustGraph:

// Import RDF data
await trustgraph.importRDF({
  source: "data/knowledge.ttl",
  format: "turtle",  // or "rdf-xml", "n-triples", "json-ld"

  // Map RDF to property graph
  mapping: {
    predicates: {
      "foaf:knows": "KNOWS",
      "org:memberOf": "WORKS_AT",
      "rdfs:subClassOf": "IS_A"
    }
  }
});

// Export to RDF
await trustgraph.exportRDF({
  output: "knowledge.ttl",
  format: "turtle",
  includeOntology: true
});

2. URIs (Uniform Resource Identifiers)

URIs uniquely identify resources globally:

# Global URIs enable linking across datasets
<http://dbpedia.org/resource/Machine_Learning>
    rdfs:label "Machine Learning" ;
    owl:sameAs <http://wikidata.org/entity/Q2539> ;  # Link to Wikidata
    owl:sameAs <http://example.org/concepts/ml> .    # Link to your data

Benefits:

  • Unique global identifiers
  • No naming conflicts
  • Link data across systems
  • Dereferenceable (can fetch information)

3. RDFS (RDF Schema)

Defines vocabularies with types and hierarchies:

# RDFS Schema
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix : <http://example.org/schema#> .

# Class definitions
:Person a rdfs:Class ;
    rdfs:label "Person" ;
    rdfs:comment "A human being" .

:Employee a rdfs:Class ;
    rdfs:subClassOf :Person ;  # Employee is_a Person
    rdfs:label "Employee" .

# Property definitions
:worksAt a rdf:Property ;
    rdfs:domain :Employee ;     # worksAt applies to Employees
    rdfs:range :Organization ;  # worksAt points to Organizations
    rdfs:label "works at" .

4. OWL (Web Ontology Language)

Adds formal logic and reasoning:

# OWL Ontology
@prefix owl: <http://www.w3.org/2002/07/owl#> .

# Class axioms
:Manager a owl:Class ;
    owl:equivalentClass [
        a owl:Restriction ;
        owl:onProperty :manages ;
        owl:minCardinality 1  # Manager must manage at least 1 person
    ] .

# Property axioms
:manages a owl:ObjectProperty ;
    owl:domain :Manager ;
    owl:range :Employee ;
    a owl:TransitiveProperty .  # If A manages B and B manages C, A manages C

# Inference rules
:CEO a owl:Class ;
    rdfs:subClassOf :Manager ;
    rdfs:subClassOf :Employee .

Reasoning in TrustGraph:

// Load OWL ontology
await trustgraph.loadOntology({
  file: "ontologies/organization.owl",
  reasoner: "owlrl"  // Apply OWL RL reasoning
});

// Query with reasoning
const results = await trustgraph.query({
  query: "Find all people managed by CEO (directly or indirectly)",
  reasoning: true  // Uses transitive property of 'manages'
});

5. SPARQL (Query Language)

Query RDF data with a SQL-like language:

# SPARQL Query
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX org: <http://www.w3.org/ns/org#>

SELECT ?person ?name ?company
WHERE {
  ?person a foaf:Person ;
          foaf:name ?name ;
          org:memberOf ?org .

  ?org foaf:name ?company .

  FILTER (?company = "TechCorp")
}
ORDER BY ?name

SPARQL in TrustGraph:

// Execute SPARQL query
const results = await trustgraph.sparql({
  query: `
    PREFIX foaf: <http://xmlns.com/foaf/0.1/>

    SELECT ?person ?name
    WHERE {
      ?person a foaf:Person ;
              foaf:name ?name .
    }
    LIMIT 10
  `
});

console.log(results);
// [
//   { person: "http://example.org/alice", name: "Alice Johnson" },
//   { person: "http://example.org/bob", name: "Bob Smith" },
//   ...
// ]

Linked Data Principles

The Semantic Web is built on Linked Data principles:

1. Use URIs to Name Things

# Good: Global URIs
<http://example.org/people/alice> foaf:name "Alice" .

# Bad: Local IDs
<person_123> foaf:name "Alice" .

2. Use HTTP URIs (Dereferenceable)

# Fetch information about a resource
curl -H "Accept: application/rdf+xml" http://dbpedia.org/resource/Berlin

# Returns RDF description of Berlin

3. Provide Useful Information

When someone looks up a URI, return RDF data:

// TrustGraph endpoint returns RDF
GET /entities/alice
Accept: text/turtle

# Returns:
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<http://example.org/people/alice> a foaf:Person ;
    foaf:name "Alice Johnson" ;
    foaf:mbox <mailto:alice@techcorp.com> ;
    org:memberOf <http://example.org/orgs/techcorp> .

4. Link to Other URIs

Create a web of interconnected data:

# Link to external datasets
<http://example.org/people/alice>
    owl:sameAs <http://wikidata.org/entity/Q123456> ;
    foaf:knows <http://example.org/people/bob> ;
    org:memberOf <http://dbpedia.org/resource/TechCorp> .

JSON-LD: JSON for Linked Data

JSON-LD brings Semantic Web to JSON:

{
  "@context": "https://schema.org",
  "@type": "Person",
  "@id": "http://example.org/people/alice",
  "name": "Alice Johnson",
  "email": "alice@techcorp.com",
  "worksFor": {
    "@type": "Organization",
    "@id": "http://example.org/orgs/techcorp",
    "name": "TechCorp"
  },
  "knows": [
    {
      "@type": "Person",
      "@id": "http://example.org/people/bob",
      "name": "Bob Smith"
    }
  ]
}

Benefits:

  • Familiar JSON syntax
  • Semantic meaning via @context
  • Embeddable in web pages
  • Converts to RDF triples

TrustGraph JSON-LD Support:

// Import JSON-LD
await trustgraph.importJSONLD({
  source: "data/people.jsonld",
  context: "https://schema.org"
});

// Export JSON-LD
const jsonld = await trustgraph.exportJSONLD({
  entities: ["person_alice", "person_bob"],
  context: "https://schema.org"
});

Semantic Web Use Cases

1. Knowledge Integration

Combine data from multiple sources:

// Import data from different sources
await trustgraph.importRDF({
  sources: [
    "http://dbpedia.org/sparql",      // DBpedia SPARQL endpoint
    "local_data/companies.ttl",       // Local RDF file
    "http://wikidata.org/sparql"      // Wikidata SPARQL endpoint
  ],

  // Link entities using owl:sameAs
  linkEntities: true,

  // Resolve conflicts
  conflictResolution: "prefer_local"
});

// Unified knowledge graph from multiple sources
const results = await trustgraph.query({
  query: "Find all companies and their information from all sources"
});

2. Semantic Search

Search by meaning across domains:

const results = await trustgraph.semanticSearch({
  query: "French capitals",

  // Expands query using semantic relationships:
  // "French" -> dbpedia:France
  // "capital" -> dbpedia:capitalOf
  // Finds: Paris capitalOf France

  linkedDataSources: ["dbpedia", "wikidata"],
  reasoning: true
});

3. Intelligent Agents

Agents that understand and reason:

const agent = await trustgraph.createAgent({
  id: "research_agent",

  // Agent can query Semantic Web
  linkedDataAccess: true,

  ontologies: [
    "http://xmlns.com/foaf/0.1/",
    "http://purl.org/dc/terms/",
    "https://schema.org"
  ]
});

// Agent understands semantic relationships
await agent.query("Who are colleagues of Alice?");

// Agent reasons:
// Alice worksAt TechCorp
// Bob worksAt TechCorp
// Therefore: Alice and Bob are colleagues (inferred)

4. Data Publishing

Publish machine-readable data:

// Publish Knowledge Graph as Linked Data
await trustgraph.publish({
  endpoint: "http://example.org/sparql",

  // Provide SPARQL endpoint
  sparql: true,

  // Provide REST API with content negotiation
  rest: true,

  // Support formats
  formats: ["turtle", "rdf-xml", "json-ld", "n-triples"],

  // Dereferenceable URIs
  contentNegotiation: true
});

// Now others can query your data:
// GET http://example.org/people/alice
// Accept: text/turtle

Semantic Web in TrustGraph

TrustGraph combines Property Graphs with Semantic Web standards:

RDF Import/Export

// Import RDF (Turtle, RDF/XML, N-Triples)
await trustgraph.importRDF({
  source: "knowledge.ttl",
  format: "turtle"
});

// Export to RDF
await trustgraph.exportRDF({
  output: "knowledge.ttl",
  format: "turtle",
  includeOntology: true
});

SPARQL Support

// Execute SPARQL queries
const results = await trustgraph.sparql({
  query: `
    SELECT ?person ?skill
    WHERE {
      ?person a :Person ;
              :hasSkill ?skill .
    }
  `
});

Ontology Reasoning

// Load OWL ontology
await trustgraph.loadOntology("ontologies/domain.owl");

// Queries use ontology reasoning
const results = await trustgraph.query({
  query: "Find all Managers",
  reasoning: true  // Includes inferred Managers
});

Linked Data Publishing

// Publish as Linked Data
await trustgraph.enableLinkedData({
  baseURI: "http://example.org/",
  sparqlEndpoint: true,
  contentNegotiation: true,
  formats: ["turtle", "json-ld", "rdf-xml"]
});

Semantic Web Standards Stack

┌─────────────────────────────────────┐
│         Applications                │
│  (Agents, Search, Integration)      │
└─────────────────────────────────────┘
┌─────────────────────────────────────┐
│     Query & Logic Layer             │
│   SPARQL, OWL, SWRL, Rules          │
└─────────────────────────────────────┘
┌─────────────────────────────────────┐
│      Ontology Layer                 │
│     OWL, RDFS, SKOS                 │
└─────────────────────────────────────┘
┌─────────────────────────────────────┐
│      Data Layer                     │
│      RDF, JSON-LD                   │
└─────────────────────────────────────┘
┌─────────────────────────────────────┐
│      Syntax Layer                   │
│  Turtle, RDF/XML, N-Triples         │
└─────────────────────────────────────┘
┌─────────────────────────────────────┐
│      Identifier Layer               │
│      URI, IRI                       │
└─────────────────────────────────────┘

Benefits of Semantic Web

  1. Machine-Understandable: Machines can interpret meaning
  2. Interoperability: Standards enable data exchange
  3. Reasoning: Infer new knowledge automatically
  4. Linked Data: Connect information globally
  5. Decentralized: No single point of control
  6. Extensible: Add new vocabularies and ontologies
  7. Querying: Powerful SPARQL query language
  8. Integration: Combine data from multiple sources

Challenges and Limitations

  1. Complexity: Steep learning curve for RDF/OWL/SPARQL
  2. Performance: Reasoning can be computationally expensive
  3. Adoption: Limited adoption compared to traditional databases
  4. Tooling: Fewer tools compared to relational/document databases
  5. Data Quality: Linked Data quality varies across sources
  6. URIs: Managing and maintaining stable URIs is challenging

Best Practices

  1. Use Standard Vocabularies: Schema.org, FOAF, Dublin Core
  2. Provide Clear URIs: Stable, dereferenceable identifiers
  3. Document Ontologies: Clear definitions and examples
  4. Version Control: Track ontology changes
  5. Content Negotiation: Support multiple RDF formats
  6. Link to External Data: Use owl:sameAs for entity linking
  7. Validate Data: Check RDF syntax and ontology compliance
  8. Optimize Performance: Index frequently queried predicates

Related Concepts

Learn More