upvote
Great showcase. Cool to see how any 2d state can be presented with enough work.

Just FYI your statement for the checkmate state in the opera game appears to be incorrect

reply
Thank you, and thanks for highlighting that. I'll take a look now.
reply
Technically you can model anything in SQL including execution of any Turing complete language
reply
Yes, but OP wants to preserve the relational goodness.
reply
SQL can make 2D data, but it extremely bad at it. It’s a good opportunity to wonder whether this part can be improved.

“Pivot tables”: I often have a list of dates, then categories that I want to become columns. SQL can’t do that so there is a technique of spreading values to each column then doing a MAX of each value per date. It is clumsy and verbose but works perfectly… as long as categories are known in advance and fixed. There should be an SQL instruction to pivot those rows into columns.

Example: SELECT date, category, metric; -- I want to show 1 row per date only, with each category as a column.

``` SELECT date,

MAX( CASE category WHEN ‘page_hits’ THEN metric END ) as “Page Hits”,

MAX( CASE category WHEN ‘user_count’ THEN metric END ) as “User Count”

GROUP BY date;

^ Without MAX and GROUP BY: 2026-03-30 Value1 NULL 2026-03-30 NULL Value2 2026-03-31 Value1 NULL (etc) The MAX just merges all rows of the same date. ```

SQL should just have an instruction like: SELECT date, PIVOT(category, metric); to display as many columns as categories.

This thought should be extended for more than 2 dimensions.

reply
DuckDB and Microsoft Access (!) have a PIVOT keyword (possibly others too). The latter is of course limited but the former is pretty robust - I've been able to use it for all I've needed.
reply
PostgresSQL

"crosstab ( source_sql text, category_sql text ) → setof record"

https://www.postgresql.org/docs/current/tablefunc.html

VIA https://www.beekeeperstudio.io/blog/how-to-pivot-in-postgres... as a current googlable reference/guide

reply