Home>

About Rails composite indexes.

For the book i am learning (Perfect Rails) for the following code

Intermediate table for User to participate in #Event
def change
    create_table: tickets do | t |
      t.references: user
      t.references: event, null: false, foreign_key: true, index: false
      t.string: comment
      t.timestamps
    end
    add_index: tickets, [: event_id,: user_id], unique: true
  end
end


Since the composite index is set to: event_id->: user_id,
Added index: false because a single index by the references method is unnecessary.

It is only stated that
If I put a composite index on two references, should I put a single index on the latter (: user_id)?