Hi guys,
I have developed a project using windows forms, this project generates true or false questions from the database. The questions are displayed on a form in textbox and there two radio buttons one for "TRUE" and the other for "FALSE" to be selected by the user. is there simpler way I can store the answers that have selected by users into a database table.
I mean I know how I can insert the selected answer into a database table but my only issue that if I have got 10 questions and 5 users answering questions, does this mean I have to create a table for each and every user in order to insert the question and the select answer .. or will I have to insert the details in one table and have redundancy data?
I really really hope this makes sense and I am not asking anyone to do it for me.. I just need ideas
Thank you guys
解决方案
To be more specific than what SA already answered, you'll want to create a table named answers, or something like that. You'll need a column for the user_id, the question_id, and then the answer.
So, if you ever need to find all answers for a given user you can query based on user_id or if you want to see all answers for a given question you can query on question_id, etc.
You need to learn creation of dababase design (schema) and data modeling, this is quite a big topic, but… some reading:
http://en.wikipedia.org/wiki/Single_Point_of_Truth[^] (immediate answer to one of your questions),
http://en.wikipedia.org/wiki/Database_schema[^],
http://en.wikipedia.org/wiki/Database_normalization[^],
http://en.wikipedia.org/wiki/Data_modeling[^],
http://en.wikipedia.org/wiki/Database_integrity[^].
In practice, for many simple problems, like yours, people develop the sense of right schema and model pretty quickly, with experience. For some other problems, it could be very difficult issue requiring a lot of professionalism, to say the least.
—SA