huge problems with database deisgn for survey

  • Thread starter Desperate in Ontario
  • Start date
D

Desperate in Ontario

I am very inexperienced at database design and am saving huge problems.

I am trying to construct a Db in Access 2000. The data is based on
information from client files and questions, as well as dates of the
questions. The time scale from an initial event is important and will be the
subject of a query.

My original design was wrong in that it had a field for each question,
however this did make for a relatively easy build.

I am now trying to do the right thing, but I cannot understand how I get the
responses into into the database. I have

tblCase
CaseID autoPK

tblQuestionsAsked
QuestionsAskedID PK auto
Description

tblResults
ResultsID PK auto
QuestionsAskedID FK
Results

tblAnswerType
ATID PK
RID FK
AnswerVelue (number, 1, 2 0)
Text (yes,no, unknown)

I have looked at AYS but found it too confusing, I don't have enough
experience to know what I need from this.

I'm sorry to be so basic, I hope that someone can provide me with a simple
solution.
 
D

Duane Hookom

I believe your tblResults needs a foreign key relating back to tblCase.
Otherwise, how do you track which case record corresponds with the results?

You might want to take a look at the survey results entry screen. There is a
command button that runs an append query with a source of the
tblQuestionsAsked and a target of tblResults. The CaseID is pulled from the
main form.
 
D

Desperate in Ontario

Thanks for replying Duane,

I have added CaseID and I think I have made a command button using the
append data query. I cant try it as ai havent entered any data yet. I need a
form now.

How do I make a form to enter the results? Do i enter text boxes and then
options boxes to hold the answers?

I tried making a table of possible answers, but my yes.no.unknown answers
will need a number input for analysis.

Thank you for your time.
 
D

Duane Hookom

If your question are associated/related to a Case then you would have a main
form based on tblCase and a subform based on tblResults. The link
master/child would be set to the CaseID field. A command button on the main
form would run the append query.

Is your Results field numeric or text? What do you want to store? You can
always group by Results to count the number of like answers.
 
D

Desperate in Ontario

I am at home now so will try that when I am back at work at the end of the
week.
My results will be a mixture of scores, yes/no/unknown, age ranges,
education ranges and dates.
I had problems grouping by results before but that may be because of my
table structure which was more spreadsheet than access tall and thin.

Thank you again
 
D

Desperate in Ontario

Hi,
I have set up the forms and am trying to add the boxes for the results.
Should I be looking at list boxes or combo boxes?

My questions are listed in rows as text in tblQuestionsAsked, not as fields,
so how do I enter each question into the form and have a box for the results?

Should my results table have rows for each answer?

Would it be so terrible if I went back to having a field for each question??
 
J

John W. Vinson

Hi,
I have set up the forms and am trying to add the boxes for the results.
Should I be looking at list boxes or combo boxes?

Whichever is more suitable for your user interface. They both let you edit
fields; they look different (the listbox always displays multiple rows, the
combo drops down thereby saving screen space, and they handle keystrokes
differently). Both work.
My questions are listed in rows as text in tblQuestionsAsked, not as fields,
so how do I enter each question into the form and have a box for the results?

You don't enter questions INTO THE FORM. You *use* the form (or a Questions
form) to enter questions INTO THE TABLE. The form for entering answers
displays the data stored in the table.
Should my results table have rows for each answer?
Yes.

Would it be so terrible if I went back to having a field for each question??

Yes.

In the nature of surveys, questions change over time. If you have a field per
question, then when you add or change a question, you must restructure your
Table, restructure all Queries involving the table, redesign your Form,
redesign your Reports... a monstrous amount of work. In a normalized design
when you change or add a question you open the Questions form, change or add
the question... and you're DONE.

If you'll only ever do *one* survey, and never change it, and discard the
database when you're done, then maybe you can do it that way... but it might
be simpler to do so in Excel, since you're essentially building a spreadsheet
rather than a database.
 
D

Duane Hookom

I agree with John (as usual). One of the nice benefits of creating a
normalized survey application is you don't have to create lots of fields,
lookup tables, controls, etc.

When I began working on the At Your Survey solution, I was taking over an
application started by someone else. I very soon got tired of adding fields,
adding tables, adding controls, adding code, adding logic,...

While the normalized structure requires that your survey conforms with some
basic constraints, it is quite flexible. It could be modified to provide a
different user interface but the table structure should remain mostly the
same.
 
D

Desperate in Ontario

Thanks for the replies

Excel won't provide the answers though as it won't porvide reports in the
same way as Access does. I am probably wrong there but my experience of Excel
doesnt give me means of saying that those Cases who live in post code xxx,
who are aged xx, answered, yes, scored 20 etc.

My basic problem with this is that now I have the tables. I haven't been
able to construct a form that has all the questions (i realize that I can get
round this by using text boxes,) and a method of entering the answers so that
the results table is populated.

The two local "Experts" suggest that I use a field per question. Even some
online examples use this method, So I am very confused. I really want to do
this the right way tho, I don't want to build in problems for later,

I have made a query that is ResultsToQuestionText. I thought this might help
with the forms as a subform to case. i still have the problem of how to get a
box for each response and show which question.

I have tried substituting my questions into AYS but that was a mess too!

thank you
 
D

Duane Hookom

To get the results, you need to run an append query as per two previous
replies in this thread. The questions are then displayed in a continuous
subform.

I'm not sure if it would help understand but if you look at the Northwind
Orders and OrderDetails tables. Let's make a couple assumptions:
- an order record is like a case record
- an order detail is like a result
- a product is like a question (let's assume there are only 7 products
available or 7 questions)
- we then have to assume that everyone is going to buy all seven products
(answer all 7 questions)

== northwind ==
You would create an append query based on your product table and the one
Order from your order table. This would create 7 order detail records waiting
for you to enter quantities to purchase.

== survey ==
You would create an append query based on your questions table and the one
Case from your tblCase table. This would create 7 tblResults records waiting
for you to enter an answer value.

You would never create a single field for each product to be ordered. For
instance you wouldn't have an Orders table with fields like: Bread, Milk,
Eggs, Apples, ... As I stated earlier, if your questions are fairly generic,
you need to normalize.

Maybe you should just allow the two local "Experts" create all the fields,
controls, reports, queries, ... required with the multiple field solution ;-)
 
D

Desperate in Ontario

Sorry, I did say that I had done the append query. Obviously wrongly but I
wasnt ignoring your advice.

I realise that its hard work talking to a novice but I am trying to do this
right rather than go for the easier option.
 
D

Duane Hookom

Is your "ResultsToQuestionText" the append query? Could you share the SQL
view of the append query?

Do you have a form based on the Case table with a subform based on the
results table? Did you set up the Link Master/Child properties?
 
D

Desperate in Ontario

Hi
I am back at my desk and can't seem to find my last post or the reply to it
that arrived on Friday evening. The email link no longer works. I wasn't able
to act on the suggestions as I don't have access to the DB at home. Duane
you suggested i look at Northwind and compare, plus another comment re the
append query. I am going to look at Northwind and redo the query but would
be very grateful if you could repost your comments.

thank you again.
 
D

Desperate in Ontario

This is the SQL of the append query

INSERT INTO tblResults ( CaseID, Results )
SELECT tblCase.CaseID, tblResults.Results
FROM tblQuestionsAsked INNER JOIN (tblCase INNER JOIN tblResults ON
tblCase.CaseID = tblResults.CaseID) ON tblQuestionsAsked.QuestionsID =
tblResults.QuestionsID
ORDER BY tblCase.CaseID;

I have the master child fields set to CASE ID

Thanks
 
D

Duane Hookom

Your append query needs to append the CaseID and QuestionsAskedID values to
tblResults. The CaseID should come from the current form where the CaseID is
bount to a text box named txtCaseID. Change your form and control names in
the below SQL. Make sure you have a unique indes in tblResults based on
CaseID and QuestionsAskedID.

INSERT INTO tblResults ( CaseID, QuestionsAskedID)
SELECT Forms!frmYourMainForm!txtCaseID, QuestionsAskedID
FROM tblQuestionsAsked ;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top