Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello ,
I have to create a quiz in my web application, that's easy . Issue comes when there are 3 different types of quiz.

Quiz 1 ) -> Objective type.
Quiz 2 ) -> Images and Answer by selecting a lable from Image.
Quiz 3 ) -> Plain text question with answer linked to an existing table.

I am having hard time in creating table structure for answers table. Multiple tables will be needed here for each type of quiz but how do i link them to Answers. So if question is for quiz type 1 then link to Answer table for quiz type 1 so on..

Now i need to create answer table. I know that it will be Bad if i put all the columns in a single table so i have to normalize and create saperate tables for saperate answers.

I don't even need Exact code. just point me in the right direction to create the appropriate structure.

Thanks

What I have tried:

I create Tables for quiz

Create table QuizMaster (Id int identity primary key , QuizName nvarchar(100),IsActive bit , CreatedDate datetime not null default getdate(),ModifiedDate datetime)

Create table Quiz (Id int identity primary Key , QuizType int foreign key references QuizMaster(Id),Title nvarchar(1000), [Description] nvarchar(4000),CreatedDate datetime not null default getdate(), ModifiedDate datetime,IsActive bit  )

Create Table QuizQuestions (Id int identity primary key , QuizNo int foreign key references Quiz(Id), Title nvarchar(1000),ImagePath nvarchar(1000),ImageName nvarchar(500))
Posted
Updated 4-Dec-17 21:28pm
v2
Comments
CHill60 5-Dec-17 8:30am    
Hint - you do not need a separate table for each type of answer! That is not quite how normalization works.
Have a QuizType or AnswerType column possibly.
The table can have a column that includes a link to an image, another that contains text - I have no idea what you mean by "Objective type" but by all means have a separate column for that too.
The key point is that these are all "Answers". You are not going to be repeating information by having all of the answers in one table.
Alternatively, if you have a fixed number of images say, you could store the Image links in one table and have the answers table link to the Image table - this would allow for any image to be used in more than one question.
Charlie Andrews 6-Dec-17 2:18am    
ohh i didn't gave it a thought that all these are answers only. :p so no need for separate tables. I'll give it a try. Thanks :)
CHill60 6-Dec-17 8:35am    
Good luck :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900