Requirements: SQL Query Builder
1. Functional Requirements
These are the core features the system must perform.
a. User Interface for Query Building
- Allow users to select tables and fields.
- Support drag-and-drop or form-based selection for ease of use.
b. Support for Basic SQL Clauses
- SELECT, FROM, WHERE, ORDER BY, GROUP BY, HAVING.
- Users can add multiple conditions and logical operators (AND, OR, NOT).
c. Join Support
- Ability to perform INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
- Users should be able to select join type and join condition visually or through input.
d. Query Preview
- Display the generated SQL query in a text area before execution.
- Option to edit raw SQL if advanced users want to.
e. Query Execution
- Execute the query on a connected database and return results in tabular form.
- Show errors clearly if the query fails.
f. Save & Load Queries
- Allow users to save frequently used queries.
- Load saved queries for re-use and editing.
g. Query Validation
- Validate query syntax before execution.
- Highlight potential issues like missing fields, ambiguous joins, or wrong data types.
h. Export Results
-
Support export of query results to CSV, Excel, or JSON formats.
2. Non-Functional Requirements
These describe how well the system should perform.
a. Usability
- Simple and intuitive interface for both technical and non-technical users.
- Tooltips and help icons to assist in query building.
b. Performance
- Queries should execute quickly for large datasets (depending on the DB engine).
- UI must remain responsive during long query runs.
c. Scalability
- Support multiple users, sessions, and large database schemas.
- Handle complex queries involving multiple tables.
d. Security
- Proper authentication before access.
- Limit access to database schemas and tables based on user roles.
- Prevent SQL injection, even when editing raw SQL.
e. Compatibility
- Support for multiple database engines (e.g., MySQL, PostgreSQL, SQL Server, Oracle).
- Use a database-agnostic query builder where possible.
3. Optional / Advanced Requirements
These can be discussed as system extensions or for bonus feature sets:
- Syntax highlighting for raw SQL editing.
- Real-time query performance stats (execution time, rows returned).
- Visual ERD (Entity Relationship Diagram) support.
- AI-assisted query suggestions.
How to Explain in Class:
- Start with user goals: “What does the user want to achieve?” → Build and run queries easily.
- Separate Functional vs Non-Functional: Helps students learn requirement types clearly.
- Use simple scenarios: Like “HR wants all employees with salary > 50000 grouped by department.”