Inspiration

The tech industry is going through an extreme AI boom, but AI itself depends on one thing: data. To manage and understand data, we need databases, DBMS and, most importantly, SQL.

Beginners often write a query and see only the final result. Why did a row disappear? How were the groups formed? I wanted to make that hidden process visible, so learners can understand SQL instead of memorizing it.

What it does

QueryLens shows how SQL runs, one step at a time. Write a query, press Space, and watch rows being filtered, grouped, joined, sorted and limited.

  • Highlights the clause being executed and explains each step
  • Shows why a row is kept or removed
  • Presents all table versions, an execution tree and a flow chart
  • Covers queries, joins, subqueries, table and data changes, permissions and transactions
  • Simulates behaviour of MySQL, PostgreSQL, SQL Server and SQLite

How I built it

I built QueryLens solo.

  • Frontend: React, JavaScript, HTML, CSS and Vite
  • SQL engine: a custom engine in the browser (lexer → parser → executor)
  • Backend: Java and Spring Boot, which compares MySQL SELECT results with a local MySQL database
  • Tools: Spring Initializr, Maven, Spring Tool Suite, Vitest and AI assistance from Claude

The executor saves a snapshot after every step. The interface moves between these snapshots, so going forward and backward is simple.

Challenges I ran into

  • Showing intermediate results: a database normally returns only the final output, so the engine had to record every step.
  • Database differences: row limits, NULL ordering, division and text comparison behave differently.
  • Matching real behaviour: small details, such as how MySQL treats 'a' || 'b', needed correction.
  • Keeping it small: tables, explanations, a tree and a flow chart had to fit one clear screen.

Accomplishments that I am proud of

  • One focused feature on one screen, true to the Smallest Possible Product theme
  • Visualization that works in the browser without a database setup
  • Step-by-step learning controlled by the Space key
  • Keyboard support, symbols alongside colours, dark mode and a phone layout

What I learned

The order we write SQL differs from its logical execution order:

FROM → JOIN → WHERE → GROUP BY → HAVING → SELECT → DISTINCT → ORDER BY → LIMIT

I also learned about three-valued logic: comparing with NULL using operators such as = or > gives UNKNOWN, and WHERE keeps only true rows.

What's next for QueryLens

  • Support UNION, window functions, views and subqueries in FROM
  • Let learners create practice challenges with their own sample data
  • Add guided lessons for common SQL mistakes

Built With

Share this project:

Updates

Submission history