Friday, January 18

Ruby on Rails - ActiveRecord pattern

We always talk about programming languages and we take pride in propagating how the language follows/supports the object oriented paradigm. This really makes sense, since we can connect them to real time objects. But, what about the databases? All the web applications do require some databases to store the content, user information and so on. We alway depend on database for any kind of information, but
Are our databases are ready to listen to objects?
How the languages communicate to the database (nothing but content)?
Well this is where the Active Record pitches in: Active record is an approach that is used to access the data.
How it does?
Programming Language Database
class =====> table
object =====> single row in table
properties/methods =====> columns in table

"A database table or view is wrapped into a class, thus an object instance is tied to a single row in the table. After creation of an object, a new row is added to the table upon save. Any object loaded gets its information from the database; when an object is updated, the corresponding row in the table is also updated. The wrapper class implements accessor methods or properties for each column in the table or view."

Now that is with Active record. Rails do implement the same pattern and with power of ruby, it does add some extra features/conventions to make developers life simpler.

Well in following posts we will see,
  1. How active record is implemented in rails
  2. What are the conventions?
  3. How to configure database to rails applications?
  4. Do we need to write xml files to configure each table?

No comments: