Create a new Primary Key on survey table
-
I have a survey table where people were asked up 7 question and I'm trying to figure out the best way to assign a primary key in sql. here how it looks like. key surveyid questionid answid questions answer ed45894 1 3 1 when was the last time you bought soda 1 week ago ed45894 1 7 2 How many live in your house 4 ed45894 1 4 5 do you children in your house Yes ed45894 1 2 7 do you use coupon while shopping No fs45895 1 3 4 when was the last time you bought soda yesterday fs45895 1 7 2 How many live in your house 1 fs45895 1 4 5 do you children in your house Yes fs45895 1 2 7 do you use coupon while shopping No
-
I have a survey table where people were asked up 7 question and I'm trying to figure out the best way to assign a primary key in sql. here how it looks like. key surveyid questionid answid questions answer ed45894 1 3 1 when was the last time you bought soda 1 week ago ed45894 1 7 2 How many live in your house 4 ed45894 1 4 5 do you children in your house Yes ed45894 1 2 7 do you use coupon while shopping No fs45895 1 3 4 when was the last time you bought soda yesterday fs45895 1 7 2 How many live in your house 1 fs45895 1 4 5 do you children in your house Yes fs45895 1 2 7 do you use coupon while shopping No
You're highly unlikely to overrun an int for surveys.
"Never attribute to malice that which can be explained by stupidity." - Hanlon's Razor
-
I have a survey table where people were asked up 7 question and I'm trying to figure out the best way to assign a primary key in sql. here how it looks like. key surveyid questionid answid questions answer ed45894 1 3 1 when was the last time you bought soda 1 week ago ed45894 1 7 2 How many live in your house 4 ed45894 1 4 5 do you children in your house Yes ed45894 1 2 7 do you use coupon while shopping No fs45895 1 3 4 when was the last time you bought soda yesterday fs45895 1 7 2 How many live in your house 1 fs45895 1 4 5 do you children in your house Yes fs45895 1 2 7 do you use coupon while shopping No
learning_new wrote:
trying to figure out the best way to assign a primary key in sql
There is only one way to do so; you find the column or columns that uniquely identify a single row in the collection. If you are having trouble with it, you're not normalizing. Your table should be in 3NF; or in short, you want the key, the whole key, and nothing but the key. Codd's law, look it up.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
I have a survey table where people were asked up 7 question and I'm trying to figure out the best way to assign a primary key in sql. here how it looks like. key surveyid questionid answid questions answer ed45894 1 3 1 when was the last time you bought soda 1 week ago ed45894 1 7 2 How many live in your house 4 ed45894 1 4 5 do you children in your house Yes ed45894 1 2 7 do you use coupon while shopping No fs45895 1 3 4 when was the last time you bought soda yesterday fs45895 1 7 2 How many live in your house 1 fs45895 1 4 5 do you children in your house Yes fs45895 1 2 7 do you use coupon while shopping No
Can you explain what these columns are ? Looks like you have enough data to make a primary key, but understanding the data would lead to a suggestion. :java:
-
Can you explain what these columns are ? Looks like you have enough data to make a primary key, but understanding the data would lead to a suggestion. :java:
Thanks David. I was able to figure out.