RDo*_*wns 2 mysql database ddl database-design
在这个场景中,我有:球员、梦幻足球联赛(社区)和结果。
1 个用户可以加入多个幻想联盟。
我当前的结构为:
create table players (id int, email, display_name)
create table communities (id int, name, password, admin_email)
create table community_players (community_id, player_id)
Run Code Online (Sandbox Code Playgroud)
我现在需要为每个社区创建一个结果表。我刚在想:
create table results (player1_id, player1_points, player1_goals_scored, player2_id, player2_points, player2_goals_scored, date, community_id)
Run Code Online (Sandbox Code Playgroud)
我担心这张桌子最终会变得很大。因此,当我去查询它的统计数据(即谁击败了谁、进球数、失球数等)时,它最终会变得非常慢。
我的想法是:
我是否应该为创建的每个社区“即时”创建一个结果表?
create table results_community_name (player1_id, player1_points, player1_goals_scored, player2_id, player2_points, player2_goals_scored, date, community_id)
Run Code Online (Sandbox Code Playgroud)