存储在具有相同ID的db中 [英] storing in db with same id

查看:80
本文介绍了存储在具有相同ID的db中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我正在研究在线考试项目,因为我有一个查询,即假设我们对不同的主题有相同的问题,那么如何将它们保存在数据库中

例如谁是HOD, IT可以在任何主题中询问,无论是cs还是电子产品。

所以我如何将这些类型的问题存储在数据库中。

解决方案

< blockquote>如果我正确理解你的问题,你会有很多可能的情况。在这种情况下,你应该使用如下结构:

- 主题表,包含不同的主题,如cs,电子产品等等

- 问题表包含个别问题

- SubjectQuestion表包含与主题相关的问题。



这样一个主题可以有多个问题,一个问题可以用于多个主题。该原则称为联结表,有关详细信息,请参阅联结表 - 维基百科,免费百科全书 [ ^ ]


在不知道您当前的数据库结构的情况下告诉你一个更好的方法会有点困难。然而,这应该看起来像这样的东西:



 问题表 
QuestionId
QuestionText
DepartmentId
CourseId


hello , i am working on online exam project, In that i have a query i.e. suppose we have same question for different subject ,then how to save them in database
Eg who is the HOD , IT can b asked in any subject, whether it is cs, or electronics.
so how i store these type of question in database.

解决方案

If I understand your question correctly, you have a many-to-may situation. In that case you should use a structure like:
- Subject table, contains different subjects such as cs, electronics, and so on
- Question table contains individual questions
- SubjectQuestion table contains questions linked to subject.

This way one subject can have multiple questions and one question can be usied for multiple subjects. The principle is called junction table, for more information, see Junction table - Wikipedia, the free encyclopedia[^]


Without knowing your current database structure it will be a little difficult to tell you a better way. However this how it should probably look soemthing like this:

QuestionTable
    QuestionId
    QuestionText
    DepartmentId
    CourseId


这篇关于存储在具有相同ID的db中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆