我们可以在同一列中有多个键值吗?

时间:2023-01-01 10:03:35

A student may be a different game player. Assume studentA playing, cricket, carrom board, athlet. For this I have master table like table (game_id (pk), game_name (varchar(300)).

学生可能是不同的游戏玩家。假设学生玩,板球,卡罗姆板,运动员。为此,我有像表一样的主表(game_id(pk),game_name(varchar(300))。

In student information table contains student details. Now i need to store the game id which are applicable for that student. For this, how can i store game id in a student info table, if one student plays more than one game.

在学生信息表中包含学生详细信息。现在我需要存储适用于该学生的游戏ID。为此,如果一个学生玩多个游戏,我如何将游戏ID存储在学生信息表中。

1 个解决方案

#1


0  

The best way I know is to create a separate table filles with foreign key, let's say "Student_sports" with records like

我知道的最好的方法是使用外键创建一个单独的表填充,让我们说“Student_sports”与记录像

student_id           sport_id
  1                     1
  1                     2
  2                     2
  3                     1

#1


0  

The best way I know is to create a separate table filles with foreign key, let's say "Student_sports" with records like

我知道的最好的方法是使用外键创建一个单独的表填充,让我们说“Student_sports”与记录像

student_id           sport_id
  1                     1
  1                     2
  2                     2
  3                     1