Ontology Meets AI Agents: From Reasoning to Enterprise Semantic Infrastructure
The article demonstrates how an ontology can serve as a business‑semantic layer for enterprise AI agents, covering multi‑relationship propagation, schema‑to‑concept mapping, cross‑system customer views, and a unified semantic query engine, while also discussing practical limits and rollout advice.
Multi‑Relationship Propagation
Define transitive and non‑transitive object properties in OWL to model business relationships. Example definitions:
class controlledBy (ObjectProperty, TransitiveProperty):
domain = [Organization]
range = [Organization]
class belongsToGroup (ObjectProperty, TransitiveProperty):
domain = [Organization]
range = [Organization]
class guaranteesFor (ObjectProperty):
domain = [Organization]
range = [Organization]Classification rule that uses these properties to identify a “GroupRiskEntity”:
class GroupRiskEntity (Organization):
equivalent_to = [Organization & (
hasRiskFlag.value(True)
| controlledBy.some(hasRiskFlag.value(True))
| belongsToGroup.some(hasRiskFlag.value(True))
)]Schema Mapping Layer
Introduce annotation properties to map ontology classes and attributes to physical tables and columns, eliminating hard‑coded SQL identifiers.
class mapsToTable (AnnotationProperty): pass
class mapsToColumn (AnnotationProperty): pass
Customer.mapsToTable = ["onto_customers"]
customerTier.mapsToColumn = ["tier"]
customerRegion.mapsToColumn = ["region"]Helper that builds a concrete SELECT statement from the ontology:
def build_mapped_query(class_name, property_name, value):
cls = onto.search_one(iri=f"*{class_name}")
prop = onto.search_one(iri=f"*{property_name}")
table = cls.mapsToTable[0]
column = prop.mapsToColumn[0]
return f"SELECT * FROM {table} WHERE {column} = %s", [value]Changing a column name (e.g., tier → customer_level) requires only updating the annotation; the agent code remains unchanged.
Semantic Query Engine
Encode query intent in ontology classes using queryFilter and queryJoin annotation properties. Example concepts:
class queryFilter (AnnotationProperty): pass
class queryJoin (AnnotationProperty): pass
class VIPCustomer (Thing):
queryFilter = ["customerTier=VIP"]
class PendingOrder (Thing):
queryFilter = ["orderStatus=pending"]
class VIPPendingOrder (Thing):
queryFilter = ["orderStatus=pending", "customerTier=VIP"]
queryJoin = ["Customer:orderCustomerId=customerId"]Engine method that reads these annotations, resolves schema mappings, and assembles the final SQL:
def build_semantic_query(self, concept_name: str) -> tuple[str, list]:
"""Read ontology annotations and automatically construct SQL"""
concept = self.onto.search_one(iri=f"*{concept_name}")
filters = concept.queryFilter # list of WHERE clauses
joins = concept.queryJoin # list of JOIN specifications
# Resolve real table/column names via schema mapping (omitted)
# Assemble WHERE and JOIN strings
return sql, paramsAdding a new query type only requires adding a new ontology class with appropriate annotations; no additional agent code is needed.
Combined Capabilities
Transitive relationship definitions enable accurate risk‑impact analysis without manual graph traversal.
Annotation‑based schema mapping decouples business terminology from physical database changes.
Declarative query definitions turn many ad‑hoc tools into a single semantic query engine.
Limitations
Consistent concept vocabularies must be established across departments.
Overlapping rules can create conflicts that require governance.
Schema‑to‑ontology mappings need ongoing maintenance as databases evolve.
Reasoning performance and ontology versioning must be managed.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
AI Large Model Application Practice
Focused on deep research and development of large-model applications. Authors of "RAG Application Development and Optimization Based on Large Models" and "MCP Principles Unveiled and Development Guide". Primarily B2B, with B2C as a supplement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
