Bitmaker Labs – Day 14

Today we started diving into SQL and ActiveRecord, so basically working with databases. RoR uses SQLite by default, which is good for small projects. Bigger projects use PostgresSQL usually. The syntax used to query databases is actually fairly straight forward. Trying to write it out though is another thing. Initially it was overwhelming trying to learn the stuff, and to actually query something was even harder. Practice makes perfect though, and pair programming helps even more.

Here’s an example of an SQL query that returns to me the person I’m searching for:

SELECT * FROM [People] WHERE LastName = 'Fuller';

ActiveRecord is easier to use, so the syntax looks like this if I’m deleting an album for example:

Artist.album.where(name: "Hello World").delete_all

Knowing SQL and ActiveRecord are both very important, as you’ll be running queries a lot on most sites you build. In general as well, being able to manipulate databases is always helpful.

Leave a Comment

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

*
*