Leveraging Infoworks AI for SQL query generation enhances data retrieval and data processing functionalities. To maximize the effectiveness of this feature, consider the following best practices:
- Be Specific: Provide clear and concise descriptions of the required data retrieval or manipulation tasks.
- Familiarize with the Schema: Understanding the database schema enhances the formulation of effective business requirements.
- Utilize Chat History: Review past queries to inform and improve future interactions.
- Provide Detailed Context: If a query is part of a larger task, providing context aids in generating more accurate SQL.
- Specify Conditions Explicitly: Clearly state any conditions in queries (e.g., specify a date range instead of using vague terms like "recent data").
- Mention Aggregations: Clearly identify any necessary aggregations, such as sums or averages, and specify the attributes involved.
- Clarify Table Relationships: If multiple tables are involved, articulate their relationships, ideally through primary and foreign keys.
- Indicate Result Requirements: Specify the desired order of results or any row limitations.
- Avoid Ambiguity: Eliminate ambiguous terms and vague descriptions to prevent incorrect SQL generation.
- One Query at a Time: Focus on a single piece of information per query to maintain clarity.
- Use Consistent Terminology: Utilize the exact terminology from the database schema when referring to specific entities.
- Provide Examples: When applicable, include examples of expected output to clarify intent.
- Request Aliases and Formatting: For shared or reused SQL queries, request the inclusion of aliases for tables and formatting for better readability.
- Rephrase if Necessary: If the generated SQL does not meet requirements, rephrase the question or provide additional context.
- Review AI Responses: Scrutinize the AI's explanations and generated SQL to ensure alignment with requests, and ask follow-up questions for clarity.
- Test Generated Code: Validate the correctness of generated SQL in a safe environment before deploying it in a production database.