php - Using Indexes in mysql correctly -
i know how can make proper indexed table, understand concept using movies example:
i have these 5 tables multiple fields list here these tables primary indexes fields only:
movies movie_id = primary index actors actor_id = primary index geners gener_id = primary index reviews review_id = primary index
and have these tables relation 2 columns each, unsure type of indexes should have these relational tables:
movie_actor movie_id,actor_id movie_gener movie_id,gener_id movie_review movie_id,review_id
i have join on these fields if wants 1 movie details use such query:
select * movies m left join movie_actor ma on ma.movie_id = m.movie_id left join actors on a.ator_id = ma.actor_id left join movie_gener mg on mg.movie_id = m.movie_id left join geners g on g.gener_id = mg.gener_id left join movie_review mr on mr.movie_id = m.movie_id left join reviews r on r.review_id = mr.review_id m.movie_id = 1234
so kind of index should use on relational tables (movie_actor,movie_gener,movie_review) both fields, primary on 1 or index on both? thanks
only 1 field can primary key on each table table can have 1 primary key (corrected user). @ post information differences between index, primary, unique, fulltext in mysql?
Comments
Post a Comment