Your Organized Data Can Be Worth Millions

Data is everywhere. It is relied on by every industry including advertising, health, science, government, shopping, finance, and service-oriented industries and more. Advertising can be targeted to specific individuals based on their online behavior, offline behavior, where they are located at the very moment, what they read and search for online, or even talk with their friends about; data related to health and science can help researchers find patterns among people and work to develop cures. Data IS the new currency.  Yet even before data is analyzed and turned into actionable information, systems and structures are required to be able to store this information. There are many database systems that can house millions (or billions) of data points, but this data needs to start from somewhere in a computer’s local memory. In Ruby, an efficient way of storing this information is as a hash.

A hash is considered to be efficient due to its design as an associative array, made up of pair of keys and values. 1 This creates a “dictionary-like” lookup system for information where given the key for a piece of data, it’s complementary data can be easily obtained. A simple example is a phonebook:

hash =
    "mom" => "2125551234",
    "dad" => "2125551235",
    "brother" => "2125551236"


A more complex hash can contain nested hashes (e.g. a hash within a hash) and utilize a symbol as a key:

hash = 
    "mom" => { :phone => "2125551234", :email => ""},
    "dad" => { :phone => "2125551235", :email => ""},
    "brother" => { :phone => "2125551236", :email => ""}


So if we wanted to look up all e-mail addresses, we could iterate over the records and store the data in a flat array, or to just the e-mail address for “brother”-



The value of a hash can be any type of basic Ruby Literal including number, string, array, hash as well as a boolean object. Hashes are also the basis for the JSON (JavaScript Object Notation) format, generally used as a means of exchanging data between applications through APIs (to be explored more in a future post), as a result of its easily understandable key/value format.

With the amount of data doubling exponentially every two years 2, it is important to have your data organized and easily retrievable. Hashes are an effective way of doing this, temporarily storing new or retrieved data and manipulating that data outside of a database system.

About the author

Leave a Reply

Your email address will not be published. Required fields are marked *

About This Blog

This blog will serve as my outlet to share my thoughts and learnings as I dedicate myself to becoming a full-stack web developer...something too long in the making.

What I’ve Been Learning

+ Ruby
+ Ruby on Rails
+ JavaScript
+ jQuery
+ AngularJS