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

发布于 2024-09-28 12:56:06 字数 815 浏览 1 评论 0原文

我目前正在同时“学习”codeigniter、php 和 mySql,因为我尝试创建一个“清单”类型的网站,访问者在其中注册、创建项目并被询问一系列问题,他们必须在其中输入某些字段

我对 mySQL DB 设计有点卡住了...(实际上完全卡住了)

它归结为...

1 个项目可以有 3 种类型之一。 “a/b/c 类型”

a 类型有 20 个问题

b 类型 = a 类型 + 15 个问题

c 类型 = b 类型 + 15 个问题...

所以基本上我希望能够轻松地说,问题 A 是A 型 和/或 B 型,但不是 C

现在,我不知道我所做的是否正确,但我基本上是制作两个表,然后在 mySQL 工作台中设置它们之间的“多对多”关系(我认为?) n:m

ProjectType
id
ProjectTypeName

Questions
ID
Title etc...

ProjectType_has_Questions
ProjectType_id
Questions_id

此外,每个问题“可以,不是必须”都有 3 个结果(当前事实)和 3 个更正(结果的改进)。

我不知道这对这里的任何人来说是否有意义,当然让我感到困惑:-/

有什么想法吗?

ps:我尝试附加图像,但这是我第一次使用该网站,这是不允许的。

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

I'm a little stuck on my mySQL DB-design... (completely stuck actually)

what it comes down to is...

1 project can have one of 3 types. "type a/b/c"

Type a has 20 questions

Type b = type a + 15 questions

Type c = type b + 15 questions...

So basically I'd like to be able to easily say, Question A is Type A AND/OR Type B but not 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

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).

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

荆棘i 2024-10-05 12:56:06

我就在这里根据我的理解来回复一下。我在你的问题中评论了其他一些问题。

如果您的项目类型始终聚合——也就是说,C 型始终是 B 型的超集,而 B 型始终是 A 型的超集——那么对于问题,您可以指定该特定问题将包含的最大项目例如,如果一个问题将出现在类型 A 和 B 中,则将该问题指定为类型 B。如果它将出现在所有三种类型中,则将其指定为类型 C。

不过,当您这样做时,您是在承诺自己。更灵活的方法是使用一个包含问题 ID 和项目类型 ID 的链接表。每个问题在此表中可以有一个或多个条目。

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.

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. Each question can have one or more entries in this table.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文