473,387 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Tables and Relationships - how would you do this?

I'm putting together a PC Workstation Assessment application, the idea being
dead simple - there are a number of predetermined questions for the user to
answer either "yes" or "no" to. My first stab, also dead simple, is just a
flat table with the user's details and a Y/N field for each question to
contain their responses. The questions themselves are not stored but just
displayed on a form next to the relevant check box for their response.

It works but of course I can't report against failing items because the
questions aren't stored. This leaves me wondering what the best table
structure might be to store the actual questions (this is always the hardest
part of a design for me). Here's my first idea:

tblUsers:
EmployeeNumber (PK)
Name
Location
.... etc

tblAnswers:
EmployeeNumber (FK)
QuestionNo (FK)
Response

tblQuestions:
QuestionNo (PK)
QuestionText

I think it's obvious where the joins are but of course I'd have to code the
app to populate tblAnswers with a set of question numbers for each user ...
wouldn't I? I think I need some fresh ideas having stared at this for quite
a while now, any comment and suggestions greatly appreciated.

Regards,
Keith.
Jan 16 '07 #1
5 1135
*Please* don't use the check boxes, Keith. :-(
As you realized, they are not queryable (i.e. unnormalized.)

The tables you have a good, but here's some other possibilities to consider:

a) Is it possible that employees may be asked to complete this survey
periodically (annually? on entry and exit?) If so, you need another
tblSurveyTaken table between tblUsers and tblAnswers. The EmployeeNumber
moves into this table, so fields are:
SurveyTakenID (PK)
EmployeeNumber (FK)
SurveyDate (Date/Time)

Now you have a main form for selecting the employee who completed the
survey, with a subform for their responses. In the AfterInsert event of this
form, you can execute an Append query statement to append all the questions
in the survey to tblAnswers, using the SurveyTakenID as the foreign key. Now
completing the survey is just a matter of running down the continuous
form/datasheet to give the answer to each question.

b) Could there be other questionnaires developed over time?
If so that might require a Survey table that defines the questions in this
questionnaire.

c) Any chance there will ever be a question that needs more than a yes/no?
Multiple choice? "Other" that requires a comment? If so, there's a sample
database by Duane Hookom here:
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='At%20Your%20Survey%2 02000'

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Keith Wilby" <he**@there.comwrote in message
news:45**********@glkas0286.greenlnk.net...
I'm putting together a PC Workstation Assessment application, the idea
being dead simple - there are a number of predetermined questions for the
user to answer either "yes" or "no" to. My first stab, also dead simple,
is just a flat table with the user's details and a Y/N field for each
question to contain their responses. The questions themselves are not
stored but just displayed on a form next to the relevant check box for
their response.

It works but of course I can't report against failing items because the
questions aren't stored. This leaves me wondering what the best table
structure might be to store the actual questions (this is always the
hardest part of a design for me). Here's my first idea:

tblUsers:
EmployeeNumber (PK)
Name
Location
... etc

tblAnswers:
EmployeeNumber (FK)
QuestionNo (FK)
Response

tblQuestions:
QuestionNo (PK)
QuestionText

I think it's obvious where the joins are but of course I'd have to code
the app to populate tblAnswers with a set of question numbers for each
user ... wouldn't I? I think I need some fresh ideas having stared at
this for quite a while now, any comment and suggestions greatly
appreciated.

Regards,
Keith.
Jan 16 '07 #2
"Allen Browne" <Al*********@SeeSig.Invalidwrote in message
news:45***********************@per-qv1-newsreader-01.iinet.net.au...
*Please* don't use the check boxes, Keith. :-(
As you realized, they are not queryable (i.e. unnormalized.)

The tables you have a good, but here's some other possibilities to
consider:

a) Is it possible that employees may be asked to complete this survey
periodically (annually? on entry and exit?) If so, you need another
tblSurveyTaken table between tblUsers and tblAnswers. The EmployeeNumber
moves into this table, so fields are:
SurveyTakenID (PK)
EmployeeNumber (FK)
SurveyDate (Date/Time)

Now you have a main form for selecting the employee who completed the
survey, with a subform for their responses. In the AfterInsert event of
this form, you can execute an Append query statement to append all the
questions in the survey to tblAnswers, using the SurveyTakenID as the
foreign key. Now completing the survey is just a matter of running down
the continuous form/datasheet to give the answer to each question.

b) Could there be other questionnaires developed over time?
If so that might require a Survey table that defines the questions in this
questionnaire.

c) Any chance there will ever be a question that needs more than a yes/no?
Multiple choice? "Other" that requires a comment? If so, there's a sample
database by Duane Hookom here:

http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='At%20Your%20Survey%2 02000'
Many thanks Allen, I'll give your suggestions a go right now. I'm actually
using combo boxes for the responses but I just wanted to keep my question as
simple as possible, mainly for my benefit :-)

Regards,
Keith.
Jan 16 '07 #3
"Allen Browne" <Al*********@SeeSig.Invalidwrote in message
news:45***********************@per-qv1-newsreader-01.iinet.net.au...
>
a) Is it possible that employees may be asked to complete this survey
periodically (annually? on entry and exit?) If so, you need another
tblSurveyTaken table between tblUsers and tblAnswers. The EmployeeNumber
moves into this table, so fields are:
SurveyTakenID (PK)
EmployeeNumber (FK)
SurveyDate (Date/Time)
Having a bit of a no-brainer on this Allen, how did you see this new table
being populated?

Thanks.

Keith.
Jan 16 '07 #4
Main form:
Employee: [ v]
Survey Date: [ ]

Subform has these columns visible:
[Question Num] [Question Text] [Answer v]

To start a survey, user select the employee who answered these questions in
the main form. Survey Date defaults to Today.

In the AfterInsert event procedure of the main form:
Dim strSql As String
strSql = "INSERT INTO ...
dbEngine(0)(0).Execute strSql, dbFailOnError

To get the SQL statement, mock up a query based on your Questions table.
Change it to an Append query (Append on Query menu.)
Type this into a fresh column in query design:
SurveyTakenID: 99
Switch to SQL View (View menu.)
There's the SQL statement you need.
Just remove the 99, and concatenate the value of the SurveyTakenID from the
main form into the string.

Is that what you were asking?

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Allen Browne" <Al*********@SeeSig.Invalidwrote in message
news:45***********************@per-qv1-newsreader-01.iinet.net.au...
*Please* don't use the check boxes, Keith. :-(
As you realized, they are not queryable (i.e. unnormalized.)

The tables you have a good, but here's some other possibilities to
consider:

a) Is it possible that employees may be asked to complete this survey
periodically (annually? on entry and exit?) If so, you need another
tblSurveyTaken table between tblUsers and tblAnswers. The EmployeeNumber
moves into this table, so fields are:
SurveyTakenID (PK)
EmployeeNumber (FK)
SurveyDate (Date/Time)

Now you have a main form for selecting the employee who completed the
survey, with a subform for their responses. In the AfterInsert event of
this form, you can execute an Append query statement to append all the
questions in the survey to tblAnswers, using the SurveyTakenID as the
foreign key. Now completing the survey is just a matter of running down
the continuous form/datasheet to give the answer to each question.

b) Could there be other questionnaires developed over time?
If so that might require a Survey table that defines the questions in this
questionnaire.

c) Any chance there will ever be a question that needs more than a yes/no?
Multiple choice? "Other" that requires a comment? If so, there's a sample
database by Duane Hookom here:

http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='At%20Your%20Survey%2 02000'

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Keith Wilby" <he**@there.comwrote in message
news:45**********@glkas0286.greenlnk.net...
>I'm putting together a PC Workstation Assessment application, the idea
being dead simple - there are a number of predetermined questions for the
user to answer either "yes" or "no" to. My first stab, also dead simple,
is just a flat table with the user's details and a Y/N field for each
question to contain their responses. The questions themselves are not
stored but just displayed on a form next to the relevant check box for
their response.

It works but of course I can't report against failing items because the
questions aren't stored. This leaves me wondering what the best table
structure might be to store the actual questions (this is always the
hardest part of a design for me). Here's my first idea:

tblUsers:
EmployeeNumber (PK)
Name
Location
... etc

tblAnswers:
EmployeeNumber (FK)
QuestionNo (FK)
Response

tblQuestions:
QuestionNo (PK)
QuestionText

I think it's obvious where the joins are but of course I'd have to code
the app to populate tblAnswers with a set of question numbers for each
user ... wouldn't I? I think I need some fresh ideas having stared at
this for quite a while now, any comment and suggestions greatly
appreciated.

Regards,
Keith.
Jan 16 '07 #5
"Allen Browne" <Al*********@SeeSig.Invalidwrote in message
news:45***********************@per-qv1-newsreader-01.iinet.net.au...
>
Is that what you were asking?
Not quite but I think I've worked it out. The problem I had was populating
tblSurveyTaken when a new record (employee) is added via the main form (bear
in mind that the app will be empty and users will be entering their own
details in Data Entry mode). What I have now is two "insert into"
statements, one to insert the employee number/date into tblSurveyTaken and
the other to insert the questions into tblAnswers.

I can't pre-populate with a list of employees because this is a huge office
on a huge site and people are constantly moving around.

I think when it comes to users doing a second survey I'll need a "start new
survey" button but I'll cross that bridge when I come to it.

Many thanks again Allen.

Regards,
Keith.
Jan 16 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
by: Mariusz Jedrzejewski | last post by:
Hi, I'll be very grateful if somebody can explain me why my Opera 7.23 (runing under linux) doesn't show me inner tables. Using below code I can see only "inner table 1". There is no problem with...
3
by: Stephen | last post by:
It is possible to relate queries to tables, right? It seems logical but when I try to match my queries to any of the tables or even to each other it gives me a blank relationship. What could I...
5
by: Christoph Sticksel | last post by:
Hi, I'm having problems with attaching two tables stored in an SQL Server 2000 to an Access 97 database. It worked well for all other tables except those two. This is what I did: Choose the...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
1
by: jpr | last post by:
Hello, My database has 5 tables. WHen I add data to one table, it runs an append query that copies three records to other 4 tables. The main table is MASTER. The data I copy are: ID, SSN and...
1
by: cricket7 | last post by:
I think I figured out my tables and relationships. Tables: Table 1 tblTowedVehicles fldTowID fldReportDate fldReportTime fldlReportNumber
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
10
by: Richard | last post by:
Hi folks, thanks for taking the time to read this (and hopefully point our where I'm going wrong). The scenario: I have a local Access2007 database which links in several read only mySql...
2
by: Roger | last post by:
I've moved all my tables to sql server2005 and I've created the appropriate relationships now I create links to two such tables that have a relationship into ms- acess97 but when I add the two...
2
by: John Google | last post by:
Hi, Access 2002. I import tables from another database where I only copy the definition and not the data. I select the Import Relationships option on the import dialog. After I do the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.