Good day. There is a database with tables:

  • Questions (ID, Vopros, IdDisciplini)
  • Disciplines (ID, Disciplina)
  • VariantsAnswers (ID, IdVoprosa, Variant, IsTrue)
  • Categories (ID, NazvaneEkzamena, Year)
  • The list of questions (ID, IdVoprosa, IdKategorii) // In such and such a year, on such an exam, there will be such and such a question, on the discipline such and such
  • Performance (IdStudenta, IdSpiskaVoprosa, IdVarianta) // The option that the user has chosen for this issue

Because A question can be repeated, for example, in the year 2013 and 2014, I would like to leave one question, not several (in order to tie up the comments of a specific question in the future and not produce the same in the database).
But! The field "question" (table of questions) may be the same in several questions, but there must be different fields "Option" for these questions in the table OptionsAnswers. (Well, for example, there can be many “Choose the correct answer” questions, but the answers should differ in different questions).

And the most basic: for example, there is the question "How much is 2 + 2?" (Tabl Questions Id = 1). This Id correspond to options in the Options table:

id=333,variant='1',istrue=false; id=336,variant='2',istrue=false; id=338,variant='4',istrue=true; 

It seems as if everything is clear. And how to make a check in the performance table (IdStudenta, IdSpiskaVoprosa, IdVarianta), where if through a join we look at IdSpiskaVoprosa-> IdVoprosa-> VariantOtveta-> Id? In general, so that specifically for this question (id = 1) in the Performance table, you could put only IdVarianta = 333,336,338?

Maybe not very well formulated the idea. Or tell me how, maybe in a different way to form. Maybe this is too clumsy option? Thank.

  • > And how to make a check in the performance table (IdStudenta, IdSpiskaVoprosa, IdVarianta), where if through a join we look at IdSpiskaVoprosa-> IdVoprosa-> VariantOtveta-> Id? Implement it at the application level. In postgre and other engines, you can certainly make such a constraint, but it is simpler at the application level. - etki
  • And why the question "2 + 2 =" does not provide the answer options "10" and "11"? They are also true. :-) And your scheme is quite. I thought, and I did the same thing. Lacking only the table of students. - BuilderC

0