开发者

How to optimize mysql table for executing faster

开发者_运维知识库

I made a mysql database for my project. I need to know if what I did is correct or not.

I made a master table to store all my movie details and I built some other tables to store the views and ratings. Am I doing wrong by using different tables to store views and ratings, although I can use the master table to store views and rating in each post.

If I add the rating and views fields to the master table itself, will it affect my database? What's the optimal solution?

I am using Myisam as lots of select queries are needed instead of insert.


If you are just using the fields for incremental value, you can use the master table. But if you wish to save extra parameters to a vote or view, you should use a secundary table. e.g. You want to save which user voted which value on which date. Than you should add a table 'votes' with the fields: voteId, userId, rating, date.

Afterwards you can use the AVG function to calculate the avarage vote.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜