ER model design for application with changing number of Questions - database

I need to create an ER model for an application that has some questions and answers, some questions have more than one answer. Currently, I created an ER model as follows.
Step 1: Create separate tables for Questions and Answers. Both these
tables have one column named TYPE which is question number (this is
to make sure that answers belong to a particular question only). There is no relationship between Questions and Answers table.
Step2: Create a table AnsweredQuestions where we can save the information
of questions answered. This table contains 10 columns with names
Answer1, Answer2,..., Answer10 to enter the answers for each
question. The number of questions/Questions/number of answers can
change in the future.
Is there any better way of designing this ER diagram?

Related

Database tables without relationships [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
Is it a good thing to create a database without relationships between the tables?
Is there any problem doing this? I have to design a database with historical events, sports events, environment data, etc. but can I put them in only one database?
In your case (as you said in a comment, it's for a history table), having no explicit relation between the parent table and the child table isn't a problem, as:
you won't need the unique constraints
you don't need to delete the orphans (if it's a history table, you want to maintain all the data, isn't it?)
And if the requests to this history table are made independently to the parent (e.g. any ORM used), make sure to have an index in the parent id column to be able to easily retrieve all the data linked to the parent.
Is a good thing create a database that its table hasn't relationships?
Sure if you don't have/need to make relations (Example Table Users and Table StarsInTheSky)
I have to design a database with some historical events, sports events, environment data and other stuff, but can I put them in only one database?
Probably you are talking about putting data in only one table; In my opinion You should think about Normalization:
Begin writing in a paper your unique table and the first row (Use your imagination).
Question yourself: "Am i repeating some Data in the rows written?"
EX:
Name - Surname - BirthDate - Address
Paul - Allen - 01/11/1957 - 21 Baker Street NY
Paul - Allen - 01/11/1957 - 66 Mullholland Drive LosAngeles
As you can see here U can Relate Personal Data with Address in two distinct table.
Question yourself: "Am i using irresponsible Columns (Fields)?
EX:
Name - Surname - BirthDate - Phone1 - Phone2
Paul - Allen - 01/11/1957 - 25412255 - null
What if another user has 3 or 4 phone numbers?
Relate User data with Phone table.
EDIT: Use a single Database or not? AFAIK programs need evolution and implementation in time, maybe one day you would need to make some relation so it's better if u use a single database per Program no matter how many tables u have and if they are related or not, keep the future work as simple as u can :)

Database diagram for multiple selection

I am having a logic problem while designing my database for a online survey. Part of my software consist in a survey generator where the user can create a question and add checkboxes and radiobuttons as options. So every question have an ID, however 1 question can have many options.
So far I have only work with software where the user can choose from determined range of options so I can collect the input and store it in the respective column of a table. However this is a different case for me because the columns are not there yet. I am trying to figure out a way to work around however I have been block for hours.
Assuming by options you mean Possible answers to a question
Question -Tracks the question of the survey
QID PK
Answers - Tracks the available answers for a survey item
AID PK
QuestionAnswers - Identifies which answers can be used on which questions
QUID PK
AID PK
Users - identifies a person taking a survey
UID PK
UserAnswers - Identifes the answers a user has selected for a survey and relates to both users and questionAnswers thus limiting which answers can be used for a question but each row allows the user to select 1-M answers as needed.
UID PK
QID PK
AID PK

Questionnaire to database design

I have read through a lot of the threads here and have found a good amount of useful input...but there are a couple of questions that remain unanswered.
I am storing questions & answers from a questionnaire in a database.
I have the tables:
Survey (surveyID)
Question (questionID, surveyID, questionType, Question)
Answer (answerID, userID, questionID, answer)
User (userID, username)
Question 1: multi-value questions...I would have a separate row for each value in the answer table....but have the same questionID and userID. But then how would you work the following:
-what are your coping strategies (multi-value)
-how frequently do you use each coping strategy?
i.e. a one-one relationship of coping strategy-frequency.
The solution above (i.e. one row per answer doesn't work because you need the relation between the specific coping strategy and the frequency).
A similar question is for the following:
have you been involved in conflicts over land-use rights?
with whom? (multi-value)
for what reasons?
(i.e. what were your reasons for conflict with the neighbours, what were your reasons for conflict with the authorities?) ...i.e. one to many on a multi-value attribute
Thank you in advance, I hope I have explained my query sufficiently well.
Becky

What is the best DB model for multiple answer questions

I need to store in a DB (MSSQL) multiple answer questions, and I am having trouble deciding what is the best way to do so. Should I store questions in one table, all answers in another and right answers in a 3rd table? Should they all be in the same table?
I would love to hear your ideas
thanks
Amit
Each concept, or entity, should be in its own table.
Questions in a Question table
Answers in an Answer Table with a QuestionID with a boolean field indicating its right or wrongness
(unless Answers can belong to more than one question?)
To me in your case best way is to hold question and answer in seperate tables. If your question has multiple answer and you maybe want to use one answer in a lot of question its the best way. You should also add table for which answer is good for specific question.
In this way you don't have data redundancy in database.
I agree with podiluska.
Each entity in a table.
If all or any of answer can be "typified" (i.e. not "free answer"), add a table for "typified answers" relating this one with table questions (to prevent someone to choose inapplicable "typified answers".
In table "user answers" relate it with table "questions" and if some record (or answer) contains a not "typified" you can mark it with a boolean column indicating "right" or "wrong".
I hope have helped you.

To improve a relation figure for a database

This question is based on my plan at the thread.
The following figure shows relations in my database
alt text http://files.getdropbox.com/u/175564/relation-figure.png
I have two "help-tables": questions-subjects and check-moderator. I use the former because one question can have many subjects, while the later because more than one moderator can check a question.
I left out the 1-to-1 number out at the arrows.
The dotted arrow between the tables question and moderator-check indicates that there may be questions which moderators do not check.
This is my first database-project so there are mistakes in the tables.
What would you improve in the table?
User, UserInfo, Moderator and Password are redundant tables that offer no benefit.
They only express 1-1 relationships with User, so there is no need to normalize them into seperate tables:
Make one table:
UserId
Name
Email
PasswordMd5
IsModerator
Reply to FlySwat's answer
I changed my table to the following based on your answer.
alt text http://files.getdropbox.com/u/175564/table-problem-3.png

Resources