2012-01-07 37 views
0

我目前正在设计我的游戏的数据库 - 我希望它尽可能的漂亮。下面你会发现一些漂亮的数据库结构

Database Game { 

//The ID of the game (unique) 
int id 

//First player data 
varchar firstPlayerName 
int firstPlayerSessionID 
varchar firstPlayerIP 

//Second player data 
varchar secondPlayerName 
int secondPlayerSessionID 
varchar secondPlayerIP 

//The opponent type, 0 is default (against the "computer") while 1 is against another player 
int type 

//The size of the game, default: 3 
int size 

} 

(对不起格式,它只是用于自己混搭只) 我主要是寻找在“播放器部分”的建议 - 我想这没关系的方式,现在是这样,但如果有超过5名球员呢?如果你问我,那就麻烦了。

有没有更好的方法来做到这一点?

回答

3

有一个单独的玩家表,并根据玩家和游戏的ID将这两个表与第三个表(Game_Players)相关联。

0

为什么不将所有游戏元素分开在不同的关系表中?

为玩家提供单独的桌子,为游戏的设置提供另一个桌子,等等。

这样一来,组织游戏的各个方面会更加简单,从而更容易更改游戏元素,也更容易添加新元素。