## 4 Model
### Relational Graph Attention Network  
RGAT [26] builds upon the foundation of GAT [21] by incorporating relation-aware self-attention. In RGAT, the relational graph comprises a set of interconnected nodes, where each node represents an entity that can be linked to others, with edges denoting the relationships between them. The principles of RGAT are illustrated in Figure 7. For node A, its neighboring nodes are categorized into several groups based on different types of relationships. Taking node E as an example, let \(e_{a}\) represent the initial embedding of  
Figure 6: Results of syntactic analysis: (**a**) syntactic constituent analysis; (**b**) grammatical dependency relations.  
node A, \(e_{e}\) represent the edge embedding from node A to neighboring node E, and \(e_{r_{1}}\) represent the refined grammatical relationship embedding from node A to node E. Based on this, after processing through a relation-aware self-attention mechanism, each neighboring node generates a new embedding vector that reflects the specific relationship between node A and its neighbors. Finally, all embedding vectors of different relationship types are integrated and fused through a fully connected layer to obtain the final representation of node A.  
In this paper, we employ RGAT, which comprises two primary modules: a node-centric graph module and an edge-centric graph module. The node-centric graph module represents entities as nodes, with edges indicating the relationships between them. Conversely, the edge-centric graph module treats the relationships between two entities as nodes, depicting the entities as edges in a directed graph. By combining and stacking these two graph types, our model can effectively capture and update both the nodes and their interrelationships during training while also refreshing the embeddings of both nodes and relationships.  
For example, the natural language query \"Find all students older than 20 years old\" prompts RGISQL to first identify the database schema related to the query, including table names and column names. Then, it uses a grammatical dependency tree to parse the input's syntactic structure and segment it, identifying key content involved in the query, such as the \"students\" table and the \"age\" field, and mapping them to the database schema.  
After parsing the syntactic information, the model integrates the relationships between syntactic dependencies and the database schema into a graph structure. The graph includes nodes (such as \"students\" and \"age\") and edges (such as the condition \"age greater than 20\"), generating node embeddings X and edge embeddings R. RGAT, as a relational graph encoder, is capable of capturing the connections between grammatical dependencies and the database schema, thus preparing for the next step of decoding.  
Once encoding is complete, the ASTormer decoder recursively generates the SQL query step by step. It relies on the embedded information output by the encoder to construct components of the SQL statement layer by layer until the complete query is formed. The final output of the SQL statement is SELECT * FROM student WHERE age > 20.  
Figure 7: RGAT principle diagram.