Ask HN: What is the best online resource to learn advanced SQL?
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.
100 comments
[ 4.1 ms ] story [ 172 ms ] threadhttps://www.amazon.com/Joe-Celkos-SQL-Smarties-Fourth/dp/012...
Postgres has an excellent manual. It has an internal scripting language called PL/pgSQL which is (to put it politely) not intuitive at all. The manual was enough to help me write a query to implement a binary tree search.
In particular: https://www.postgresql.org/docs/9.6/static/sql.html
https://www.postgresql.org/docs/9.6/static/server-programmin...
https://www.postgresql.org/docs/9.6/static/sql-commands.html
[1] https://www.postgresql.org/docs/manuals/
Is really good, though its more related to indexing than SQL specifically.
[1] http://sql-performance-explained.com/
[2] http://dataintensive.net/
[0] http://modern-sql.com/
Preview on macOS is also good.
EDIT: I don't know, when that review was written the device was just released. The device received various firmware updates since then. I convert everything to EPUB with Calibre.
I had a Samsung Galaxy Note 12.2 for a while, but the built in reader (iBooks) in the iPad is far superior to everything I tried on Android over a period of months.
* Most modern browsers have it built in
* Preview on MacOS is good
* Kindle and iBooks import PDF files
* SumatraPDF and Skim, depending on your OS
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!
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.
One thing you have to realize is that once you get a little advanced, you have to get to the details of the single SQL implementations, it's not about SQL but about Postgres.
I've found these books really valuable
# SQL Performance Explained Everything Developers Need to Know about SQL Performance
https://www.amazon.com/Performance-Explained-Everything-Deve...
This book fundamentally talks about how to effectively use and leverage the SQL indices. Talks about all the important implementations (Postgres, MySQL, Oracle, SQL Server).
# Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems
https://www.amazon.com/Designing-Data-Intensive-Applications...
This book gets mentioned a bunch around here and for a good reason. There aren't too many concrete resources on making your systems "webscale" and this one is really good.
# PostgreSQL 9.0 High Performance
https://www.amazon.com/PostgreSQL-High-Performance-Gregory-S...
Discusses all the different settings and tweaks you can do in Postgres. It's crazy how much of a perf gain you can get just by twiddling the parameters of the database, i.e. all the tricks you can do when the single instances are bottle necks.
There's a similar book for MySQL https://www.amazon.com/High-Performance-MySQL-Optimization-R...
# PostgreSQL 9 High Availability Cookbook
https://www.amazon.com/PostgreSQL-9-High-Availability-Cookbo...
Discusses how do you go from 1 Postgres instance to 1+ instance. Talks about replication, monitoring, cluster management, avoiding downtime etc i.e. all the tricks you can do to manage multiple instances. Again there's a similar book for MySQL https://www.amazon.com/MySQL-High-Availability-Building-Cent...
Last but not least check out the postgres documentation, people consider it a standard of what good documentation looks like https://www.postgresql.org/docs/9.6...
https://lagunita.stanford.edu/courses/DB/SQL/SelfPaced/cours... https://lagunita.stanford.edu/courses/DB/SQL/SelfPaced/cours... https://lagunita.stanford.edu/courses/DB/SQL/SelfPaced/cours... https://lagunita.stanford.edu/courses/DB/SQL/SelfPaced/cours... https://lagunita.stanford.edu/courses/DB/SQL/SelfPaced/cours... https://lagunita.stanford.edu/courses/DB/SQL/SelfPaced/cours...
Not shiny, but very functional. It's been around 5+ years and has lots of great practice for advanced queries.
That will get you pretty far but the advanced SQL topics will require the study of what the underlying database provides and how it works. Every database is different in terms of how it implements advanced features, if at all. For example, MySQL doesn't have window functions. For postgres related topics, the documentation is excellent, postgresguide.com gives a high level overview, or you can follow craig's blog (http://www.craigkerstiens.com/) that provides a gentle introduction to many of these topics as well.
Whenever I do come across blogs that have good articles we aim to feature them in Postgres Weekly, so if you want a regular stream of that type of content it's worth checking out - http://www.postgresweekly.com
One of the things I sometimes find tricky with SQL is pattern matching a problem to a solution. It can be tricky to describe what you want and sometimes direct human help can't be beat so I do recommend Stackoverflow (normally I have mixed feelings about SO). There are few power users on SO like Craig Ringer and the horsesomethingsomething (can't recall the actual handle) that are helpful and friendly.
The HackerRank SQL challenges were also helpful in getting some extra practice: https://www.hackerrank.com/domains/sql/
Finally, this Quora post will also point you to some useful resources and has some great tips that I'm working through now: https://www.quora.com/How-do-I-learn-SQL
Sometimes I see job offers that ask for experience with large websites, large databases, large servers, etc, etc, etc (you get the idea).
How do you land those jobs if getting in that kind of subject is impossible alone? You can't simulate that kind of things at your home, so unless your side project grow and you must learnt it the hard way, or you had luck to be at a company where they allowed you to be involved, how do you learn that? Thank you
The Try SQL course is free, the other 2 you have to pay for. https://www.codeschool.com/courses/try-sql
[1] https://schemaverse.com/
It doesn't necessarily teach each advanced technique, but it does give you a good place to practice what you've learned.
(Thanks for the mention!)