O'Reilly logo

Learning Rails 3 by Edd Dumbill, Simon St. Laurent, Eric J Gruber

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix B. An Incredibly Brief Introduction to Relational Databases

“I thought the whole point of Rails was that it hid the database and just let me write Ruby code! Why do I need to know about these things?”

Rails has all kinds of features for building web applications, but its foundation component is the way that it lets you get information into and out of relational databases. You can build simple applications without knowing much about databases, just telling Rake to do a few things and making sure you gave Rails the right data type for each field. You don’t need to know Structured Query Language (SQL), the classic language for working with databases.

Building a more complex Rails application, though, really demands at least a basic understanding of how relational databases work. It helps to think about tables and their connections when defining Rails models, at least when you first set them up.

Note

You may be hearing a lot about NoSQL databases as an alternative approach. They’re definitely moving forward, with tools like CouchDB, MongoDB, Riak, and many others competing for attention. They’re not yet, however, at the heart of Rails.

Tables of Data

The foundational idea underneath relational databases is a simple but powerful structure. Each table is a set of sets, and within a single table all of these sets have the same data structure, containing a list of named fields and their values. For convenience, each set within a table is called a row, and each field within that row is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required