- [] Explain persistence, the need for using SQL, and difference between SQLite3 and SQL
- Install the Sqlite extension for VSCode. It's a good resource for navigating through your DB right within VSCode.
- You can also explore provided data through DB Browser for SQLite
- [] Perform CRUD actions on a single table
- [] Explore how to interact with a sqlite3 database with a ruby file
- [] Perform CRUD actions using ActiveRecord
- RailsGuides on ActiveRecord
- RailsGuides on ActiveRecord Migrations
- RailsGuides for ActiveRecord Query Interface
- Rails documentation (section on ActiveRecord)
- Sqlite tutorial
- Sqlite Cheatsheet
- VSCode Sqlite Extension
...
...
...
...
...
- Create Dogs model and table
- open up
./bin/console
and do create a couple of dogs.
- Create a
computers
table with the following columns:
- brand (string)
- model (string)
- screen_size (float)
- model_year (integer)
- asleep (boolean)
- last_backed_up_at (datetime)
-
In
lib/computer.rb
, create aComputer
class that inherits fromActiveRecord::Base
-
In
lib/exercises.rb
fill in thefirst_computer
andsecond_computer
methods so that they both return computers withbrand
,model
,screen_size
andmodel_year
properties assigned.
...
Why do we write database changes to a file instead of using SQL to update the structure of the database?
...
...
...
...
...
For this, let's open up ./bin/console
and attempt the following:
-
Define a
back_up
method within the computer class that updates thelast_backed_up_at
attribute of the computer to the current date and time. -
Define a
sleep
method within the computer class that updates theasleep
attribute of the computer totrue
. -
Define a
wake_up
method within the computer class that updates theasleep
attribute of the computer tofalse
. -
Define a
backed_up
method within the computer class that returns all of the computers that have been backed_up.
...
...
...