Tag system for Django -


i building quiz app user (content creator or author) can create quizzes (choice based questions , solutions) specific domain. these quiz can attempted other users (consumers - not yet implemented).

to allow quiz consumers able search questions based on specific domains of interest (and add granularity quiz content), implementing tagging system attached questions.

here models:

class question(models.model):         ques_id = models.autofield(primary_key=true)      ques_text = models.textfield(max_length=1024, blank=false)     ques_author = models.foreignkey('author')     ques_created = models.datefield(auto_now_add=true)     ques_dscore = models.integerfield()     ques_bloom = models.charfield(max_length=3)     ques_subject = models.charfield(max_length=3)     ques_type = models.charfield(max_length=1)     ques_flags = models.charfield(max_length=16)     ques_quiz = models.manytomanyfield('quiz')      def __unicode__(self):         return self.ques_text  class choice(models.model):      choice_id = models.autofield(primary_key=true)     choice_text = models.charfield(max_length=256, blank=false)     choice_ques = models.foreignkey('question')     choice_ans = models.booleanfield(default=false)     choice_tags = models.charfield(max_length=32)      def __unicode__(self):         return self.choice_text  class answer(models.model):      answer_id = models.autofield(primary_key=true)     answer_text = models.textfield(max_length=1024)     answer_ques = models.foreignkey('question')     answer_choice = models.foreignkey('choice')     answer_tags = models.charfield(max_length=128)  class author(models.model):      user = models.onetoonefield(user)     domain = models.charfield(max_length=16)      def __unicode__(self):         return self.user.username   # table storing tags class tags(models.model):      tags_id = models.autofield(primary_key=true)     tags_text = models.charfield(max_length=16)      def __unicode__(self):         return self.tags_text  # table connects tags question attached tag # research on web, can infered # 3nf tagging (toxi solution) best way go # inserts slow on selects class tagcon(models.model):      tagcon_id = models.autofield(primary_key=true)     tagcon_tags = models.foreignkey('tags')     tagcon_ques = models.foreignkey('question') 

i have applied 3nf tagging toxi solution. issue denormalized system in faster selects , 3nf faster inserts slow searches.

i confused if should use manytomany field type tags. enlighten if better use manytomany field inbuilt in django or implement 3nf system done?

this exactly same manytomanyfield. difference adding field give explicit accessor question tag.

(note, models odd. there absolutely no benefit in prefixing every field name abbreviated version of model name; can ever access field via model anyway, doing question.ques_text, redundant. , shouldn't defining own pk fields unless have reason.)


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -