A modern, interactive web application that demonstrates the Query By Example concept. This application allows users to query a database by providing example data instead of writing SQL queries.
- Query By Example Interface: Input example values to find similar records
- Advanced Query Builder: Build complex queries with multiple conditions and operators
- Real-time SQL Generation: See the SQL queries generated from your examples
- Interactive Results: View, sort, and export query results
- Multiple Tables: Employees and Products tables with sample data
- Schema Information: View table structure and column details
- Sample Data Preview: See example records to understand the data
- Modern Design: Beautiful, responsive UI with gradient backgrounds
- Tabbed Interface: Switch between QBE, Query Builder, and Data View modes
- Real-time Search: Search and filter data across all fields
- Pagination: Navigate through large datasets
- Export Functionality: Download results as CSV files
- Column Statistics: View statistical information for numeric columns
- Sorting: Click column headers to sort data
- Responsive Design: Works on desktop and mobile devices
- Loading States: Visual feedback during query execution
- Node.js with Express.js
- SQLite database for simplicity
- RESTful API endpoints
- CORS enabled for cross-origin requests
- React.js with modern hooks
- Axios for API communication
- Lucide React for beautiful icons
- CSS Grid & Flexbox for responsive layouts
- Custom CSS with modern styling
-
Clone the repository
git clone <repository-url> cd QBE
-
Install dependencies
# Install server dependencies npm install # Install client dependencies cd client npm install cd ..
-
Run the application
# Start both server and client in development mode npm run devOr run them separately:
# Terminal 1 - Start the server npm run server # Terminal 2 - Start the client npm run client
-
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
- Select a table from the sidebar (Employees or Products)
- Fill in example values in the form fields
- Click "Execute Query" to find similar records
- View results and generated SQL query
Example:
- Table: Employees
- Department: "Engineering"
- Position: "Engineer"
- Result: Finds all employees in Engineering department with "Engineer" in their position
- Switch to the "Query Builder" tab
- Add multiple conditions with different operators
- Use operators like =, !=, >, <, LIKE, NOT LIKE
- Execute the query to see results
- Switch to the "View Data" tab
- Browse all records in the selected table
- Use search to filter data
- Click column headers to sort
- Export data as CSV
- Columns: id, name, department, salary, position, hire_date
- Sample Records: 8 employees with various departments and positions
- Columns: id, name, category, price, stock, supplier
- Sample Records: 8 products with different categories and suppliers
GET /api/tables- Get all available tablesGET /api/table/:tableName/schema- Get table schemaGET /api/table/:tableName/sample- Get sample dataGET /api/table/:tableName/all- Get all data from table
POST /api/qbe/query- Execute QBE query- Body:
{ tableName: string, exampleData: object } - Returns:
{ query: string, values: array, results: array, count: number }
- Body:
QBE allows users to query databases by providing example data rather than writing SQL. The system automatically generates SQL queries based on the provided examples.
Example:
- User provides:
{ department: "Engineering", salary: 75000 } - System generates:
SELECT * FROM employees WHERE department LIKE '%Engineering%' AND salary = 75000
The application shows the exact SQL query being executed, helping users understand how their examples translate to database queries.
- Form Validation: Ensures proper data types
- Dynamic Operators: Shows relevant operators based on column type
- Live Preview: See sample data to understand the structure
QBE/
├── server/
│ └── index.js # Express server with API endpoints
├── client/
│ ├── public/
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── App.js # Main application
│ │ └── index.js # React entry point
│ └── package.json
├── package.json # Root package.json
└── README.md
npm run dev- Start both server and clientnpm run server- Start only the servernpm run client- Start only the clientnpm run build- Build the React app for productionnpm run install-all- Install all dependencies
- More Database Support: PostgreSQL, MySQL integration
- Advanced QBE Features: Range queries, fuzzy matching
- Query History: Save and reuse previous queries
- User Authentication: Multi-user support
- Custom Tables: Allow users to create their own tables
- Query Templates: Pre-built query examples
- Data Visualization: Charts and graphs for results
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
Query By Example - Making database queries accessible to everyone! 🎯