# SQL book for Rails developers?

**URL:** <https://www.ruby-forum.com/t/sql-book-for-rails-developers/59441>\
**Category:** Rails\
**Created:** [May 3, 2006, 7:06pm UTC](https://www.ruby-forum.com/t/sql-book-for-rails-developers/59441 "2006-05-03T19:06:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trevor\_Harmon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/9fc348/32.png) [@Trevor\_Harmon](https://www.ruby-forum.com/u/Trevor_Harmon)\
**Post date:** [May 3, 2006, 7:06pm UTC](https://www.ruby-forum.com/t/sql-book-for-rails-developers/59441/1 "2006-05-03T19:06:48Z")

</div>

I can design basic Rails models without any trouble, and I feel pretty  
comfortable at the mysql command prompt. But some of these new database  
features in Rails 1.1 have me scratching my head: polymorphic  
associations, join models, etc. What is all that?

I think I need a book that covers the advanced database topics one  
would need to know as a Rails developer – not necessarily  
Rails-specific, but comprehensive enough to include all the database  
topics relevant to Rails. That means it would have to include not just  
material on SQL syntax and whatnot, but also best practices for  
database design, that sort of thing. Hopefully it could also serve as a  
general reference to the SQL language, as well.

Does anyone know of a book like that? (Hope I’m not wishing for too  
much.) Thanks,

Trevor

---

<div class="post-metadata">

**Author:** ![Trevor\_Harmon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/9fc348/32.png) [@Trevor\_Harmon](https://www.ruby-forum.com/u/Trevor_Harmon)\
**Post date:** [May 3, 2006, 7:07pm UTC](https://www.ruby-forum.com/t/sql-book-for-rails-developers/59441/2 "2006-05-03T19:07:10Z")

</div>

On Wed, May 03, 2006 at 12:52:55AM -0700, Trevor Harmon wrote:  
} I can design basic Rails models without any trouble, and I feel pretty  
} comfortable at the mysql command prompt. But some of these new  
database  
} features in Rails 1.1 have me scratching my head: polymorphic  
} associations, join models, etc. What is all that?

These are not SQL terms or even relational database terms. These have to  
do  
with Object-Relational Modeling (ORM). ActiveRecord is an ORM framework,  
and some of those terms (e.g. join models) seem to have been invented  
specifically for AR.

} I think I need a book that covers the advanced database topics one  
} would need to know as a Rails developer – not necessarily  
} Rails-specific, but comprehensive enough to include all the database  
} topics relevant to Rails. That means it would have to include not just  
} material on SQL syntax and whatnot, but also best practices for  
} database design, that sort of thing. Hopefully it could also serve as  
a  
} general reference to the SQL language, as well.  
}  
} Does anyone know of a book like that? (Hope I’m not wishing for too  
} much.)

Good database design is an art. I have rarely seen it taught well. The  
best  
book I’ve seen, which is the textbook I used in college (and is used  
pretty  
nearly universally for undergrad database courses), probably isn’t  
sufficient on its own. You can try, though. We used “Database System  
Concepts” by Silberschatz et al., which seems to retail for over $100  
(well  
it _is_ a textbook) these days. I searched Amazon for “database” and  
found  
many books, but I can’t say anything about their quality.

} Thanks,  
} Trevor  
–Greg

---

<div class="post-metadata">

**Author:** ![Trevor\_Harmon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/9fc348/32.png) [@Trevor\_Harmon](https://www.ruby-forum.com/u/Trevor_Harmon)\
**Post date:** [May 3, 2006, 7:07pm UTC](https://www.ruby-forum.com/t/sql-book-for-rails-developers/59441/3 "2006-05-03T19:07:23Z")

</div>

On Wednesday 03 May 2006 14:35, Derrick S. wrote:

> These are not SQL terms or even relational database terms. These have to do  
> with Object-Relational Modeling (ORM). ActiveRecord is an ORM framework,  
> and some of those terms (e.g. join models) seem to have been invented  
> specifically for AR.
> 
> Yes, but a good database book will discuss object-oriented and  
> object-relational databases, not just relational databases. The key here  
> is that you need both an understanding of databases AND an understanding of  
> object oriented programming concepts. It’s one of those times you have to  
> put the knowledge from multiple courses together.

Trevor

I agree with the general theme of the replies here. I worked with  
databases  
daily for over a year with no real understanding of what I was doing.  
(I  
mean I THOUGHT I knew what I was doing but really didn’t have a clue.)

You can’t really learn how to use the “Rails-specific” bits of a  
database, any  
more than you can learn only “holiday phrases” of a foreign language.  
You  
have to learn the whole thing, then take the bits you need for whatever  
you  
are doing.

Databases have a lot of rigorous theory behind them. You don’t need to  
understand it in full depth to work with databases (I certainly don’t!),  
but  
you need to be aware of the issues. There are plenty of traps waiting -  
SQL  
itself is a flawed language (the MySQL implementation even more so) but  
if  
you are know where you are making compromises, they won’t come back to  
bite  
you. Incidentally, I always recommend PostgreSQL over MySQL here simply  
because it strives for correctness which is the number 1 concern for  
databases.

I haven’t seen a book that is a gentle introduction to databases AND  
explains  
how to apply the theory correctly. I think this is a big hole in the  
market  
right now! You are best finding the best book on the database system  
you  
want to use and getting some practical experience. Then buy something  
more  
theoretical. I highly recommend Database in Depth by C J Date  
(incidentally  
where I got my signature quote from). It can be a bit of a  
mind-boggler, but  
it’s short, it makes you think, and you can skip the proofs and formal  
defintions.

I wish there was an easy way to learn databases, but if you put the  
effort in,  
you can get yourself way ahead of the game.

Regards  
Ashley

---

<div class="post-metadata">

**Author:** ![Trevor\_Harmon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/9fc348/32.png) [@Trevor\_Harmon](https://www.ruby-forum.com/u/Trevor_Harmon)\
**Post date:** [May 3, 2006, 7:07pm UTC](https://www.ruby-forum.com/t/sql-book-for-rails-developers/59441/4 "2006-05-03T19:07:16Z")

</div>

On May 3, 2006, at 8:42 AM, Gregory S. wrote:

> with Object-Relational Modeling (ORM). ActiveRecord is an ORM  
> framework,  
> and some of those terms (e.g. join models) seem to have been invented  
> specifically for AR.

Yes, but a good database book will discuss object-oriented and object-  
relational databases, not just relational databases. The key here is  
that you need both an understanding of databases AND an understanding  
of object oriented programming concepts. It’s one of those times you  
have to put the knowledge from multiple courses together.

> } Does anyone know of a book like that? (Hope I’m not wishing for too  
> it _is_ a textbook) these days. I searched Amazon for “database”  
> and found  
> many books, but I can’t say anything about their quality.

I’ve heard good things about the Silberschatz book. The text we used  
was titled “Database Systems: The Complete Book” and was authored by  
Garcia-Molina, Ullman, & Widom (almost sounds like a law firm). It’s  
another $100 book, but it’s pretty comprehensive. I highly recommend  
it if you are looking for a deeper understanding that also can serve  
as a good reference. Here’s the synopsis from [ecampus.com](http://ecampus.com):

Synopsis:  
This introduction to database systems offers a readable comprehensive  
approach with engaging, real-world examplesâ??users will learn how to  
successfully plan a database application before building it. The  
first half of the book provides in-depth coverage of databases from  
the point of view of the database designer, user, and application  
programmer, while the second half of the book provides in-depth  
coverage of databases from the point of view of the DBMS implementor.  
The first half of the book focuses on database design, database use,  
and implementation of database applications and database management  
systemsâ??it covers the latest database standards SQL:1999, SQL/PSM,  
SQL/CLI, JDBC, ODL, and XML, with broader coverage of SQL than most  
other books. The second half of the book focuses on storage  
structures, query processing, and transaction managementâ??it covers  
the main techniques in these areas with broader coverage of query  
optimization than most other books, along with advanced topics  
including multidimensional and bitmap indexes, distributed  
transactions, and information integration techniques. A professional  
reference for database designers, users, and application programmers.

I think that it’s also sold separately in parts 1 and 2. The second  
half discusses the concepts related to designing the database server  
itself, so unless you plan on writing the next-generation database  
server YourSQL, it’s probably overkill.

-Derrick S.
