Graph queries in SQLY enable working with networked data, such as social connections, recommendation systems, and hierarchical relationships.
SQLY allows traversing relationships between entities using graph_traverse.
query:
select: [user_a, user_b]
from: user_connections
where:
graph_traverse:
start: 42
depth: 1This retrieves all users directly connected to user 42.
Graph traversal supports multi-hop queries to find indirect relationships.
query:
select: [user_a, user_b]
from: user_connections
where:
graph_traverse:
start: 42
depth: 2This finds all friends and their friends (up to two levels away).
SQLY can compute the shortest path between nodes in a graph.
query:
select: [user_a, user_b, path_length]
from: user_connections
where:
shortest_path:
start: 42
end: 99This retrieves the shortest connection path between users 42 and 99.
Some relationships may have weights, such as distances or costs.
query:
select: [source, destination, total_cost]
from: delivery_routes
where:
shortest_path:
start: "Warehouse A"
end: "Customer B"
weight: shipping_costThis retrieves the most cost-effective delivery route.
Graph analytics can group entities based on relationships.
query:
select: [user_id, community_id]
from: users
where:
community_detection:
method: louvainThis clusters users into social communities using the Louvain method.
graph_traversefinds direct and multi-hop connections.shortest_pathcomputes optimal routes between nodes.- Weighted graphs allow cost-based queries.
- Community detection groups entities into clusters.