YAML Syntax Reference
This guide provides a comprehensive reference for the YAML syntax used to define ontologies in Graphora. The syntax is designed to be intuitive while supporting advanced features like quality rules and complex relationships.Basic Structure
Every Graphora ontology follows this basic structure:Version Declaration
All ontologies must start with a version declaration:Currently, only version 1 is supported. This field is required for future compatibility.
Entity Definitions
Entities are the core building blocks of your ontology. Each entity represents a type of object in your domain.Entity Naming
- Use PascalCase for entity names (e.g.,
Company,BusinessSegment) - Choose descriptive, singular nouns
- Avoid abbreviations unless they’re widely understood
Property Definitions
Properties define the attributes that entities can have. Each property has a type and optional constraints.Property Types
Graphora supports the following property types:string
string
Text data of any length
integer
integer
Whole numbers (positive, negative, or zero)
float
float
Decimal numbers
boolean
boolean
True or false values
date
date
Date values in YYYY-MM-DD format
Property Constraints
Properties can have various constraints to ensure data quality:Required Properties
Unique Properties
Indexed Properties
Combined Constraints
Complete Property Example
Relationship Definitions
Relationships define how entities connect to each other in your knowledge graph.Relationship Naming
- Use UPPER_CASE with underscores (e.g.,
WORKS_FOR,HAS_SUBSIDIARY) - Choose descriptive verb phrases
- Consider the direction: relationships are directional from source to target
Basic Relationships
Cardinality Constraints
Specify how many entities can be connected through a relationship:oneToOne
oneToOne
Each source entity connects to exactly one target entity
oneToMany
oneToMany
Each source entity can connect to multiple target entities
manyToOne
manyToOne
Multiple source entities can connect to the same target entity
manyToMany
manyToMany
Multiple source entities can connect to multiple target entities
Relationship Properties
Self-Referencing Relationships
Entities can have relationships to themselves:Advanced Features
Multi-Target Relationships
While not directly supported in the syntax, you can model complex relationships using intermediate entities:Conditional Properties
Use descriptions to document business rules that should be enforced:Complete Syntax Example
Here’s a comprehensive example showcasing all syntax features:Validation Rules
The YAML syntax is validated for:- Syntax correctness: Valid YAML format
- Required fields: Version, entities with proper structure
- Type validity: Supported property types only
- Reference integrity: Relationship targets must reference defined entities
- Naming conventions: Entity and relationship names follow recommended patterns
Next Steps
Quality Rules
Learn how to add sophisticated quality validation to your ontology
Examples
Explore complete ontology examples for different domains
