为用户创建基于复古成就的网站的Mysql数据库设计
背景故事
在回答这个问题之前先讲一个背景故事。
- 我正在开发一个 Mysql 驱动的网站,允许人们跟踪用户 为“复古”游戏创造了成就。
- 到目前为止,我一直在手动跟踪成就,但 喜欢以基于荣誉的自我检查方式向所有人开放 系统。
- 我已经登录正常,所以有一个登录表,其中包含用户名 和密码。 (还有其他专栏,但我认为这对 回答)。
- 最初,我打算为每个用户创建一个表,我希望 会达到数千,但在阅读了网站上的帖子后,我 逐渐明白这是一个坏主意。
问题
我的问题如下:
最有效的表结构是什么?
- 我希望每个用户都有一个每场比赛的成就列表,其中 已实现和未实现的代表,因此他们需要能够 从预设列表中添加游戏。
- 由于大多数人都有不止一款游戏,因此会有多个列表。
- 我认为这是多对多的关系,但我不太确定 如何将所有元素链接在一起,以便我可以开始编写 查询。
感谢您阅读这篇文章以及提供的任何建议。
Background Story
A little back story before i get to the question.
- I'm working on a Mysql driven site that allows people to track user
created achievements for "retro" games. - Ive been hand tracking the achievements up to this point, but would
like to open it up for everyone with a honor based self checking
system. - Ive got the login working, so there is a login table, with username
and password. (also other columns tho i dont think its matters to the
answer). - Originally, i was going to create a table per user, which id hope
would get into the thousands, but after reading post on the site, ive
come to understand that is a bad idea.
Questions
My question is the following:
What is the most efficient table(s) structure?
- I want each user to have a list of the achievements per game, with
achieved and non-achieved represented, so they will need to be able
to add games from a pre-set list. - There will be multiple lists as most people have more than 1 game.
- I think this is a many to many relationship, but I'm not quite sure
how to link all the elements together so i can start writing the
queries.
Thanks for reading this post and any advice provided.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能应该有一个用户、游戏、成就和 user_achievements 表。成就表中的每个条目都可以链接到一个游戏 ID。当用户实现某个成就时,您可以在 user_achievements 表中添加包含 user_id 和 Achievement_id 的条目。如果没有该用户和成就的条目,则意味着他们尚未实现。
You should probably have a users, games, achievements, and user_achievements tables. Each entry in the achievement table can be linked to a game id. When a user achieves a certain achievement, you can add an entry with the user_id and achievement_id in the user_achievements table. If there is no entry for that user and achievement, that means they have not achieved it.
您可以创建多个表格来代表系统的每个部分。例子。
现在,您可以创建尽可能多的用户,而不会影响成就,反之亦然。
想象一下您创建了两个游戏。帝国时代和帝国时代II。这些将在数据库中创建
,然后假设用户“BoomBlaster”拥有这两款游戏,您可以在用户“usesgames”选项卡行中创建一个逗号分隔的列表,就像这样
想象一下您使用 PHP,您将能够分隔这些游戏通过使用
explode();
函数到目前为止,您现在可以将用户和游戏连接在一起,以获取数据库表“Achievements”中的成就通过说
我希望您看到我的观点。
此致。
乔纳斯
You can create several tabels representing each of their own parts of your system. Example.
Now, you can create as many users as possible, without interfering with the achievements vice versa.
Imagine you create two games. Age of Empires and Age of Empires II. Those will be created in the database with
Lets then say, that user "BoomBlaster" own both games, you could make a comma seperated list in that users "usesgames" tabel row, like this
Imagining your using PHP you would be able to seperate those by using the
explode();
functionYet to this, you can now connect the user and the game toghetter to fetch the achievements in the database table "Achievements" By saying
I hope you see my point.
Best regards.
Jonas