CSC 486: Ruby on Rails – Introduction to Active Record

TL:DR

Overview:

The team and I as you know are working on a Ruby on Rails and it is my first working on a project like this CodeWorkout. This being said I have been working hard to gain an understanding of Rails and now, I am writing about for everyone to see my question and follow along with my research.

This post going to be about Active Record and my own questions surround it. A few major questions being “What is Active Record is the first place” and then when reading about a topic, “What do this terminology mean?” These are all real disconcerting questions for a student of computer science; this especially holds truth for the field of software engineering. This is where this process of admitting and sharing out these questions and thoughts to the community comes in handy. This is why I am going to show my progress. I will do this through my posts.

Today’s post I am going to show sections of what I am reading along with questions and the answer I have found. Then follow by a quick summary and a reflection of the article.

Active Record:

The first article I read was Active Record Basics. When reading the article, questions started. This was good here what I took from that article.

Active Record is the M in MVC – the model – which is the layer of the system responsible for representing business data and logic. Active Record facilitates the creation and use of business objects whose data requires persistent storage to a database. It is an implementation of the Active Record pattern which itself is a description of an Object Relational Mapping system.

My First Thoughts:

I found this paragraph to be helpful but I did have many questions. I will be honest I don’t understand that much of this paragraph but to be fair it is just defining what Active Record is and what it is doing. The following were my questions when I was reading.

Questions:

I do not understand how Active Record is not a database when it collects data and logic and why Active Record is a layer. What is a database model? How and why does Active Record facilitate the creation and the use of business objects? What is an Object Relational Mapping system?

Answers:

What is a database model?

When to Wikipedia and found this page for Database model. This page explained, “A database model is a type of data model that determines the logical structure of a database and fundamentally determines in which manner data can be stored, organized, and manipulated.”

What is an Object Relational Mapping system?

When to Wikipedia and found this page for Object-relational mapping. This page explained, Object-relational mapping (ORM, O/RM, and O/R mapping tool) in computer science is a programming technique for converting data between incompatible type systems in object-oriented programming languages.”

 


1.1 The Active Record Pattern

Active Record was described by Martin Fowler in his book Patterns of Enterprise Application Architecture. In Active Record, objects carry both persistent data and behavior, which operates on that data. Active Record takes the opinion that ensuring data access logic as part of the object will educate users of that object on how to write to and read from the database.”

My First Thoughts:

After reading this paragraph, I felt even more confused than the last paragraph. Below are some of my questions on this paragraph.

Questions:

What is persistent data? What is a domain object? What is a behavior of a database? How do these all work and why do they matter? What does “Active Record takes the opinion that ensuring data access logic as part of the object will educate users of that object on how to write to and read from the database” mean? What does an opinion in the context of Active Record?

Answers:

What is persistent data?

When to Wikipedia and found this page for Persistent data. This page explained, “Persistent Data denotes information that is infrequently accessed and not likely to be modified.”

What is a domain object?

I found this page for Domain Object. This page explained, “Domain object is a logical container of purely domain information, usually represents a logical entity in the problem domain space”

What is a behavior of a database?

I found this page for Behaviour Driven Development. This page explained, “In software engineering, behavior-driven development (BDD) is a software development process that emerged from test-driven development (TDD).”


1.2 Object Relational Mappin

Object-Relational Mapping commonly referred to as its abbreviation ORM, is a technique that connects the rich objects of an application to tables in a relational database management system. Using ORM, the properties and relationships of the objects in an application can be easily stored and retrieved from a database without writing SQL statements directly and with less overall database access code.

1.3 Active Record as an ORM Framework Active Record gives us several mechanisms, the most important being the ability to:

  • Represent models and their data.
  • Represent associations between these models.
  • Represent inheritance hierarchies through related models.
  • Validate models before they are persisted to the database.
  • Perform database operations in an object-oriented fashion.

My First Thoughts:

After reading this paragraph, I felt better because I looked up what Object-Relational Mapping meant and could understand this paragraph. One of the main reason is because I understand the very basic of databases. I understand what properties, relationships, and some SQl. Even though I have seen and have some knowledge.  I still have some questions.

Questions:

What is an association?

Answers:

What is an association?

I found this page for Associations. This page explained, “association (ER term: relationship) is the way that two classes are functionally connected to each other.”

Summary:

It seems that Active Record is a layer of abstraction uses holds data and logic. This abstraction is used for recording and analyzing data for both the user and different parts of the database.  There are multiple types of data that Active Record uses, persistent and behavior data. Active Record uses this data to ensure that the application can educate users on how to write and read from the database.

This is because Active uses Object Relational Mapping or ORM, which connects tables together with associations. From my understanding, this allows the user to show their models, data, association, and inheritance. Along with performing validation for the database models and operations in an object-oriented fashion.

Reflection:

I admit, this took very long to do but it was worth it. I am planning on keeping this up. Writing one or two if time permits, along with my normal blog post. I found that the important part of this experiment is that it help fresh out the question and plus it show my hard work which is a plus.

Thank for reading this long post and I hope you could take something from this post. I hope that you continue the conversation.

Reference list down below

References:

http://guides.rubyonrails.org/active_record_basics.html

http://www.martinfowler.com/eaaCatalog/activeRecord.html

https://en.wikipedia.org/wiki/Database_model

https://en.wikipedia.org/wiki/Persistent_data

http://c2.com/cgi/wiki?DomainObject

https://en.wikipedia.org/wiki/Behavior-driven_development

http://behaviourdriven.org/

https://www.worldcat.org/title/java-magazine/oclc/73534586

http://ieeexplore.ieee.org/xpl/articleDetails.jsp?reload=true&arnumber=6068372

http://www.tomjewett.com/dbdesign/dbdesign.php?page=association.php

https://en.wikipedia.org/wiki/Object-relational_mapping

http://adrianmejia.com/blog/2011/08/11/ruby-on-rails-architectural-design/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s