简体   繁体   English

MySQL数据库设计-清单/测验应用程序

[英]Mysql Database design - checklist/quiz application

I'm currently 'learning' codeigniter, php and mySql all at once as I try and create a "checklist" type of website, where visitors sign up, create a project and are asked a list of questions, where they must input certain fields 当我尝试创建“清单”类型的网站时,我目前正在一次“学习” codeigniter,php和mySql,访问者在其中注册,创建项目并被询问问题列表,他们必须在其中输入某些字段

I'm a little stuck on my mySQL DB-design... (completely stuck actually) 我的mySQL DB设计有些卡住...(实际上完全卡住了)

what it comes down to is... 归结为...

1 project can have one of 3 types. 1个项目可以具有3种类型之一。 "type a/b/c" “输入a / b / c”

Type a has 20 questions 类型A有20个问题

Type b = type a + 15 questions 类型b =类型a + 15个问题

Type c = type b + 15 questions... 类型c =类型b + 15个问题...

So basically I'd like to be able to easily say, Question A is Type A AND/OR Type B but not C . 因此,基本上,我希望能够轻松地说,问题A是A型和/或B型,不是C型

Now, I don't know if what I'm doing is correct, but I'm basically making two tables and then setting a relationship between them "many to many" (i think?) n:m in mySQL workbench 现在,我不知道我在做什么是正确的,但我基本上做两个表,然后设置它们之间的关系“多对多”(我想?)N:在MySQL工作台米

ProjectType
id
ProjectTypeName

Questions
ID
Title etc...

ProjectType_has_Questions
ProjectType_id
Questions_id

Also, every question "CAN, not must" have 3 results (current facts) and 3 corrections (improvement on results). 此外,每个“可以,不一定”的问题都有3个结果(当前事实)和3个更正(结果改进)。

I don't know if this is making any sense to anyone here, sure as hell is baffeling me :-/ 我不知道这对这里的任何人是否有意义,请确保地狱在困扰我:-/

any thoughts? 有什么想法吗?

ps: I tried to attach an image but seeing as this is my first time using the site this wasn't allowed. ps:我尝试附加图片,但是看到这是我第一次使用该网站,所以这是不允许的。

I'll respond to what I understand here. 我会在这里回应我的理解。 Had a few other questions that I commented on in your question. 还有其他一些问题,我曾在您的问题中发表过评论。

If your project types will always aggregate -- that is, Type C is always a superset of Type B, which is always a superset of Type A -- then for the questions you can just specify the biggest project that that particular question will be included in. Say, if a question will appear in Types A and B, then designate the question as Type B. If it will appear in all three types, designate it as Type C. 如果您的项目类型将始终聚合(即类型C始终是类型B的超集,而它始终是类型A的超集),那么对于问题,您可以仅指定将包含该特定问题的最大项目例如,如果问题将出现在类型A和类型B中,则将其指定为类型B。如果将出现在所有这三种类型中,则将其指定为类型C。

You're committing yourself when you do this, though. 但是,您在执行此操作时会做出自己的承诺。 A more flexible way to do this would be to have a linking table that includes the question ID and the project type ID. 一种更灵活的方法是拥有一个包含问题ID和项目类型ID的链接表。 Each question can have one or more entries in this table. 每个问题可以在此表中包含一个或多个条目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM