Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have created table Question with 3 types : (FindBug, Fillblank, MultiChoice ) but each of type has a different answer type and question type .
In Database I save a question and answer for each type questions like this:
- Find Bug Question : answer (width, height, top, left by a bug)
- Fillblank : question (ListChoiceA, ListChoiceB, ListChoiceC) Answer (correct A, CorrectB, correct C)
- Multichoice : question (ListChoice) Answer (answer A)
I don't know how to normal my database with SQL 2008, I have created a big table with saving all of this attribute and I attach images for table Question

CREATE TABLE [dbo].[tblQuestion](
    [QuestionID] [int] NOT NULL,
    [QuestionDif] [int] NULL,
    [QuestionSrc] [nvarchar](50) NULL,
    [Type] [nchar](10) NULL,
    [Positionwidth] [nchar](10) NULL,
    [Positionheight] [nchar](10) NULL,
    [PositionTop] [nchar](10) NULL,
    [PositionLeft] [nchar](10) NULL,
    [ListA] [nvarchar](50) NULL,
    [ListB] [nvarchar](50) NULL,
    [ListC] [nvarchar](50) NULL,
    [A] [nchar](50) NULL,
    [B] [nchar](50) NULL,
    [C] [nchar](50) NULL,
    [ListAnswer] [nvarchar](100) NULL,
    [Answer] [nchar](50) NULL,

and this is image of this table


Could you please help me make this data more clearly and be logical
Tomas Takac 27-Mar-14 18:35pm    
What you are looking for is called Table-per-Type, in EF terminology at least. But what you have now is not necessarily a bad solution. This short article should get you started: How to choose an Inheritance Strategy
Member 10606752 28-Mar-14 0:46am    
Thanks Tomas, this is exactly what I want, can I do it in SQL sever 2008, what is it's term in SQL sever
Rob Grainger 28-Mar-14 13:00pm    
There is a quick overview of data normalisation : here that should help.

It shows a simple example that should help you grasp the basics.

1 solution

I'd suggest to start here[^].

What you're looking for is calling quiz[^]. There are several ways to build a quiz. It depends on your needs. Study the examples to find a solution.

There would be more than one table, for example: Questions and Answers. They should be related one to many. For example:
Questions     | Answers
QuestID (PK)--| AnsID (PK)
              |--QuestID (FK)
Share this answer
Member 10606752 31-Mar-14 10:30am    
Thanks very much, this is very useful,
Maciej Los 31-Mar-14 10:50am    
You're welcome ;)

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