Almacenamiento de diferentes tipos de preguntas y respuestas en una base de datos relacional

I have three types of questions:

  1. Vocab (represented by question:answer pares)
  2. Grammar (represented by question:[list, of, answers])
  3. Listening (represented by question:answer --where value is an .oog/.wav audio file).

I avoided the term key:value here since I'm not sure dictionaries can store audio.

Mi pregunta es:

How can I model this set of tables into a manageable design?

languages         lessons        lesson_types
=========         ========       ============
lang_id           lesson_id      lt_id
lang_name         lang_id        lt_name
                  lesson_name    lt_desc
                  lt_id

And that's the simple part.

The part I am having trouble understanding is how I can serialize different types of objects in python to overcome the differences each type of question proposes. In a strict, DBMS-only approach, I would use a separate table for each type of question (since BLOBs hold audio, grammar questions can have upwards to a dozen parts to describe its tense, gender, etc). I'm excited to see what sqlalchemy is able to do in terms of simplifying a database's structure.

How can I go about designing a questions table that can handle dictionaries así como as serializable, sqlite3-friendly audio formats?

preguntado el 01 de febrero de 12 a las 22:02

1 Respuestas

What's wrong with a table Questions (question_id, question_text), a table Answers (question id, answer_text), and a table Audio_Answers (question_id, audio_blob)? (That is: Each Answer row contains uno question id, and uno answer. Where a question has multiple answers, there will be multiple entries the answer table for that question. This applies in the exact same way to the Audio_Answers table.)

That would allow you to model all three types of question with maximum flexibility. questions with a single or multiple answers can be handled in the exact same way. The two answers tables hold all of the answers, one answer per row.

Respondido 03 Feb 12, 03:02

Well then I should go with a table for grammar_answers, you think? I designed a prototype that skipped the database, and my biggest problem was comprehensive coverage of the various conjugations...I ended up with a list that kept gaining more and more Null parts as I explored more ways to use the same verbs. - Droogans

@Droogans: No, the point of this structure is that questions with a single or multiple answers can be handled in the exact same way. The two answers tables hold all of the answers. - Marcin

So, a character-delimited value list goes into the same answer table that simple vocab answers do? - Droogans

@Droogans: Absolutely not! Each row contains uno question id, and uno answer. Where a question has multiple answers, there will be multiple entries the answer table for that question. - Marcin

I gave you the accepted answer, but only time will tell if your suggestion pans out. It seems good...but database design questions are hard. There's never any way to find out unless you just hacerlo. ¡Gracias! - Droogans

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.