Chess in SQL
by upmostly on 3/29/2026, 1:25:16 PM
https://www.dbpro.app/blog/chess-in-pure-sql
Comments
by: eelinki
You could take this even further and add triggers to see if your move is legal or not. Or delete row with a conflict when you capture a piece.
4/1/2026, 6:12:51 AM
by: upmostly
Author here.<p>I had the idea of building a working Chess game using purely SQL.<p>The chess framing is a bit of a trojan horse, honestly. The actual point is that SQL can represent any stateful 2D grid. Calendars, heatmaps, seating plans, game of life. The schema is always the same: two coordinate columns and a value. The pivot query doesn't change.<p>A few people have asked why not just use a 64-char string or an array type. You could! But you lose all the relational goodness: joins, aggregations, filtering by piece type. SELECT COUNT(*) FROM board WHERE piece = '♙' just works.
3/29/2026, 1:28:45 PM
by: jimgoneill
And they didn’t call it ChessQL?
4/1/2026, 6:43:46 AM
by: landsman
Tool looks nice, but I would prefer such a tool written in a better (native?) language than JavaScript. Security is also important to me, so I only use open-source tools. I’m going to stick with DBeaver and DataGrip.
4/1/2026, 6:12:04 AM
by: grimm8080
Amazing, how do I play it?
4/1/2026, 6:36:56 AM
by: FergusArgyll
Very cool! I think the dragon is missing a white rook - ascii chess pieces are heard to see...
4/1/2026, 6:12:01 AM