Jump to content

Recommended Posts

Newbie here just looking for a simple explanation if there is one (I realize there might not be one).

 

Say I have an application where there will be tests, questions, and answers.

 

From what I read about normalization, it seems like the proper way to do it would be to have THREE tables..

 

TESTS (with fields like testid, testname, etc)

QUESTIONS (with fields like testid, questionid, question, etc)

ANSWERS (with fields like testid, questionid, answerid, answer, etc)

 

What I don't get is this...  Since every question will have a corresponding answer, why not have TWO tables like this...

 

TESTS (with fields like testid, testname, etc)

QUESTIONSANDANSWERS (with fields like testid, questionid, question, answerid, answer, etc)

 

It would seem that it would be easier to have all the Q & A stuff in ONE table so that my queries only have to query ONE table, but everything I read seems to indicate that this would be "normalized" by having the questions and answers in TWO separate tables.

 

It seems backwards to me so if there is anyone that can explain the theory behind this "normalization" stuff like I'm a 5 year old, please enlighten me.

 

Or is it possible that my example should be done the 2nd way?  haha, I doubt it, but have to ask.

 

I just want to make sure I do things the proper way before I delve into this project.

 

Thanks!

 

 

Link to comment
https://forums.phpfreaks.com/topic/231454-question-on-normalization-basics/
Share on other sites

if you were 100% that it will never be a many to 1 relationship than an 'answer' is just a property of a question.  Therefore it can just be a field on the question table.

 

But you also have to ask, will there ever be information about an answer that isn't directly about the question?  Like, how long it took to answer that question, what order the answer appeared in, etc..  That all could still be on the question table, but you wanna make sure that an answer is just 1 piece of info about a question and it isn't an entity of its own.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.