When you've saved the survey to the database, you will have a ROW ID. That ROW ID can serve as the ID of the survey. So you might have a surveypage.aspx and you can pass it
ok , but that link how i can let it appear to the end user for example let's say that i have the follwoing :
click here to generate an email link now when the user click on the prev link i need to generate to him ( appear to him ) thje link which will distributed ? how i can do that ?
After creating the survey, you will have an ID from your database. If you don't, you should modify your stored procedure to return the ID of the newly created survey. You can store that ID, say, in a session variable. Pass that along to the page that generates the emails and use it in the body of the email.
should i put Question and answer in one table or sepreated ?
the ID if i put it Auto Increment , it will make a problem later on ?
In the database i'll expalin my Question in the following senario
let's say that three people make thire survey , gnerated the link and they send it by email ,
now should i make databese for every user alone so can everyone has his result , or how i can connect the user who made survey with his own result. so when he access his control area he can see the result for his own survey ..
Senario 2:
while user making his survey at first it show for him a dropdown list he will choose from it the type of survey that he want let say for example he choose yes/no
now i need after he made his choice to apper to him the editor to put his Questions , how i can make the editor hide until he choose the type of survey from the dropdown list ?
after that he'll go to next page to put the answers for the questions , here my question is after he choose the survey type and puting the his Q A how i can generate page that has Q and the radio button ( yes/No) under each question ?
Separate the questions and answers. Each set of entries by an end user will correspond to questions which means that you'll have to have a foreign key reference.
No, the autoincrement won't cause a problem.
Obviously, don't make a new database for each user. It'll just be separate rows in the same table, differentiated by the User ID.
To hide a control you simply set its Visible property to false (either through codebehind or javascript). When the user selects an option you can make it visible using codebehind or javascript.
To generate a series of questions, use a repeater. For each question in the dataset, the repeater will render out one row, which is where you'd need to define the look and feel of the question in an ItemTemplate.
I strongly suggest that you get the database design nailed down first, else you'll face problems later.
Yeah, that'd be a better idea - show us the database design and then your question of how or whether you should separate the 'rows' or not can be answered.
Right, that's good. Still some changes you need to make though.
A survey can consist of multiple questions. Therefore, you should not have a 'question' row in the survey table. Make a new table just for questions. Each question should obviously have a QuestionId (auto increment) and be associated with a survey ID.
I assume 'type' means that it is either a Y/N or T/F or Written answer type question. Yes? I believe the type should also be stored against the question row rather than the survey itself. Think about it - would a survey consist of a series of questions of all types or just one type?
All surveys I see have multiple types, so this 'type' field should really be against the question itself.
Now that you have the questions in place, you need the potential answers against each question.
I'm assuming that's what the bottom 3 tables are, but of course, again, they should be against each question.
Finally, each user will select a survey and select answers in that survey. You will need another table that holds the userid against questionids along with answerIDs selected.
You also had a question about foreign keys incrementing? Not sure what you meant, but only the primary key in those tables should be made to increment. The foreign keys are simply constraints that say "If ID 92 exists in the parent table, then and only then will I allow the value 92 in this field in this child table."
Finally, each user will select a survey and select answers in that survey. You will need another table that holds the userid against questionids along with answerIDs selected.
did you mean i should make a table lets say it's name Result and consist from following rows ?
ResultID
UserID
QuestionID
WID
TFID
YNID
i really appreciate your help and i dont know how i should thank you for helping me ..
waiting for your reply
Regards
Last edited by alqous; Jan 24th, 2009 at 12:22 AM.
The Question table needs to know what type of a question it is linking to. Currently, the question table has no idea. This means that if you ask for QuestionID 29, your SQL query will have to look at at all three tables to find out where it is... that's inefficient. You will need to create a table with two columns - AnswerTypeId and AnswerTypeName. The values will be
1 - Written
2 - YesNo
3 - TrueFalse
Then, against each question, have an AnswerTypeId.
QuestionId = 29, Question = "Are you a pineapple?" AnswerTypeId = 2, SID = 8.
This way, when you see that AnswerTypeId = 2, you will look at the YesNo table, because you know that 2 is "YesNo".
OK, I need to add more comments - you don't have a way of specifying multiple choice questions.
I realize that I am not giving you a straight answer, I am only giving you pointers, this is because these skills that you will struggle with now will help you later when you work on a new project and help you realize how important database design is in any project. It's the foundation of your application and has to be done right.
OK, unless I've overlooked something, that looks fine.
You should start coding against it now, if you face problems, you can always go back and change the schema, but the changes should be easy enough at this point.
It does make sense to have every question in a row. That's called the one to many relationship. One survey has many questions. One question has many answers.
You just need to make sure that a SurveyId has a relationship with several QuestionIds.
In the Questions table, have a column called SurveyId which has a foreign key reference to SurveyId in the survey table. Make sure it's not unique. This way, you have set up a one-to-many relationship between the Survey table and the Questions table.
i faced something , after the user put hi info to register and hit the save button everything is ok and the info stored in the database , but if he make a refresh for the page the info dublicated how i can prevent that ?