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:
Find all files:
Get specific properties:
Filtering by Properties
Find nodes with specific labels:
Querying Edges
Simple Edge Queries
Count all relationships:
Find all relationships by type:
Get edge details:
Joins Between Nodes and Edges
Find Connected Nodes
Get source nodes with their relationships:
Find files that contain other entities:
WHERE Clauses
Label Filtering
Find specific node types:
Combined Conditions
Aggregations
Count by Label
Edge Type Statistics
ORDER BY and LIMIT
Pagination
Get first 10 nodes:
Skip first 10, get next 10:
Order by label:
Complex Queries
Multi-Table Joins
Find all relationships with full node details:
Nested Aggregations
Try Your Own Queries!
Experiment with your own SQL queries:
Available Tables
The SQL interface provides access to:
-
nodes: Graph nodes with columns:
id(String): Unique node identifierlabel(String): Node type/labelproperties(JSON String): Node properties
-
edges: Graph relationships with columns:
id(String): Unique edge identifierfrom_node(String): Source node IDto_node(String): Target node IDedge_type(String): Relationship typeproperties(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
- KQL Syntax - Learn graph-oriented queries
- Automation API - Programmatic access
- Architecture - How queries are executed