RepoSnowflake (Arctic)Snowflake (Arctic)published Apr 24, 2026seen 5d

Snowflake-Labs/ontology-on-snowflake

Python

Open original ↗

Captured source

source ↗

Snowflake-Labs/ontology-on-snowflake

Language: Python

License: Apache-2.0

Stars: 20

Forks: 5

Open issues: 0

Created: 2026-04-24T19:40:39Z

Pushed: 2026-05-13T14:35:32Z

Default branch: main

Fork: no

Archived: no

README:

Ontology on Snowflake

Unifying Data, Semantics, and AI Reasoning in the Snowflake AI Data Cloud

This repository contains the complete implementation of Ontology on Snowflake - a Snowflake-native ontology platform that transforms Snowflake from a system that manages data into a platform that models real-world business concepts and processes.

Blog Post Series

This implementation is accompanied by a three-part blog series on Medium:

1. [Part 1: Overview and Data Model](https://medium.com/snowflake/ontology-on-snowflake-part-1-overview-and-data-model-9e8eeaac7363) - Introduces the knowledge graph foundation and ontology metadata layer 2. [Part 2: Semantic Models](https://medium.com/snowflake/ontology-on-snowflake-part-2-semantic-models-9aa0fa9b9312) - Covers the three specialized Cortex Analyst semantic models 3. [Part 3: AI-Powered Intelligence](https://medium.com/snowflake/ontology-on-snowflake-part-3-ai-powered-intelligence-bbace87c6be1) - Details Cortex Agent orchestration and graph analytics

Solution Overview

Ontology on Snowflake is delivered as an integrated, end-to-end capability across three parts (aligned with the blog post series):

| Part | Blog Post | Layer(s) | What's Built | |------|-----------|----------|--------------| | Part 1 | *Overview and Data Model* | 1–3 | KG_NODE, KG_EDGE tables + ontology metadata + abstract views | | Part 2 | *Semantic Models* | 4 | Three specialized Cortex Analyst semantic models | | Part 3 | *AI-Powered Intelligence* | 5 | Cortex Agent + graph analytics tools |

What Each Part Covers

1. Part 1 – Data Model (Layers 1-3): A flexible object–relationship foundation with ontology metadata that captures business meaning natively in Snowflake. Creates KG_NODE and KG_EDGE tables, ontology metadata tables (ONT_CLASS, ONT_RELATION_DEF, etc.), and generated abstract views (VW_ONT_PERSON, VW_ONT_WORKS_FOR).

2. Part 2 – Semantic Models (Layer 4): Purpose-built semantic models optimized for concrete queries (Knowledge Graph Model), abstract reasoning (Ontology Model), and governance (Metadata & Governance Model).

3. Part 3 – AI-Powered Intelligence (Layer 5): Intelligent agent orchestration with Cortex Agent, graph-powered reasoning via NetworkX, and natural-language interaction across all semantic models.

Five-Layer Architecture

![Ontology on Snowflake Architecture](blog_image_architecture.png)

Layer Summary:

  • Layer 5 - Cortex Agent: Orchestrates semantic models and graph analytics tools
  • Layer 4 - Semantic Models: Knowledge Graph (concrete), Ontology (abstract), Metadata (introspection), Graph Analytics (algorithms)
  • Layer 3 - Generated Views: Auto-generated abstract views (VW_ONT_PERSON, VW_ONT_WORKS_FOR)
  • Layer 2 - Ontology Metadata: Classes, relationships, properties, permissions, inference rules
  • Layer 1 - Physical Storage: KG_NODE (entities) + KG_EDGE (relationships)

Repository Structure

ontology_on_snowflake/
├── README.md # This file
├── data/ # Sample data files
│ ├── clubs.json # Soccer clubs
│ ├── persons.json # Players and coaches
│ ├── player_contracts.json # Player-club contracts
│ ├── coach_contracts.json # Coach-club contracts
│ ├── matches.json # Soccer matches
│ ├── match_appearances.json # Player match appearances
│ └── metadata.json # Additional metadata
├── sql/ # SQL scripts (run in order)
│ ├── 00_setup.sql # Database and schema creation
│ ├── 01_physical_layer.sql # KG_NODE and KG_EDGE tables
│ ├── 02_entity_views.sql # V_PLAYER, V_COACH, V_CLUB, V_MATCH
│ ├── 03_relationship_views.sql # V_PLAYS_FOR, V_COACHES, etc.
│ ├── 04_ontology_metadata.sql # Ontology metadata tables
│ ├── 05_ontology_views_generator.sql # SP_GENERATE_ONTOLOGY_VIEWS procedure
│ ├── 06_inference_procedures.sql # Inference and constraint procedures
│ ├── 07_abstract_views.sql # Pre-built abstract ontology views
│ ├── 08_seed_metadata.sql # Seed ontology metadata
│ └── 09_load_data.sql # Load sample data
├── semantic_models/ # Cortex Analyst semantic models
│ ├── soccer_semantic_model.yml # Concrete knowledge graph model
│ ├── soccer_semantic_model_ontology.yml # Abstract ontology model
│ └── soccer_metadata_governance_model.yml # Metadata and governance model
├── agent/ # Cortex Agent configuration
│ └── cortex_agent_config.json # Agent orchestration config (8 tools)
└── mcp_server/ # SPCS graph analytics service
├── soccer_mcp_server.py # Graph analytics server with 5 tools
├── requirements.txt # Python dependencies
├── Dockerfile # Container build for SPCS
├── service.yaml # SPCS service specification
├── deploy_spcs.sh # Deployment automation script
├── deploy_to_spcs.sql # Snowflake infrastructure setup
├── spcs_service_functions.sql # Service functions for Cortex Agent
├── SPCS_DEPLOYMENT_GUIDE.md # Complete deployment guide
├── README.md # MCP server documentation
└── graph_data/ # Static JSON data for graph analytics
├── persons.json # 41 players + 11 coaches
├── clubs.json # 15 soccer clubs
├── matches.json # 20 matches
├── player_contracts.json # Player contract history
├── coach_contracts.json # Coach contract history
├── match_appearances.json # Player match statistics
└── metadata.json # Data summary

Quick Start

Prerequisites

  • Snowflake account with a role that has sufficient privileges (see below). ACCOUNTADMIN works but a least-privilege role is recommended -- see mcp_server/deploy_to_spcs.sql for an example setup.
  • Access to Cortex Analyst and Cortex Agent (preview features)
  • Docker (optional, for SPCS graph analytics deployment)

Step 1: Create Database and Schema (Part 1 - Layers 1-2)

Open a Snowflake worksheet and run the SQL scripts in order. These scripts create the database ONTOLOGY_DB with schema SOCCER_KG:

-- Connect to Snowflake
-- Use a role with CREATE DATABASE, CREATE SCHEMA, and CREATE STAGE privileges.
-- ACCOUNTADMIN works but a dedicated role is recommended (see deploy_to_spcs.sql).
USE ROLE ACCOUNTADMIN;

-- 1. Create database and schema
-- Run: sql/00_setup.sql
CREATE OR REPLACE DATABASE ONTOLOGY_DB;
USE DATABASE ONTOLOGY_DB;
CREATE OR REPLACE SCHEMA SOCCER_KG;
USE SCHEMA SOCCER_KG;

-- 2. Create physical layer (Layer 1: KG_NODE and…

Excerpt shown — open the source for the full document.

Notability

notability 3.0/10

Low-star routine repo from Snowflake