SQL Validator is a fully client-side web application powered by sql.js. Designed for the database course at Stockholm University, it provides an interface for students to write, format, and run SQL queries directly in their browser without the need for a database server. Results can be compared to expected results based on a question bank, and views can be created and managed using the browser's local storage.
- Fully Client-Side Execution: All SQL validation and execution is performed in the browser using sql.js SQLite.
- SQL Editor: A simple text editor with syntax highlighting and formatting.
- Views Management: Create, delete, and manage database views, stored in the browser's local storage.
- Efficient Results Comparison: Compare query results to expected results based on a question bank.
- Dark/Light Mode: Toggle between dark and light mode.
- Question Highlighting: Started and completed questions are highlighted in the question selector making it easy to track progress.
- Import/Export Data: Import and export queries and views to file for sharing and/or backups.
- Image Export: Export queries and views as images in light mode for assignment submission.
- Multi-Language Support: Full i18n support with Swedish and English included. Adding a new language only requires a new language pack file.
A public instance of SQL Validator is available at https://sql-validator.e-su.se, powered with Cloudflare Pages.
- Clone the repository:
git clone https://github.com/Edwinexd/sql-validator.git - Install dependencies:
npm install - Start the development server:
npm start
The oracle (data/oracle.json) is the single source of truth for the database schema, canonical data, and all 110 reference SQL queries. It uses language-agnostic placeholders (e.g. {{table:Person}}, {{col:Person.city}}, {{city:6}}) that are resolved at generation time using a language pack.
The oracle is encrypted (data/oracle.enc) before committing so students cannot see the answers.
Language definitions live in languages/ (e.g. sv.ts, en.ts). Each pack provides:
- Localized names, addresses, cities, course names, room names
- Per-person IDs, postal codes, phone numbers
- Schema translations (table and column names)
- 110 localized question descriptions
- UI strings
The generate-language.ts script combines the oracle with a language pack to produce per-language output:
- Creates a SQLite database with localized schema and data
- Runs all reference queries to produce expected result sets
- Outputs
questionpool.jsonanddata.sqlite3intopublic/languages/<code>/
The generate-erd.ts script produces light/dark SVG database diagrams from the generated databases.
Both scripts support --all to auto-discover and process all languages.
| Script | Description |
|---|---|
npm run generate-all |
Regenerate all languages (question pools, databases, ERDs) |
npm run generate-lang -- --lang <code> --plain |
Generate a single language using unencrypted oracle |
npm run generate-lang -- --all --plain |
Generate all languages |
npm run generate-erd -- --all |
Regenerate ERD diagrams for all languages |
npm run encrypt-oracle -- <password> |
Encrypt oracle.json to oracle.enc |
npm run decrypt-oracle -- <password> |
Decrypt oracle.enc to oracle.json |
- Create a new file in
languages/(e.g.de.ts) implementing theLanguageDefinitioninterface - Run
npm run generate-all
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for more information.









