Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a simple Application In which i have users and these users are associated with some Villages mean that while creating their account they have been assigned some villages the rule is simple (one user can have one or many villages )

in my Application I have a questionnaire and there are many many question Each question Has a target value as well as achieved value (the target value is set by the supervisor of the person) and the achieved value is what the user achieved

The DB I have created is like that

Users(userID(P),UserNAme,Email,)

Villages(villageID(P),VillageName)

District(DistrictID(P),DistrictNAme)

Questions(questionID(P),Question_Text)

QuestionTarget(REcordID(P),QuestionID(F),TargetValue ,DistrictID(F))

Answers(AnswerID(P),Question_ID(F),Achieved,VillageID(F))

Check the Attached image and tell this db is correct the details is in image availble



below the url to see the attached picture of my DB desing

http://tinypic.com/r/1hcjye/8[^]
Posted
Comments
jgakenhe 29-Aug-15 15:25pm    
The design is probably right, but you aren't showing the relationships or cardinality.
Malikdanish 29-Aug-15 15:47pm    
check the link for Relationship , this gives incorrect record set may be due to the reason for one row of question target table i have many rows in answersnew table
http://tinypic.com/r/206iipv/8
jgakenhe 29-Aug-15 16:09pm    
It looks correct. The only thing that looks a bit off is the QuestionTarget. If a user has 1 to Many QuestionTargets and a QuestionTarget has 1 to Many Questions, and each Question has 1 to Many Answers, then it is correct.

You'll know if there is a problem when you start testing it. If you can't get the data out accurately through a query, then you'll need to make revisions.
Malikdanish 30-Aug-15 0:12am    
There is one questionTarget and for this questionTarget there are many Answers that is the rule so
see the picture
calculate the sum of QuestionTarget column from QuestionTarget table and calculate the sum of QTotal Column from the AnswersNew table see the picture for tables data
link of picture is http://tinypic.com/r/2cxys2f/8
Jörgen Andersson 8-Sep-15 1:53am    
I'm wondering over the connection between District and village, they are both usually geographical entities and should normally have a direct relation, and not via a user.

1 solution

Database design completely depends on your understanding of the requirements. We can't say something is right or wrong.

Because one thing can be designed using one table and that thing again can be designed using 100 tables. Depends exactly on your perception and requirements.

I thing you have designed it well. But I think the two tables can be combined. The only thing which is different is the target value and achieved value, which can be two columns in one table. See if you can do that.
 
Share this answer
 
Comments
Malikdanish 31-Aug-15 0:59am    
I already told you that against one target i may have 100 replies so how can i combine these two into a single table , secondly if i combine them into a single table the if I have 100 achieved values against one target value then i will duplicate this target values 100 times so data redundancy get lost.

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