Skip to main content

Ontologies in Graphora

An ontology is a formal specification of the entities, relationships, and rules that define a domain of knowledge. In Graphora, ontologies serve as the blueprint for your knowledge graph, defining what types of entities can exist, what properties they can have, and how they can relate to each other.

Why Ontologies Matter

Ontologies provide several key benefits:
  • Structure: They define the schema for your knowledge graph
  • Validation: They ensure data consistency and quality
  • Inference: They enable logical reasoning about your data
  • Interoperability: They facilitate data sharing and integration

Ontology Structure in Graphora

A Graphora ontology is defined in YAML format and consists of two main components: version information and entity definitions (which include their relationships).

1. Version Information

Basic version information about the ontology:

2. Entities

Definitions of the entity types in your domain, including their properties and relationships:
Each entity has:
  • A unique name (as the key in the entities dictionary)
  • A set of properties, each with:
    • A type (string, integer, etc.)
    • A description
    • Optional constraints (unique, required, index)
  • A set of relationships to other entities, each with:
    • A target entity type
    • Optional cardinality specification
    • Optional properties with constraints

Working with Ontologies in the Client Library

The Graphora client library provides methods for registering and retrieving ontologies:

Registering an Ontology

Retrieving an Ontology

Best Practices for Ontology Design

When designing ontologies for Graphora, consider these best practices:
  1. Start simple: Begin with the core entities and relationships, then expand
  2. Use clear names: Choose descriptive, consistent names for entities and relationships
  3. Define constraints: Use property constraints to ensure data quality
  4. Document thoroughly: Include descriptions for entities, relationships, and properties
  5. Test with real data: Validate your ontology with representative data samples

Complete Ontology Example

Here’s a complete example of a financial reporting ontology:
This ontology defines entities like Metadata, Company, Business, and RiskFactor, along with their properties and relationships. Each property has a type, description, and optional constraints like unique, required, and index.

Next Steps