I have a table like this:
| id | user_id | ... | ... | ...
Where id
is the primary key. What indexing should I apply to the user_id
column (note that there can be multiple rows in this table from the same user)? Just a regular index?
I have a table like this:
| id | user_id | ... | ... | ...
Where id
is the primary key. What indexing should I apply to the user_id
column (note that there can be multiple rows in this table from the same user)? Just a regular index?
Look into Eloquent Relationships - https://laravel.com/docs/5.5/eloquent-relationships#defining-relationships
Depending on the relationship, one-to-one, one-to-many or many-to-many, you will set up foreign keys in your database migrations and define the relationship type in the related models.
There is no need to apply indexing to the user_id column over and above that.