News for hackers. Stuff that matters.
Re:The category design pattern by mjw on Sunday November 08, 2015 @04:01PM (#10529887)
Eh...

    SELECT a.*, b.* FROM a CROSS JOIN b;

    (SELECT 'a' AS tag, * FROM a) UNION (SELECT 'b' AS tag, * FROM b);
Re:The category design pattern by catnaroek on Sunday November 08, 2015 @04:09PM (#10529930)
As I mentioned in my comment below: https://news.ycombinator.com/item?id=10529838 , the category of SQL queries has coproducts and products, but the category of SQL tables does not. Coproduct and product tables are very useful in their own right.
Re:The category design pattern by mjw on Monday November 09, 2015 @06:44PM (#10536647)
Ah OK, fair enough.

Not sure what definition you're using for the category of tables, but I don't think the distinction between table and query is really that significant, at least from a theory point of view. You can declare views and materialized views. In some SQL dialects you can even define triggers which allow you to 'update' them, not that I would have thought mutability would be particularly nice to reason about in a category-theoretic framework.

If you really want to do theory on this stuff, just use the relational algebra, or better yet just plain first-order logic. Much nicer, you have all the products and coproducts you want, and the results can probably be re-applied to SQL with a bit of cludge-work :)

Re:The category design pattern by catnaroek on Monday November 09, 2015 @10:09PM (#10537389)
Triggers are an imperative hack. This is like using a C struct with an enum and a union, and claiming that C has "sum types".
Re:The category design pattern by mjw on Tuesday November 10, 2015 @08:08PM (#10544047)
Agreed that SQL is ugly as hell, but if you want to talk about its theoretical properties that's a separate debate. Theory doesn't care whether something's aesthetically pleasing, just whether it's possible.