Re:Challenges students face when learning to work with relat...
by layer8 on Sunday August 29, 2021 @07:29PM
(#28351445)
The problem with NULL in SQL is that the semantics are inconsistent in complex ways. See for example https://vettabase.com/blog/what-does-null-mean-in-sql/.
Re:Challenges students face when learning to work with relat...
by nicoburns on Sunday August 29, 2021 @08:09PM
(#28351674)
Recursive queries are definitely top of the complexity pile IMO. However I usually discount them because I am yet to actually need them in a production environment. Window functions are super useful on the other hand.
Re:Challenges students face when learning to work with relat...
by magicalhippo on Sunday August 29, 2021 @08:25PM
(#28351758)
Heh, perhaps it's more accurate to say I've abused recursive queries.
One instance was to turn a column containing comma separated values into rows[1], so I could join on them. Wasn't for a query that needed performance of course.
Re:Challenges students face when learning to work with relat...
by alexanderskates on Monday August 30, 2021 @05:01AM
(#28353874)
I had this same issue in Redshift and ended up populating a table with values 1 to the maximum number of commas found (e.g. using max(regexp_count(...)) or something), then cross joining on the table with the csv column and calling split_part on the corresponding column and index (with the index coming from the numbers table). The cross join ensures that you index every value of the csv column.
Re:Challenges students face when learning to work with relat...
by fifilura on Monday August 30, 2021 @05:53AM
(#28354165)
What I think you'd do here (in modern implementations of SQL at least) is to split the values into an array using some convenient split function and self join on that array to pivot the arrays into rows.
Re:Challenges students face when learning to work with relat...
by magicalhippo on Monday August 30, 2021 @08:42AM
(#28355041)
> some convenient split function
If only the DB we're using had one of those :)
Another one that caught me by surprise was NULL vs unknown[1]. That bit me in a couple of queries.
[1]: https://learnsql.com/blog/understanding-use-null-sql/