检查我的 SQLite 数据库表设计
我正在制作一个问答游戏,我想知道这种方法是否可以?
trivia_table
*movie_id
name
genre
question_table
*movie_id
*question_id
question
difficulty
answers_table
*question_id
A
B
C
D
Answer
所以每部电影都会有自己的问题表。
我还想也许我可以将所有问题放在一个大表中,然后在 Question_table 中添加每部电影的问题数量,然后将 pk movie_id 添加到answers_table 中?
I'm making a trivia game and I was wondering if this approach was OK?
trivia_table
*movie_id
name
genre
question_table
*movie_id
*question_id
question
difficulty
answers_table
*question_id
A
B
C
D
Answer
So each movie will have its own table of questions.
I also thought that maybe I could throw all my questions in one big table and by adding the number of questions there are for each movie in the question_table and then adding the pk movie_id to the answers_table as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该将问题和答案表结合起来 - 每个问题都会有一个答案行。单个问题不会有多个答案行。单个答案不适用于多个问题。
您不应该为每部电影拥有单独的表格(或为每部电影修订后的单独表格)。
如果问题 ID 是唯一的(在所有电影中),您可以将其作为组合问答表的主键。
您的“trivia_table”最好命名为“movies”。您的组合问答表可以称为“琐事”。表名上的
_table
后缀没有任何好处。You should combine the question and answer tables - you will have one answer row for each question. A single question won't have multiple answer rows. A single answer won't apply to multiple questions.
You should not have separate tables for each movie (or a separate table for each movie as revised).
If the question ID is unique (across all movies), you can make it the primary key of the combined Q&A table.
Your 'trivia_table' would be better named 'movies'. Your combined Q&A table could be called 'trivia'. There is no virtue in the
_table
suffix on the table name.