玩家卡 Collection MySQL
Player's Card Collection MySQL
我正在使用 C# 开发在线 TCG,但在寻找存储和检索玩家卡片的有效解决方案时遇到了麻烦 collection。本质上,我想要的是数据库中的每个玩家都有一个 "card collection",我认为这将是某种类型的字典,其中包含以下形式的条目(卡 ID、拥有的数量)。我将非常频繁地添加、删除和编辑此 collection 中的每个条目。我正在研究 XML 序列化,但它似乎对大量卡片来说会很慢。我也想过像一串
"id1,数量1
id2,amount2
并且只是在 ',' 和换行符处拆分,但我觉得这样编辑字符串会很麻烦。其他人建议像新的 table 那样做,其中包含以下字段:userid、cardid、amount。我使用的是 MySQL 并且不太熟悉这些数据库解决方案。是否有最佳解决方案?
一定要在您的数据库中使用连接 table。如果您设置了正确的索引和引擎,读取 collection 会非常高效。操纵 collection 也会更有效率 - 序列化并不便宜!
如果您想要生成关于普通玩家 collection.
的组成的统计数据,它也能很好地帮助您。
[Users ]
|UserID_|
|.... |
|_______]
[Cards ](all cards in the TCG)
|CardID_ |
|.... |
|________|
[Decks ]
|DeckID_ |
|DeckUserID | -> Users.UserID 1..n
|.... |
|___________|
[DeckCards]
|DeckID_ | -> Decks.DeckID 1..n
|CardID_ | -> Cards.CardID (1..n||1..1) to fit your needs
[_________|
[Collection ]
|CollectionID_|
|UserID | -> Users.UserID 1..1 to bound only one collection per user
|.... |
|_____________|
[CollectionCards]
|CollectionID_ | -> Collection.CollectionID 1..n
|CardID_ | -> Cards.CardID (1..n||1..1) to fit your needs
[_______________|
您只显示:Users->Collection->CollectionCards->Cards 以显示 collection 个用户的卡片。
您只显示:Users->Deck->DeckCards->Cards 以显示卡片组中的卡片
希望能被理解...
我正在使用 C# 开发在线 TCG,但在寻找存储和检索玩家卡片的有效解决方案时遇到了麻烦 collection。本质上,我想要的是数据库中的每个玩家都有一个 "card collection",我认为这将是某种类型的字典,其中包含以下形式的条目(卡 ID、拥有的数量)。我将非常频繁地添加、删除和编辑此 collection 中的每个条目。我正在研究 XML 序列化,但它似乎对大量卡片来说会很慢。我也想过像一串
"id1,数量1
id2,amount2
并且只是在 ',' 和换行符处拆分,但我觉得这样编辑字符串会很麻烦。其他人建议像新的 table 那样做,其中包含以下字段:userid、cardid、amount。我使用的是 MySQL 并且不太熟悉这些数据库解决方案。是否有最佳解决方案?
一定要在您的数据库中使用连接 table。如果您设置了正确的索引和引擎,读取 collection 会非常高效。操纵 collection 也会更有效率 - 序列化并不便宜!
如果您想要生成关于普通玩家 collection.
的组成的统计数据,它也能很好地帮助您。[Users ]
|UserID_|
|.... |
|_______]
[Cards ](all cards in the TCG)
|CardID_ |
|.... |
|________|
[Decks ]
|DeckID_ |
|DeckUserID | -> Users.UserID 1..n
|.... |
|___________|
[DeckCards]
|DeckID_ | -> Decks.DeckID 1..n
|CardID_ | -> Cards.CardID (1..n||1..1) to fit your needs
[_________|
[Collection ]
|CollectionID_|
|UserID | -> Users.UserID 1..1 to bound only one collection per user
|.... |
|_____________|
[CollectionCards]
|CollectionID_ | -> Collection.CollectionID 1..n
|CardID_ | -> Cards.CardID (1..n||1..1) to fit your needs
[_______________|
您只显示:Users->Collection->CollectionCards->Cards 以显示 collection 个用户的卡片。
您只显示:Users->Deck->DeckCards->Cards 以显示卡片组中的卡片
希望能被理解...