Lurker News
I too often find myself getting stuck when it comes to more advanced SQL queries. I have never actively learnt SQL and realise that I don't have a great mental model of how it works. I would like to improve this as it is killing my productivity from time to time.

Comments (97) 45 threads

Earlier comments
jrjames83#
I created a set of videos for Udemy, but they complained about audio quality so I added them to YouTube. I cover a variety of basics (joins) but also get into subqueries, correlated subqueries, window functions and all along use a freely available database. https://www.youtube.com/playlist?list=PLImyDqSBQbdm09n4BhGwK...
aakriti12151 reply#
I just finished learning Postgres! I used codecademy's SQL session for the intro, but then just decided to play around with queries. This diagram was my most useful resource, and one that I still look at on a daily basis when trying to create queries - I hope it helps! https://www.sqlite.org/images/syntax/select-stmt.gif

I also look at the postgres docs very frequently for syntax and format and those help me a lot. Stack Overflow is also a great resource!

tommynicholas1 reply#
I found that course excellent as well - although these days if you don't have the "pro" tier of Codecademy you miss out on the quizzes and other things. Still, it was good and pretty advanced. Learned a lot.
aakriti1215#
That's very true, I actually ended up subscribing to pro because I was also learning JavaScript and HTML/CSS at the time (new programmer), so I found the pro stuff useful. However, if you're not wanting to drop the $20 or so for the month, I'd say that you can find plenty of fantastic online resources.
wireprotocol#
There are a lot of good resources to learn the "how" of SQL, but not the "why".

The first reason is that the relational model is a combination of logic and set theory, which happens to be great for a lot of business applications.
The second reason is that people have adapted SQL surprisingly well to other kinds of data, like JSON. Even if you try to build a database system specialized to JSON, it will still probably come out worse because getting things like storage, replication, administration, etc. right takes a long time.
The third reason is that data has more value when combined seamlessly with other data. So if you have business data (which everyone has) and JSON, you are better off with a single system that is great at business data and OK at JSON, than two specialized systems.
Keeping these things in mind makes it easier to understand SQL in my opinion.

sn91 reply#
I'm not sure if this is the level you're looking for, but if you need a better mental model of SQL, you should take a look at Jennifer Widom's course on Stanford Lagunita on Databases: https://lagunita.stanford.edu/courses/Engineering/db/2014_1/...

Starting from the relational model and going through SQL really makes the language make sense.
If this is too basic for you, then, at worst, you'll spend a few hours reviewing the basics and strengthening your foundation.

wenc#
That is an excellent course, and a good jumping off point. It is somewhat technical and expounds ideas that most DBAs probably aren't aware of.

Load more comments