Extended SQL Translation for Graph Query Optimization
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Functional graph traversal languages like Gremlin struggle to optimize queries due to their step-order dependent semantics, which limits query optimization, and standard SQL fails to retain directed edges and advanced data structures, leading to incomplete translation and inefficient query execution.
Innovation Solution
Translating functional graph traversal languages into an extended Structured Query Language (SQL) that retains directed edges, flow control, iteration, and advanced data structures, enabling full-fidelity semantic translation and optimizing queries by identifying equivalent execution plans.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If standard SQL is used for translation, then query execution efficiency is improved, but directed edges and advanced data structures are lost
Solution Approach 1:
The patent segments the SQL language into standard SQL components and extended components. The extended SQL dialect introduces new syntax elements specifically designed to represent directed edges (using special join conditions and path expressions) and advanced data structures (using recursive CTEs and custom data type definitions). This segmentation allows the translation to preserve graph-specific semantics while still leveraging the execution efficiency of SQL.
Solution Approach 2:
The patent introduces an intermediary extended SQL dialect that acts as a bridge between functional graph traversal language and standard SQL. This intermediary language includes additional constructs for representing directed edges through specialized join syntax and path expressions, and for preserving advanced data structures through recursive common table expressions. The intermediary maintains full semantic equivalence while enabling optimization through SQL's declarative nature.
2Loss of information
If functional graph traversal language is used, then directed edges and advanced data structures are retained, but query optimization is limited
Solution Approach 1:
The patent changes the parameter of query representation from imperative step-by-step functional language to declarative extended SQL statements. This parameter change enables the query optimizer to explore multiple execution plans and select the most efficient one, while the extended SQL syntax ensures that directed edges and advanced data structures are preserved through specialized constructs like path expressions and recursive CTEs.
3Ease of manufacture
If standard SQL translation is applied, then translation simplicity is improved, but semantic completeness deteriorates
Solution Approach 1:
The patent creates a universal extended SQL framework that can handle both traditional relational queries and graph traversal queries with directed edges and advanced data structures. The extended SQL dialect incorporates additional syntax rules and constructs that work alongside standard SQL, allowing a single translation system to preserve complete semantics while maintaining compatibility with existing SQL infrastructure and tools.
Data Source
Figure 1
Figure 2
Figure 3
AI summary
In embodiments of the present disclosure, there is provided a scheme for translating a functional graph traversal language to an extended Structured Query Language (SQL). After a first query compiled with the functional graph traversal language is obtained, the first query is translated to a second query in the form of the extended Structured Query Language based on the translating rules. By extending the standard Structured Query Language, embodiments of the present disclosure enable retaining directed edges between vertices in the graph database in the second query and retaining flow control, iteration, temporary variable definition, advanced data structure, side effect, and dependency between steps included in the first query. Therefore, according to embodiments of the present disclosure, by translating the functional graph traversal language, it is possible to identify queries with the same semantics in the functional graph traversal language, thereby optimizing queries in the functional graph traversal language.