Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - How to normalize these tables..help pls
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to normalize these tables..help pls

 Post Reply Post Reply
Author
PrivateEye View Drop Down
Groupie
Groupie
Avatar

Joined: 21 March 2003
Location: United Kingdom
Status: Offline
Points: 168
Post Options Post Options   Thanks (0) Thanks(0)   Quote PrivateEye Quote  Post ReplyReply Direct Link To This Post Topic: How to normalize these tables..help pls
    Posted: 13 June 2004 at 8:12am

I want to conduct a survery on my website where users can select answers of a question. I am confused how to normalize the database. I am writing here the table definitions:

tblUsers

UserID, Username, PhoneNumber

tblQuestions

QuestionID, Question_Description

tblChoices

ChoiceID, QuestionID, Choice_Description

* A question has more than one choices, users can select multiple answers.

Now I want to know how to save users options against a question. I think that there is missing table(s) which are confusing for me. If anyone can normalize this database, I will be thankfull.



Edited by PrivateEye
The Judgement Day
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 13 June 2004 at 10:49am
Just add one table

tblSurvey

AnswerID, UserID, QuestionID, ChoiceID
 
 
This way a user can have as many answers as you want, thus you can write a constraint to limit the number or asnwers for each users
Back to Top
PrivateEye View Drop Down
Groupie
Groupie
Avatar

Joined: 21 March 2003
Location: United Kingdom
Status: Offline
Points: 168
Post Options Post Options   Thanks (0) Thanks(0)   Quote PrivateEye Quote  Post ReplyReply Direct Link To This Post Posted: 13 June 2004 at 11:24am

Thanx michael. Will you be kind enough to write a query here showing results of the survery from tblSurvery table for each user (by question and its choice) so that I can print out the survery. This time I am confused how to Join tables. Thanx in advance.



Edited by PrivateEye
The Judgement Day
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 13 June 2004 at 11:41am
Actually scratch the Question ID column from the tblSurvey, did not see you had it in there.....
After that just do a simple join between the tables....
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.