Prev | Current Page 124 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

There is just one last detail to get out of the way, and that??™s
the process of actually setting up our database.
Designing Active Record??“Friendly Tables
Later in this chapter, you will be introduced to Active Record migrations, a powerful way to set
up and maintain your database schema with nothing more than simple Ruby code. Before we
get into that though, let??™s take a quick minute to review the things you should keep in mind
when designing tables for use with Active Record. Most of these things were covered in Chapter 1
when we talked about Active Record assumptions, but as these assumptions are especially
important to keep in mind when you are designing your tables, they??™re worth a quick review
here as well. Ready?
Every table should have an automatically incrementing primary key called id. If you chose
not to follow this rule, you will have to specifically define your primary keys within your
models with the set_primary_key method and specifically define your foreign keys for
each of your associations.
Table names should be plural.


Pages:
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136