SQL, PostgreSQL & ActiveRecord
It is currently Friday morning and I have just finished my System Check for this weeks curriculum. It wasn’t until about yesterday afternoon that any of this stuff began to make sense to me. In past cohorts, this week was split up into two weeks – the first being
PostgreSQL followed the next week by
ActiveRecord. Not us though, we got all of it at once.
As a result of having everything crammed into one week, things got a little hectic. For instance, on Sunday night we were learning about how to use
SQL. We learned a bunch of methods and all that jazz and then were told to forget it all because we would be using
ActiveRecord from now on. Huh?
It felt like a bit of a sick joke when I heard that. The explanation given was we should understand what’s going on under the hood of
ActiveRecord. I don’t necessarily disagree with that – I just didn’t like how it was done. One week was too little time to be learning something new only to forget it and move to something else a day later.
That being said, once we got to
ActiveRecord and situated ourselves, things were a breeze. We mainly focused on how to create databases and tables inside of our editor instead of doing it all manually inside of our terminal like we did we
The cool thing about using
ActiveRecord in this way is that it intuitively knows which tables you are referencing. Instead of getting bogged down with assigning unique
id's to all of your rows in a table,
ActiveRecord does that automatically.
It get’s better though, when referencing a row from a different table, you just call it by its name instead of some wierd
id by using associations. There is some weird voodoo magic involved here for sure but I’m not about to complain.
My recommendation to people who are unfamiliar with this stuff would be to take a look at
SQL and do your best to understand the fundamentals of what is happening inside of a database and how data is structured inside of tables. Once you feel you have a handle on this, move to
ActiveRecord and your life will become infinitely easier – I assure you.
You might be wondering why you should learn databases in the first place. When you create a web app you are likely to structure it in such a way that users are able to input information and interact with the page. This adheres to the principles of CRUD – Create, Read, Update & Destroy. This is the basis for all good web applications.
You want users to be able to put data onto a page, then read that data and if they decide to alter or delete that data – they should be able to do so. Strive for incorporating CRUD into your web app and you will shine when stacked up against silly static web pages.
I will be doing an entire breakdown of how to best prep for a boot camp, Launch Academy in particular, in the near future but for now I would say to focus on the basics of
ActiveRecord where possible as I mentioned earlier in this article. This will put you in a solid place for nailing this week.