How can I structure my database so that the two tables that make up the same "elemental" link to another?

I read about structuring and normalizing the database and decided to rebuild the database behind my training stuff to reduce redundancy.

I have different types of records that you can find out. Texts of spaces / cloze (one text, many spaces) and simple known-unknown (one question, one answer) types.

Now I am a little pickle:

  • spaces need the same columns in the user table as response-response types
  • but they need fewer columns than answer types (all this information is in the table clozetests).
  • I want a “magic” foreign key that can indicate both a gap and a term table. Of course, their identifiers will overlap. I don't like having both term_id and gap_id in user_terms, which seems inelegant (but the most elegant that I can come up with after searching on Google for a while, not knowing what name this pickle goes through).
  • I do not want an analog user_gapswith user_terms, because then I would be in the same brine when it comes to the table user_terms_answers.

I exposed this cardboard collage cutout of my outline. I did not delete material that is not relevant to this issue, but I can do it if any confusion can be eliminated. I think it looks super neat. More subtle than my mental concept. I said that any help would be greatly appreciated? Defendants could believe in their wisdom. Cutout of my schema diagram


Background , if you like it, it is not relevant to the issue.
Before the remodeling, I had all of them in one table (because I quickly added the break texts), so the break texts were “normal” elements without answers, and spaces, where there are objects without questions. The app ties them together.


Edit

, SO . 100% . , , -, .

+3
2

Stackoverflow .

, , , , .

, . ( ), . .

  • ,
  • , . , , Google.

, . , .

enter image description here

+1

, , . , . , .

. (LangLevelTestNo).

() . . . .

> . , . , .. p >

enter image description here

+2

Source: https://habr.com/ru/post/1788881/


All Articles