SQL making Headlines, but what is it?

Seeing this recent article about Theranos in between deploying apps on Heroku, it felt like the right time to talk structured query languages and databases.

In this first blog, I’ll discuss a little bit how the two are related and used by this Rubyist. In following entry, I will discuss ActiveRecord and ORMs.

So what exactly is this SQL? Simply, it’s a “domain-specific” programming language with a “special purpose”: it’s only used for talking to databases. I’ve used it to handle data in a relational database management system, or RDBMS. What’s cool about it is that it can access many records with a single command, and it doesn’t need to specify how to reach a record.

However, for as much as you might hear people talking about using SQL around the office (in the before times), its rare as a full-stack web developer to spend much time going into my terminal and writing code like:

  1. sqlite> SELECT * FROM cats WHERE owner_id = 8527;

Instead, we’re using techniques like Object Relational Mapping, or ORM, to access these RDBMS with object-oriented programming languages, like Ruby. Moreover, we’ll use libraries of code, like, one of my favorites, the Ruby gem ActiveRecord. This beauty handles all the complexities of the SQL, and creates the connection from the program to the database. Also, it introduces ‘macros’ that easily create associations between our classes. Essentially, the work of actually digging into a database is abstracted away, allowing us to play with the data rather than worrying how to find it.

In beginning my journey into coding professionally, it felt good to look back at some of these ideas. If you want some further reading, I recommend the docs on SQLite.

web developer making apps for people with appetite