Hacker News new | past | comments | ask | show | jobs | submit login
Is there a K&R for SQL?
10 points by nonamegiven on Jan 20, 2013 | hide | past | web | favorite | 7 comments
Just as K&R is primarily about C, not programming or computer science in general, I'm interested in a tutorial on SQL that leaves relational theory to other texts.

(disclamer: I have more than a decade experiences in doing SQL)

I would say Mr. Joe Celko's "SQL for smarties" (and basically anything he has written (look him up for references)....

I have had the opportunity to talk to mr. Celko, and he added (as I asked him what he thought was the best database-book) the "Manga Guide to Databases" (seriously!), I am reading it now (but I am only in the second chapter), and it seems very good...

If you need a good database which honors the standard behaviour closely and has super documentation (and very clean codebase), take a look at Postgresql. The fact that is is free and open source (bsd licensened) does not hurt at all :)

And please remember, you cannot "read" yourself to better knowledge. Download a sql server (postgres if you ask me) and play around...

The big leap is imho, the difference between procedural (do-this-do-that code like most programming languages) and declarative syntax (I want "xxxx" and I don't care how you get it) which is how SQL works... And thinking in sets...

++Postgres; ++Celko; ++play around;

Recommend Postgres' own concise tutorial: http://www.postgresql.org/docs/9.2/static/tutorial-sql.html for starters.

Also, after you've cracked joins, learn the 'WITH' clause ( http://www.postgresql.org/docs/9.0/static/queries-with.html ), it's good: 'WITH' restructures the more difficult 'middle-outward' subquery syntax to a top-down 'detail-to-summary' structure. Far easier to build, debug, and re-grok 6 months later.

Apart from postgres site, is there any good book with hands on practice exercises available on Postgres?

Database: A Primer by C. J. Date, if you can find it


I found the book "The Definitive Guide to SQLite" to also be an excellent primer on SQL, especially for small application developers. It doesn't cover the variants used in big databases, but handles the basics quite well, along with giving lots of insight into SQLite's specific implementation.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact