Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: Best Book for learning SQL?
6 points by babyboy808 on Jan 28, 2009 | hide | past | favorite | 10 comments
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?


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.)


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


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...

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.


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/...


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



Thanks NonEUCitizen, much appreciated and it's free!


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.



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




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

Search: