Skip to main content

SQL Syntax

KnowledgeFlowDB supports standard SQL queries over the graph data model, providing a familiar interface for relational-style queries.

Basic Query Structure

SELECT columns
FROM table
[WHERE condition]
[ORDER BY field [ASC|DESC]]
[LIMIT n]
[OFFSET m]

Querying Nodes

Simple Node Queries

Count all nodes in the database:

SQL Query
Loading...
Press Ctrl+Enter to run

Find all files:

SQL Query
Loading...
Press Ctrl+Enter to run

Get specific properties:

SQL Query
Loading...
Press Ctrl+Enter to run

Filtering by Properties

Find nodes with specific labels:

SQL Query
Loading...
Press Ctrl+Enter to run

Querying Edges

Simple Edge Queries

Count all relationships:

SQL Query
Loading...
Press Ctrl+Enter to run

Find all relationships by type:

SQL Query
Loading...
Press Ctrl+Enter to run

Get edge details:

SQL Query
Loading...
Press Ctrl+Enter to run

Joins Between Nodes and Edges

Find Connected Nodes

Get source nodes with their relationships:

SQL Query
Loading...
Press Ctrl+Enter to run

Find files that contain other entities:

SQL Query
Loading...
Press Ctrl+Enter to run

WHERE Clauses

Label Filtering

Find specific node types:

SQL Query
Loading...
Press Ctrl+Enter to run

Combined Conditions

SQL Query
Loading...
Press Ctrl+Enter to run

Aggregations

Count by Label

SQL Query
Loading...
Press Ctrl+Enter to run

Edge Type Statistics

SQL Query
Loading...
Press Ctrl+Enter to run

ORDER BY and LIMIT

Pagination

Get first 10 nodes:

SQL Query
Loading...
Press Ctrl+Enter to run

Skip first 10, get next 10:

SQL Query
Loading...
Press Ctrl+Enter to run

Order by label:

SQL Query
Loading...
Press Ctrl+Enter to run

Complex Queries

Multi-Table Joins

Find all relationships with full node details:

SQL Query
Loading...
Press Ctrl+Enter to run

Nested Aggregations

SQL Query
Loading...
Press Ctrl+Enter to run

Try Your Own Queries!

Experiment with your own SQL queries:

SQL Query
Loading...
Press Ctrl+Enter to run

Available Tables

The SQL interface provides access to:

  • nodes: Graph nodes with columns:

    • id (String): Unique node identifier
    • label (String): Node type/label
    • properties (JSON String): Node properties
  • edges: Graph relationships with columns:

    • id (String): Unique edge identifier
    • from_node (String): Source node ID
    • to_node (String): Target node ID
    • edge_type (String): Relationship type
    • properties (JSON String): Edge properties

Comparing SQL and KQL

Both query languages access the same underlying graph data:

SQL is great for:

  • Relational-style queries
  • Aggregations and statistics
  • Joins across nodes and edges
  • Familiar syntax for SQL users

KQL is great for:

  • Graph pattern matching
  • Multi-hop traversals
  • Relationship-centric queries
  • Cypher-like graph exploration

Try switching between SQL and KQL in the playground to see the difference!

Next Steps