#1
  1. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,997
    Rep Power
    375

    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)
    question_id,choice
  2. #2
  3. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    Iwould do the following:
    #1 For question1:
    Store them in the same table but with a usergroup,
    Code:
    id name groupID etc
    33 John 3          xxx
    Make a second table to store user groups
    Code:
    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:
    Code:
    QID  question                      type
    22    What do gorilla's eat?    multiple
    table answers:
    Code:
    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