atieh mokhtary atieh mokhtary - 7 months ago 42
MySQL Question

create ManyToMany relation or an array of movieId in laravel 5.2?

I am going to create a website which has exactly same as site logic.

I have

table that can have lots of movies from
table. now I want to know which method is the best choice?

  1. Creating a
    relation between
    table and create a pivot table to store ids from both tables.

  2. In
    table create a field named
    and store all movies ids like an array in this field and separate them with ','.

Please let me know what way would you choose and why?


Ok. Go for ManyToMany Relationship. Eloquent already has the mechanism to handle this relationship reducing your effort of writing code. Defining the proper relation via pivot table will make you much more easier for handling CRUD operation too.

With the second approach you won't be able to handle this using Eloquent.And again this is not the standard way of creating relationship between tables. Besides you have to manually prepare the name of the movies separated by comma.