1. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Rep Power

    Database design questions

    I have few questions that i would like to ask:

    1. If i am creating a system whereby there is a hierarchy of users (i.e. students, teachers, manager). should I store this in one table or three? avoids having to self join again and again to get relevant info?

    2. if i need a system whereby I can set some questions and answers, or questions with multi-choice answers. How best should I store them?

    Class_id, question_id,question,answer (for Q&A)

    class_id,question_id,question,answer (for multiple choice Questions)
  2. #2
  3. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Rep Power
    Iwould do the following:
    #1 For question1:
    Store them in the same table but with a usergroup,
    id name groupID etc
    33 John 3          xxx
    Make a second table to store user groups
    GroupID description
    1          students
    2          teachers
    3          alumni
    *this allows you to add and alter groups or names and sort them by number

    #2 For your second question.
    I would make 2 tables (questions and answers)
    and interlink them with their corresponding id's

    The reason why you want 2 different tables is because you would otherwise duplicate data, which is unnecesary.
    table questions:
    QID  question                      type
    22    What do gorilla's eat?    multiple
    table answers:
    AID  QID   answer                     
    1      22    banana's
    2      22    Soup
    3      22    Lemons

    Comments on this post

    • paulh1983 agrees : sorry for taking so long to say thanks
    Last edited by aeternus; December 10th, 2012 at 04:57 PM.

IMN logo majestic logo threadwatch logo seochat tools logo