schemu_ff
schemu_ff
DatabaseSchema
Input_id
User_id Schema_id
Input_text Table_name
Users
Submitted_at description
User_id
Username
Created_at
TableColumns Synonyms
Column_id Synonym_id
Schema_id Entity_type
Column_name Entity_id
Data_type Synonym_text
description
QueryMapping
Mapping_id GeneratedQueries
Input_id Query_id
Intent_id Input_id
Schema_id Sql_query
Column_id Generated_at
status
1. Users Table
user_id INT Unique identifier for the user Primary Key, Auto-Increment
2. UserInputs Table
input_id INT Unique identifier for the input Primary Key, Auto-Increment
user_id INT ID of the user submitting the input Foreign Key (Users.user_id)
Purpose: Logs every user query for processing and historical analysis.
3. DatabaseSchema Table
Stores metadata about the target database schema that the SQL queries will interact with.
schema_id INT Unique identifier for the schema Primary Key, Auto-Increment
4. TableColumns Table
Details the columns within each table of the database.
Purpose: Maps column names and types for query generation and validation.
5. Synonyms Table
Stores natural language synonyms or aliases for tables and columns to aid in mapping naive input.
ENUM('table',
entity_type Type of entity (table or column) NOT NULL
'column')
Purpose: Helps interpret user input by linking common terms to schema elements (e.g., "price" →
unit_price).
6. Intents Table
Defines possible query intents (e.g., retrieve, insert, update) to classify user input.
Column Name Data Type Description Constraints
intent_id INT Unique identifier for the intent Primary Key, Auto-Increment
intent_name VARCHAR(20) Name of intent (e.g., SELECT, INSERT) NOT NULL, UNIQUE
7. QueryMappings Table
Column Data
Description Constraints
Name Type
Purpose: Records how the system interpreted the naive input in terms of intent and schema.
8. GeneratedQueries Table
Timestamp of query
generated_at DATETIME NOT NULL, Default: NOW()
generation
ENUM('success', 'failed',
status Execution status NOT NULL, Default: 'pending'
'pending')
Purpose: Logs the final SQL output and its execution status for debugging and auditing.
Relationships
Example Usage
1. UserInputs: Stores "Show me all customer names and their orders" with user_id and
submitted_at.
2. QueryMappings: