Creating Tables in SQL

Results 1 to 2 of 2

Thread: Creating Tables in SQL

  1. #1
    Joey Guest

    Default Creating Tables in SQL

    I have a site that I ask LOTS of questions of new users. Each question has a list of possible responses. I am trying to figure out how to do this in SQL. I had though that I should put all the responses in a SQL Table, but it doesn&#039t seem like I can do it in one table. Am I going to have to create a Table for each question with their responses?? Maybe it&#039s too early in the morning and I&#039m not thinking clearly. Please help!<BR><BR>Thanks!

  2. #2
    Join Date
    Dec 1969

    Default RE: Creating Tables in SQL

    let me see if I can get this right without actually designing the database...<BR>:o)<BR><BR>You could first create your USER table. Give them a PRIMARY KEY set to an incremental and unique number and let&#039s call that USER_ID.<BR><BR>Then create a table of QUESTIONS. Give each one you create a PRIMARY KEY in the same way as above. Let&#039s call each question&#039s id QUESTION_ID.<BR><BR>Do the same thing for a possible RESPONSES table. This is actually very tricky and there are many ways I can think of to do it. You could actually skip this table all together and move everything into forms actually on the client&#039s page. This is up to you. If you go the table way, you might want to also add a field in there for referencing the QUESTION_ID that it should apply to.<BR><BR>Then finally create your USER_RESPONSES table. This could have many entries for each person, one for each response to a question. A possible outline for this table would be:<BR>ID - incremental unique number<BR>USER_ID - to know for what user this is for<BR>QUESTION_ID - for what question?<BR>RESPONSE_ID - what was their response?<BR><BR>Again, instead of a RESPONSE_ID refencing back to your RESPONSES table, you could actually have the response in text from the client, sent directly from the browser. Also, make the USER_ID and QUESTION_ID both PRIMARY KEYs. Together they will form a unique identity, so that you could not have 2 responses for the same question from the same user. If you do not want this, you could actually add another PRIMARY KEy to this table in the RESPONSE_ID.<BR><BR>I hope this helps. Good luck.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts