I am trying to get my head around this code. It's from the Rails Tutorial Book and is part of the process of making a twitter like application.
class CreateRelationships < ActiveRecord::Migration def change create_table :relationships do |t| t.integer :follower_id t.integer :followed_id t.timestamps end add_index :relationships, :follower_id add_index :relationships, :followed_id add_index :relationships, [:follower_id, :followed_id], unique: true end end
- Since their are only 2 columns (follower_id and followed_id) why would their be a need for an index?
- Does the index sort them is some way? It just seems a bit strange to me to add an index to a table with 2 columns?
- What does the index do to the rows?