🌍 The Odin Project · subject

The Odin Project Databases, Ruby on Rails & Node.js Syllabus

The Databases, Ruby on Rails & Node.js syllabus for The Odin Project in full: 8 chapters and 38 topics, every one listed below, plus 50 Databases, Ruby on Rails & Node.js flashcards with answers.

8Chapters
38Topics
50Flashcards

Databases, Ruby on Rails & Node.js syllabus: all 8 chapters

Expand any chapter to see its topics and sub-topics.

  1. Databases

    2 topics
    • Databases and SQL
    • Project: SQL Zoo
  2. Ruby on Rails Fundamentals

    6 topics
    • Introduction to Rails
    • Routing
    • Active Record Basics
    • Active Record Queries
    • Form Basics
    • Controllers and Views
  3. Advanced Rails

    6 topics
    • Associations
    • Nested Forms
    • Authentication
    • Sessions, Cookies and Authentication
    • Advanced Forms and APIs
    • Mailers and Advanced Topics
  4. Introduction to NodeJS

    6 topics
    • Introduction to the Back End
    • What is NodeJS?
    • Getting Started
    • Debugging Node
    • Environment Variables
    • Project: Basic Informational Site
  5. Express

    6 topics
    • Introduction to Express
    • MVC in Express
    • Forms and Data Handling
    • Deployment
    • PostgreSQL
    • Projects
  6. Authentication, ORMs & APIs

    7 topics
    • Authentication Basics
    • Project: Members Only
    • Prisma ORM
    • Project: File Uploader
    • API Basics
    • API Security
    • Project: Blog API
  7. Testing Express

    2 topics
    • Testing Routes and Controllers
    • Testing Database Operations
  8. Full Stack Projects

    3 topics
    • Project: Where's Waldo (Photo Tagging App)
    • Project: Messaging App
    • Project: Odin-Book

The Odin Project Databases, Ruby on Rails & Node.js flashcards — 50 questions with answers

  1. What is a relational database?

    A database that stores data in tables (relations) made of rows (records) and columns (attributes), where tables can be linked to each other through keys, and which is queried using SQL.

  2. What is a primary key in SQL?

    A column (or set of columns) that uniquely identifies each row in a table. It must be unique and non-NULL; in Rails it is conventionally an auto-incrementing integer column named `id`.

  3. What is a foreign key?

    A column in one table that references the primary key of another table, creating a link between the two tables (e.g., a `user_id` column on a `posts` table pointing to `users.id`).

  4. What are the main categories of SQL statements a web developer must know?

    Data definition: CREATE TABLE, ALTER TABLE, DROP TABLE. Data manipulation: INSERT, SELECT, UPDATE, DELETE. Plus clauses that shape queries: WHERE, ORDER BY, LIMIT, GROUP BY, HAVING, JOIN.

  5. What is the basic order of clauses in a SQL SELECT statement?

    SELECT columns FROM table [JOIN ... ON ...] [WHERE condition] [GROUP BY columns] [HAVING condition] [ORDER BY columns] [LIMIT n].

  6. What is the difference between WHERE and HAVING in SQL?

    WHERE filters individual rows before grouping/aggregation; HAVING filters groups after GROUP BY has been applied, so only HAVING can use aggregate functions like COUNT() or SUM().

  7. Name the five most common SQL aggregate functions.

    COUNT() (number of rows), SUM() (total), AVG() (mean), MIN() (smallest value), and MAX() (largest value); they are typically used with GROUP BY.

  8. What is the difference between an INNER JOIN and a LEFT (OUTER) JOIN?

    INNER JOIN returns only rows that have matching values in both tables; LEFT JOIN returns all rows from the left table plus matching rows from the right table, filling in NULLs where there is no match.

  9. In SQL, what do the LIKE operator and the % wildcard do?

    LIKE performs pattern matching on strings in a WHERE clause; % matches any sequence of zero or more characters (and _ matches exactly one character), e.g. WHERE name LIKE 'Al%' matches names starting with 'Al'.

  10. What is a subquery in SQL, as practiced in SQL Zoo?

    A SELECT statement nested inside another query (commonly in a WHERE clause) whose result is used by the outer query, e.g. SELECT name FROM world WHERE population > (SELECT population FROM world WHERE name = 'Russia').

  11. What does the DISTINCT keyword do in a SELECT statement?

    It removes duplicate rows from the result set, returning each unique value (or unique combination of the selected columns) only once.

  12. What is Ruby on Rails and what architectural pattern does it use?

    Rails is a full-stack server-side web framework written in Ruby. It uses the MVC (Model–View–Controller) pattern: models handle data and business logic, views render output (HTML), and controllers process requests and connect the two.

  13. What are the two core philosophies of Rails?

    Convention over Configuration (sensible defaults and naming conventions replace explicit setup) and DRY — Don't Repeat Yourself (every piece of knowledge should exist in one place).

  14. Trace the path of a request through a Rails app.

    Browser sends an HTTP request → the router matches the verb + URL to a controller#action → the controller action runs, usually querying models → the model reads/writes the database via Active Record → the controller renders a view (or redirects) → the HTML response is sent back to the browser.

  15. What does the Rails router do, and where are routes defined?

    The router matches an incoming HTTP verb and URL path to a specific controller action; routes are defined in config/routes.rb, and `rails routes` lists them.

  16. What seven routes does `resources :photos` create in Rails, and to which controller actions do they map?

    GET /photos → index; GET /photos/new → new; POST /photos → create; GET /photos/:id → show; GET /photos/:id/edit → edit; PATCH/PUT /photos/:id → update; DELETE /photos/:id → destroy.

  17. In Rails routing, what is the difference between a member route and a collection route?

    A member route acts on a single resource and includes an :id in the path (e.g., /photos/1/preview); a collection route acts on the whole set with no :id (e.g., /photos/search).

  18. What is Active Record in Rails?

    Rails' ORM (Object-Relational Mapping) layer: it maps database tables to Ruby classes and rows to objects, letting you query and persist data with Ruby methods instead of raw SQL. It is the M (model) in MVC.

  19. What are the Rails naming conventions linking models to database tables?

    Model class names are singular CamelCase (e.g., BookClub); the corresponding table is plural snake_case (book_clubs); foreign keys are singularized_table_id (e.g., item_id); the primary key column is `id`.

  20. In Active Record, what is the difference between `new` and `create`?

    `Model.new` instantiates an object in memory without saving it (you must call `save`); `Model.create` instantiates and saves it to the database in one step, running validations and returning the object.

Show the other 30 Databases, Ruby on Rails & Node.js flashcards
  1. What is a Rails migration?

    A Ruby class that describes an incremental, reversible change to the database schema (creating tables, adding columns, indexes, etc.); migrations are run in order with `rails db:migrate` and can be rolled back with `rails db:rollback`.

  2. What are Active Record validations and when do they run?

    Rules declared in the model (e.g., validates :name, presence: true, uniqueness: true) that check data before it is written to the database; they run on save/create/update, and failures add messages to the object's `errors` collection and prevent saving.

  3. What is the difference between `find` and `find_by` in Active Record?

    `find(id)` looks up by primary key and raises ActiveRecord::RecordNotFound if nothing matches; `find_by(attribute: value)` returns the first record matching arbitrary conditions and returns nil if none is found.

  4. What does it mean that Active Record queries are 'lazy', and what is an ActiveRecord::Relation?

    Methods like `where`, `order`, and `limit` return an ActiveRecord::Relation instead of hitting the database immediately; the SQL only executes when the results are actually needed (e.g., iteration, `.to_a`, `.first`), which allows chaining queries efficiently.

  5. What is the N+1 query problem and how do you fix it in Rails?

    It occurs when you load N records and then run one extra query per record for an association (1 + N queries total), e.g. looping over posts and calling post.author. Fix it with eager loading: Post.includes(:author), which loads the association in a fixed number of queries.

  6. Why should you use `where("name = ?", params[:name])` instead of string interpolation in Active Record?

    The `?` placeholder creates a parameterized query that escapes user input, preventing SQL injection; interpolating user input directly into the query string lets attackers inject arbitrary SQL.

  7. Why must you use Rails form helpers (like form_with) instead of hand-writing HTML forms?

    Rails helpers automatically insert the CSRF authenticity token (without which Rails rejects non-GET submissions), set correct action/method attributes (including the _method override for PATCH/DELETE), and name fields so params arrive nested (e.g., params[:user][:name]).

  8. In Rails form parameters, what does input name `user[email]` produce in the controller?

    A nested hash in params: params[:user][:email]. The bracket naming convention groups related fields into one sub-hash so the whole set can be passed to a model at once.

  9. What are strong parameters in Rails and how are they used?

    A security mechanism requiring you to explicitly whitelist mass-assignable attributes, e.g. params.require(:user).permit(:name, :email); unpermitted attributes are dropped, preventing attackers from setting fields like `admin` via forged form data.

  10. In a Rails controller, what is the difference between `render` and `redirect_to`?

    `render` builds a response body from a view template within the current request (URL unchanged, instance variables available); `redirect_to` sends a 302 response telling the browser to make a brand-new request to another URL, discarding current instance variables.

  11. How does data get from a Rails controller to its view?

    Through instance variables: any @variable set in the controller action (e.g., @posts = Post.all) is automatically made available inside the corresponding view template.

  12. In ERB templates, what is the difference between <%= %> and <% %>?

    <%= %> evaluates the Ruby code and outputs the result into the HTML; <% %> evaluates the code without printing anything (used for logic like if statements and loops).

  13. What are Rails partials and how are they rendered?

    Reusable view fragments whose filenames start with an underscore (e.g., _form.html.erb); they are rendered with `render 'form'` or `render partial: 'user', locals: { user: @user }`, and collections can be rendered with `render @users`.

  14. How do you declare a one-to-many association in Rails, and what does each model need?

    The parent declares `has_many :posts` and the child declares `belongs_to :user`; the child's table must contain the foreign key column (user_id). The model with `belongs_to` is always the one holding the foreign key.

  15. What are the two ways to set up a many-to-many association in Rails, and how do they differ?

    `has_and_belongs_to_many` uses a bare join table with no model, while `has_many :through` uses a full join model (e.g., Appointment joining Physician and Patient). has_many :through is preferred when you need validations, callbacks, or extra attributes on the relationship.

  16. What problem do the :class_name and :foreign_key options solve in Rails associations?

    They let association names differ from model names, e.g. a Post with `belongs_to :author, class_name: "User", foreign_key: "author_id"` — Rails can no longer infer the model or key from the association name, so you specify them explicitly.

  17. What does `dependent: :destroy` do on a has_many association?

    When the parent record is destroyed, all its associated child records are also destroyed (running their callbacks), preventing orphaned rows that reference a deleted record.

  18. What is `accepts_nested_attributes_for` used for in Rails?

    Declared in a model (e.g., accepts_nested_attributes_for :addresses), it lets a parent record create/update associated records from a single form submission via a `addresses_attributes` parameter; the view uses `fields_for` to generate the nested inputs.

  19. In a nested Rails form, what do the `_destroy` attribute and `reject_if` option do?

    With allow_destroy: true, submitting `_destroy: 1` for a nested record deletes it; `reject_if` (e.g., :all_blank) skips creating nested records whose submitted fields are empty.

  20. Why must passwords be stored as hashes rather than encrypted or plain text?

    Hashing is one-way, so even if the database leaks, original passwords cannot be recovered (unlike encryption, which is reversible with a key). Rails uses bcrypt, a deliberately slow, salted hashing algorithm that resists brute-force and rainbow-table attacks.

  21. What does `has_secure_password` give a Rails model?

    Using the bcrypt gem and a `password_digest` column, it adds virtual `password` and `password_confirmation` attributes, validates their presence/match, stores only the bcrypt hash, and provides an `authenticate(password)` method that returns the user on success or false on failure.

  22. Why does HTTP need sessions and cookies for authentication?

    HTTP is stateless — each request is independent and the server retains nothing between them. Cookies are small key-value pairs the browser stores and sends with every request to that domain; sessions use a cookie (holding a session ID or signed data) to recognize the same user across requests, enabling 'staying logged in'.

  23. In Rails, what is the difference between the `session` and `cookies` hashes?

    `session` data is stored in an encrypted, tamper-proof cookie and is meant for temporary per-user state like the logged-in user's id (session[:user_id]); `cookies` writes plain browser cookies you control directly, which can persist long-term (cookies.permanent) and can be signed/encrypted explicitly.

  24. What is Devise and what does it provide?

    The most popular Rails authentication gem: a full engine providing sign-up, login/logout, password hashing, password reset emails, remember-me, account locking and confirmation, built from composable modules (database_authenticatable, recoverable, rememberable, etc.), plus helpers like current_user and authenticate_user!.

  25. How does a Rails controller respond with either HTML or JSON from the same action?

    With respond_to: e.g. `respond_to do |format| format.html; format.json { render json: @users } end` — Rails picks the block matching the request's requested format (URL extension or Accept header). `render json:` calls to_json on the object.

  26. What is an Action Mailer in Rails and how do you send mail with it?

    Mailers are classes (inheriting from ApplicationMailer) that work like controllers for email: methods set instance variables and call `mail(to:, subject:)`, views provide both HTML and plain-text templates, and you send with UserMailer.welcome_email(user).deliver_now (or deliver_later to queue it via Active Job).

  27. What is the back end of a web application, and what are its three main components?

    The server-side part the user never sees, responsible for storing, processing, and serving data. Its three core parts: the server (machine listening for requests), the application (server-side code handling requests and logic), and the database (organized persistent data storage).

  28. What is Node.js?

    Node.js is a JavaScript runtime built on Chrome's V8 engine that runs JavaScript outside the browser (on servers). It uses an event-driven, asynchronous, non-blocking I/O model: slow operations like file or network access are started, the program continues, and callbacks run via the event loop when the work completes.

  29. What are the two module systems available in Node.js and their syntax?

    CommonJS: require() to import and module.exports to export (Node's historical default). ES Modules (ESM): import/export syntax, enabled by using the .mjs extension or setting "type": "module" in package.json.

  30. How do you debug a Node.js application beyond console.log?

    Run `node inspect script.js` for the built-in terminal debugger, or `node --inspect` to open an inspector websocket that Chrome DevTools (chrome://inspect) or the VS Code debugger attach to; set breakpoints (or write `debugger;` in code), then step through and inspect variables. NODE_ENV/NODE_DEBUG and the util.debuglog utility help with log-based debugging.

The Odin Project Databases, Ruby on Rails & Node.js FAQ

What is in the The Odin Project Databases, Ruby on Rails & Node.js syllabus?

The Odin Project Databases, Ruby on Rails & Node.js is split into 8 chapters: Databases, Ruby on Rails Fundamentals, Advanced Rails, Introduction to NodeJS, Express, Authentication, ORMs & APIs, Testing Express and Full Stack Projects. Together they contain 38 topics.

How many chapters are in The Odin Project Databases, Ruby on Rails & Node.js?

8 chapters, containing 38 topics. The largest chapter is Authentication, ORMs & APIs, with 7 topics.

Are there flashcards for The Odin Project Databases, Ruby on Rails & Node.js?

Yes — a 50-card Databases, Ruby on Rails & Node.js deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.