News for hackers. Stuff that matters.
Re:Shouldn't FROM come before SELECT in SQL? (2011) by lucumo on Thursday January 25, 2024 @10:34AM (#39130591)
Slightly weird, though grammatically acceptably, as far as I know.

But the debate is actually coming from something else your example shows nicely. When you select something from a drawer, you select entities. Usually when we select from a relational table, we select properties. In SQL, the drawer is not a thing.

A different way to keep the English-style would be to add a BUT-JUST-[THEIR] clause.

SELECT FROM socks WHERE size = 45 BUT JUST [THEIR] color

All fairly tongue in cheek of course. SQL isn't going to change, so there's really no point in worrying too much about it :-)

Re:Shouldn't FROM come before SELECT in SQL? (2011) by KittenPassingBy on Thursday January 25, 2024 @11:24AM (#39131263)
Things are records / rows. Collections of the same things are entities (rubber band/ folders). Groups of entities are tables (Drawers).

A star schema usually contains one table to one entity mapping.

Dynamic tables for custom field on the other hand are usually multi entity tables. In this case, it would be a large junk drawer with various unrelated folders stuffed inside with everything from report cards, to keys to toys, to take out menus. It would have the toys entities, take out menu entities, keys entities, etc inside a mixed table.

Re:Shouldn't FROM come before SELECT in SQL? (2011) by Swizec on Thursday January 25, 2024 @10:39AM (#39130661)
> Usually when we select from a relational table, we select properties. In SQL, the drawer is not a thing

Ah but that’s by convention! If we want to be super pedantic, they’re all just relations. The drawer table describes a relation between values. And SELECT just defines a new relation! You’re creating an ad-hoc “table”.

That’s why “SELECT socks FROM (SELECT socks, pants FROM drawer)” works just fine.

Ok yes my brain has definitely been broken by years of SQL. I’m not the right person to understand newbies anymore.