This course came at the perfect time. I’ve recently gotten back into Rails after an 18-year hiatus, and this was a perfect refresher and shows just how much you can accomplish with Rails right out of the box.Garrett Winder
In this video, let's explore how we can define the structure of our tables using the different column types that Active Record provides. As we jump back into the playground, you'll see that I’ve expanded the definition of the posts table to include the 11 different column types that Active Record supports. Let’s walk through each one briefly.
A good rule of thumb: If a column only needs to hold a tweet's worth of content (under 256 characters), use string. If it needs more than 256 characters, use text.
Since SQLite does not have a rich type system, it doesn’t store these 11 Active Record types as distinct data types. Instead, SQLite simplifies them into just four storage types:
For those following SQLite advancements, recent updates allow storing JSON documents as blobs instead of text. However, Active Record does not yet support this feature. While this may change in future Rails updates, for most web applications, the performance difference is negligible.
In the next video, we’ll explore how to inspect the database and verify the actual storage types used by SQLite, helping us understand how data is stored on disk.