Click here to Skip to main content
15,126,209 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

SQL
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

<img>https://fbcdn-sphotos-a-a.akamaihd.net/hphotos-ak-prn2/t1.0-9/10004017_272448229590981_2128351427_n.jpg</img>

Could you please help me make this data more clearly and be logical
Posted
Comments
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.

Tip:
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)
   
Comments
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