| ▲ | Chess in SQL(dbpro.app) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 points by upmostly 3 days ago | 21 comments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | upmostly 3 days ago | parent | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Author here. I had the idea of building a working Chess game using purely SQL. 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. 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. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | herodoturtle 23 minutes ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
This is such a cool way to build brand awareness - kudos to the author. I'd never heard of dbpro.app until now - and this article is just so awesome. Nice job! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | antonautz 3 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Nice post! It looks like the colors of the pieces are swapped though. Perhaps you could replace the dots with something else to indicate the colors of the individual squares too. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | eelinki 7 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | jimgoneill 7 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
And they didn’t call it ChessQL? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | danielszlaski 5 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Nice. The trojan horse framing works well, once you see that any 2D state is just coordinates + a value, it’s hard to unsee it. Did you consider using this to enforce move legality via CHECK constraints or triggers, or did that get too hairy? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | grimm8080 7 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Amazing, how do I play it? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | OfirMarom 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Of all the use cases for SQL chess would not have been on that list haha. Amazing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | landsman 7 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | devlx 2 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Very cool concept | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | FergusArgyll 7 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Very cool! I think the dragon is missing a white rook - ascii chess pieces are heard to see... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | catlifeonmars 5 hours ago | parent | prev [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
> No JavaScript. No frameworks. Just SQL. > Let's build it. Cool concept; but every blog post sounds exactly the same nowadays. I mean it’s like they are all written by the exact same person /s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||