

Ask HN: Best Book for learning SQL? - babyboy808

I am trying to learn SQL, to work with MySQL. The main part I am having trouble with is getting my head round relationships (Querying, Updating and linking different tables together etc etc). What book do you recommended for learning SQl that maybe has a tutorial flow?
======
silentbicycle
It isn't specific to MySQL, but an excellent book for understanding relational
databases is _An Introduction to Database Systems_ by C. J. Date. Reading that
(even just the first several chapters, and then others as needed) will help
you understand the mindset behind both SQL and relational databases in
general. While I had figured out the basics of SQL on my own, I found that
getting the big relational ideas made it much clearer why some schema designs
are better, the intent behind some aspects of SQL that seemed strange, etc.

It has a new edition published every couple years (it's a textbook), so you
can usually get the previous edition for quite cheap.

Also, note that a lot of the books on SQL deal specifically with MySQL, SQL
server, etc., and don't always make it clear which aspects are the
implementation vs. which are standard SQL. (I was learning with SQLite and
Postgresql, so I probably got bit by this more than you will.)

~~~
babyboy808
Thank you for the indepth response. An Introduction to Database Systems is
quite pricey though but if it does the job...

~~~
silentbicycle
It shouldn't be pricey. I got a copy of the 7th edition hardcover for about
$8. This one: [http://www.amazon.com/Introduction-Database-Systems-C-
Date/d...](http://www.amazon.com/Introduction-Database-Systems-C-
Date/dp/0201385902)

I doubt the concepts and mathematical model behind relational databases have
changed _that_ much between 1999 and 2003. :)

Also, most the code in the book is in a language called "Tutorial D", with
asides about how it would look in SQL (and equally frequent complaints about
how SQL fails to live up to the mathematical ideal of the relational model).
_It's not an SQL tutorial_ , but once you understand the relational model, you
will probably be able to burn through tutorials -- it will just be learning
syntax, not completely new ideas.

------
kqr2
I actually recommend playing with sqlite. It's fast and easy to setup. You can
work with it via command line or use a web browser plugin.

I can also recommend Mike Owens' book _Definitive Guide to SQLite_

[http://www.amazon.com/Definitive-Guide-SQLite-Mike-
Owens/dp/...](http://www.amazon.com/Definitive-Guide-SQLite-Mike-
Owens/dp/1590596730/)

------
compay
Joe Celko's "SQL For Smarties" and "SQL Puzzles and Answers" are classics in
the field. They're still very relevant despite being 10+ years old, since SQL
hasn't changed anywhere near as much as, say, Java in that time.

<http://www.celko.com/books.htm>

------
NonEUCitizen
online: <http://philip.greenspun.com/sql/>

~~~
babyboy808
Thanks NonEUCitizen, much appreciated and it's free!

------
wigglywonk
Skip the book. Find, read, and 'do' a few online tutorials, and you'll know
over 90% of what you need to get going. Pick one specific to your engine of
choice (MySQL in this case, it seems) and just go with it.

------
gtani
fromthat other site

[http://www.reddit.com/r/programming/comments/7n9q8/ask_progg...](http://www.reddit.com/r/programming/comments/7n9q8/ask_proggit_what_are_some_good_books_for_learning/)

------
morbidkk
if you are completely new to this then Head First Sql would be good start

