A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

set up tables relationship



 
 
Thread Tools Display Modes
  #1  
Old August 2nd, 2009, 04:49 AM posted to microsoft.public.access.tablesdbdesign
ALEX
external usenet poster
 
Posts: 731
Default set up tables relationship

Hello everybody,

I created a survey questions table with the following fields:

SurvID
QstnID
QstnText
QstnCtrlType
AnswCtrlType
QstnType
Grp1ID
Grp2ID
Grp3ID
PageID
PageType
OrderByID

The Group fields imply that each question can belong to a max three
independent groups.

So, I’ve created another table for Groups with the following fields:
SurvID
QstnID
Grp1ID
Grp1Name
Grp1Vis
Grp2ID
Grp2Name
Grp2Vis
Grp3ID
Grp3Name
Grp3Vis

QstnID is identity incremental field so it’s unique without having SurveyID
to be primary key as well. But we need SurveyID for making tables join
connections.
The number of questions and the questions themselves are different per survey.
The questions’ grouping per survey can be different as well. So, the
separate table with only groups without SurveyID won’t work.
My question is how to link those two tables.
Will it work:
Questions.SurveyID - Groups.SurveyID
Questions.Grp1ID - Groups.Grp1ID
Questions.Grp2ID - Groups.Grp2ID
Questions.Grp3ID - Groups.Grp3ID
Or it’s needed to be three instances of the table Groups to be linked to
the Questions table: Groups as A, Groups As B, and Groups As C:
Questions.SurveyID - A.SurveyID
Questions.Grp1ID - A.Grp1ID
Questions.SurveyID - A.SurveyID
Questions.Grp2ID - B.Grp2ID
Questions.SurveyID - A.SurveyID
Questions.Grp3ID - C.Grp3ID
Or it should be something else?
What would be the better practice here?

Thanks


  #2  
Old August 2nd, 2009, 08:51 AM posted to microsoft.public.access.tablesdbdesign
biganthony via AccessMonster.com
external usenet poster
 
Posts: 49
Default set up tables relationship

Alex,

Check out the link I provide below. Duane Hookom is the creator. This is the
description from the site: "At Your Survey (ATS) is a full featured
application that allows users to create their own surveys by designing the
questions and providing a lookup of possible responses. ATS uses a fairly
normalized table structure so the same tables, forms, code, queries, and
reports can be used for any number of surveys. There is a brief manual to
help you get started as well as a sample survey with data."

Link is: http://www.rogersaccesslibrary.com/f...osts.asp?TID=3

Reagrds,
Anthony

Alex wrote:
Hello everybody,

I created a survey questions table with the following fields:

SurvID
QstnID
QstnText
QstnCtrlType
AnswCtrlType
QstnType
Grp1ID
Grp2ID
Grp3ID
PageID
PageType
OrderByID

The Group fields imply that each question can belong to a max three
independent groups.

So, I’ve created another table for Groups with the following fields:
SurvID
QstnID
Grp1ID
Grp1Name
Grp1Vis
Grp2ID
Grp2Name
Grp2Vis
Grp3ID
Grp3Name
Grp3Vis

QstnID is identity incremental field so it’s unique without having SurveyID
to be primary key as well. But we need SurveyID for making tables join
connections.
The number of questions and the questions themselves are different per survey.
The questions’ grouping per survey can be different as well. So, the
separate table with only groups without SurveyID won’t work.
My question is how to link those two tables.
Will it work:
Questions.SurveyID - Groups.SurveyID
Questions.Grp1ID - Groups.Grp1ID
Questions.Grp2ID - Groups.Grp2ID
Questions.Grp3ID - Groups.Grp3ID
Or it’s needed to be three instances of the table Groups to be linked to
the Questions table: Groups as A, Groups As B, and Groups As C:
Questions.SurveyID - A.SurveyID
Questions.Grp1ID - A.Grp1ID
Questions.SurveyID - A.SurveyID
Questions.Grp2ID - B.Grp2ID
Questions.SurveyID - A.SurveyID
Questions.Grp3ID - C.Grp3ID
Or it should be something else?
What would be the better practice here?

Thanks


--
Message posted via http://www.accessmonster.com

  #3  
Old August 2nd, 2009, 07:08 PM posted to microsoft.public.access.tablesdbdesign
ALEX
external usenet poster
 
Posts: 731
Default set up tables relationship

Thank you for your reply, biganthony.

I was expecting I would be referred to that site. It’s a nice learning tool.
I’m aware of that survey. But, I’ve been requested to use some different
approach for grouping when a one question could belong to several independent
groups.

Please, let’s move away from the survey things as I could name all stuff
differently to not focus whether it’s survey or not.

I’m asking about tables relationships. If it’s appropriate to set up
relationships as I outlined in my question.

Thanks


"biganthony via AccessMonster.com" wrote:

Alex,

Check out the link I provide below. Duane Hookom is the creator. This is the
description from the site: "At Your Survey (ATS) is a full featured
application that allows users to create their own surveys by designing the
questions and providing a lookup of possible responses. ATS uses a fairly
normalized table structure so the same tables, forms, code, queries, and
reports can be used for any number of surveys. There is a brief manual to
help you get started as well as a sample survey with data."

Link is: http://www.rogersaccesslibrary.com/f...osts.asp?TID=3

Reagrds,
Anthony

Alex wrote:
Hello everybody,

I created a survey questions table with the following fields:

SurvID
QstnID
QstnText
QstnCtrlType
AnswCtrlType
QstnType
Grp1ID
Grp2ID
Grp3ID
PageID
PageType
OrderByID

The Group fields imply that each question can belong to a max three
independent groups.

So, I’ve created another table for Groups with the following fields:
SurvID
QstnID
Grp1ID
Grp1Name
Grp1Vis
Grp2ID
Grp2Name
Grp2Vis
Grp3ID
Grp3Name
Grp3Vis

QstnID is identity incremental field so it’s unique without having SurveyID
to be primary key as well. But we need SurveyID for making tables join
connections.
The number of questions and the questions themselves are different per survey.
The questions’ grouping per survey can be different as well. So, the
separate table with only groups without SurveyID won’t work.
My question is how to link those two tables.
Will it work:
Questions.SurveyID - Groups.SurveyID
Questions.Grp1ID - Groups.Grp1ID
Questions.Grp2ID - Groups.Grp2ID
Questions.Grp3ID - Groups.Grp3ID
Or it’s needed to be three instances of the table Groups to be linked to
the Questions table: Groups as A, Groups As B, and Groups As C:
Questions.SurveyID - A.SurveyID
Questions.Grp1ID - A.Grp1ID
Questions.SurveyID - A.SurveyID
Questions.Grp2ID - B.Grp2ID
Questions.SurveyID - A.SurveyID
Questions.Grp3ID - C.Grp3ID
Or it should be something else?
What would be the better practice here?

Thanks


--
Message posted via http://www.accessmonster.com


  #4  
Old August 2nd, 2009, 07:43 PM posted to microsoft.public.access.tablesdbdesign
Steve[_77_]
external usenet poster
 
Posts: 1,017
Default set up tables relationship

Your tables are not correct! Consider this ...

TblSurvey
SurveyID
SurveyDate
etc

TblGroup
GroupID
GroupName
GroupVis

TblQuestionType
QuestionTypeID
QuestionType

TblQuestion
QuestionID
SurveyID
GroupID
QuestionTypeID
QuestionText

TblAnswer
AnswerID
QuestionID
Identifies who took the survey. Could be EmployeeID,
CustomerID, etc.
Answer

I don't know what PageID, PageType and OrderByID are for so there not
included.

It is very apparent you are struggling with this database. I can help you! I
provide help with Access applications for a small fee. Contact me if you
would like my help with your database.

Steve

"Alex" wrote in message
...
Hello everybody,

I created a survey questions table with the following fields:

SurvID
QstnID
QstnText
QstnCtrlType
AnswCtrlType
QstnType
Grp1ID
Grp2ID
Grp3ID
PageID
PageType
OrderByID

The Group fields imply that each question can belong to a max three
independent groups.

So, I've created another table for Groups with the following fields:
SurvID
QstnID
Grp1ID
Grp1Name
Grp1Vis
Grp2ID
Grp2Name
Grp2Vis
Grp3ID
Grp3Name
Grp3Vis

QstnID is identity incremental field so it's unique without having
SurveyID
to be primary key as well. But we need SurveyID for making tables join
connections.
The number of questions and the questions themselves are different per
survey.
The questions' grouping per survey can be different as well. So, the
separate table with only groups without SurveyID won't work.
My question is how to link those two tables.
Will it work:
Questions.SurveyID - Groups.SurveyID
Questions.Grp1ID - Groups.Grp1ID
Questions.Grp2ID - Groups.Grp2ID
Questions.Grp3ID - Groups.Grp3ID
Or it's needed to be three instances of the table Groups to be linked to
the Questions table: Groups as A, Groups As B, and Groups As C:
Questions.SurveyID - A.SurveyID
Questions.Grp1ID - A.Grp1ID
Questions.SurveyID - A.SurveyID
Questions.Grp2ID - B.Grp2ID
Questions.SurveyID - A.SurveyID
Questions.Grp3ID - C.Grp3ID
Or it should be something else?
What would be the better practice here?

Thanks




  #5  
Old August 2nd, 2009, 07:52 PM posted to microsoft.public.access.tablesdbdesign
John... Visio MVP
external usenet poster
 
Posts: 900
Default set up tables relationship

"Steve" wrote in message
...
Your tables are not correct! Consider this ...


It is very apparent you are struggling with this database. I can help you!
I provide help with Access applications for a small fee. Contact me if you
would like my help with your database.

Steve



WARNING! Stevie is our local troll who pretends to be competent

These newsgroups are provided by Microsoft for FREE peer to peer support.
There are many highly qualified individuals who gladly help for free. Stevie
is not one of them, but he is the only one who just does not get the idea of
"FREE" support. He offers questionable results at unreasonable prices. If he
was any good, the "thousands" of people he claims to have helped would be
flooding him with work, but there appears to be a continuous drought and he
needs to constantly grovel for work.

A few gems gleaned from the Word New User newsgroup over the Christmas
holidays to show Stevie's "expertise" in Word.


Dec 17, 2008 7:47 pm

Word 2007 ..........
In older versions of Word you could highlght some text then go to Format -
Change Case and change the case of the hoghloghted text. Is this still
available in Word 2007? Where?
Thanks! Steve


Dec 22, 2008 8:22 pm

I am designing a series of paystubs for a client. I start in landscape and
draw a table then add columns and rows to setup labels and their
corresponding value. This all works fine. After a landscape version is
completed, I next need to design a portrait version. Rather than strating
from scratch, I'd like to be able to cut and paste from the landscape
version and design the portrait version.
Steve


Dec 24, 2008, 1:12 PM

How do you protect the document for filling in forms?
Steve


One of my favourites:
Dec 30, 2008 8:07 PM - a reply to stevie
(The original poster asked how to sort a list and stevie offered to create
the OP an Access database)

Steve wrote:
Yes, you are right but a database is the correct tool to use not a
spreadsheet.



Not at all. If it's just a simple list then a spreadsheet is perfectly
adequate...




John... Visio MVP

  #6  
Old August 2nd, 2009, 08:10 PM posted to microsoft.public.access.tablesdbdesign
ALEX
external usenet poster
 
Posts: 731
Default set up tables relationship

Thank you very much Steve. I have all those tables with almost the same
structure you outlined.

From all those tables I’m talking only about tblQuestions and tblGroups.
According to requirements a one question can belong to a one, two, or I put
as an extreme case even to three independent groups (they’re not subgroups).
It can be as follows:

tblQuestions:
QsnID SurvID Grp1ID Grp2ID Grp3ID
1 10 2 1 1
2 10 3 3 2
3 10 3 4 3
.....
25 11 2 1 3

tblGroups
SurvID Grp1ID Grp1Name Grp2ID Grp2Name Grp3ID Grp3Name
10 1 Leadership 1 Encouragment 1 SomeName
10 2 SomeName 2 SomeName 2 SomeName
....
11 1 SomeName 1 SomeName 1 SomeName
11 2 SomeName 2 SomeName 2 SomeName
....


"Steve" wrote:

Your tables are not correct! Consider this ...

TblSurvey
SurveyID
SurveyDate
etc

TblGroup
GroupID
GroupName
GroupVis

TblQuestionType
QuestionTypeID
QuestionType

TblQuestion
QuestionID
SurveyID
GroupID
QuestionTypeID
QuestionText

TblAnswer
AnswerID
QuestionID
Identifies who took the survey. Could be EmployeeID,
CustomerID, etc.
Answer

I don't know what PageID, PageType and OrderByID are for so there not
included.

It is very apparent you are struggling with this database. I can help you! I
provide help with Access applications for a small fee. Contact me if you
would like my help with your database.

Steve

"Alex" wrote in message
...
Hello everybody,

I created a survey questions table with the following fields:

SurvID
QstnID
QstnText
QstnCtrlType
AnswCtrlType
QstnType
Grp1ID
Grp2ID
Grp3ID
PageID
PageType
OrderByID

The Group fields imply that each question can belong to a max three
independent groups.

So, I've created another table for Groups with the following fields:
SurvID
QstnID
Grp1ID
Grp1Name
Grp1Vis
Grp2ID
Grp2Name
Grp2Vis
Grp3ID
Grp3Name
Grp3Vis

QstnID is identity incremental field so it's unique without having
SurveyID
to be primary key as well. But we need SurveyID for making tables join
connections.
The number of questions and the questions themselves are different per
survey.
The questions' grouping per survey can be different as well. So, the
separate table with only groups without SurveyID won't work.
My question is how to link those two tables.
Will it work:
Questions.SurveyID - Groups.SurveyID
Questions.Grp1ID - Groups.Grp1ID
Questions.Grp2ID - Groups.Grp2ID
Questions.Grp3ID - Groups.Grp3ID
Or it's needed to be three instances of the table Groups to be linked to
the Questions table: Groups as A, Groups As B, and Groups As C:
Questions.SurveyID - A.SurveyID
Questions.Grp1ID - A.Grp1ID
Questions.SurveyID - A.SurveyID
Questions.Grp2ID - B.Grp2ID
Questions.SurveyID - A.SurveyID
Questions.Grp3ID - C.Grp3ID
Or it should be something else?
What would be the better practice here?

Thanks





  #7  
Old August 2nd, 2009, 08:28 PM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default set up tables relationship

On Sat, 1 Aug 2009 20:49:01 -0700, Alex
wrote:

Hello everybody,

I created a survey questions table with the following fields:

SurvID
QstnID
QstnText
QstnCtrlType
AnswCtrlType
QstnType
Grp1ID
Grp2ID
Grp3ID
PageID
PageType
OrderByID

The Group fields imply that each question can belong to a max three
independent groups.


If each Question can belong to zero, one or more groups, and each Group may
apply to zero, one, or more Questions... *you have a many to many
relationship*.

In Access (or any relational database) the proper way to model this is with
three tables:

Questions
SurvID
QstnID
etc

Groups
GrpID
Group
other information about the group as a whole

GroupMembership
SurvID
QstnID joint links to Questions
GrpID which group is this question in

If a question is in three groups you would have three RECORDS in
GroupMembership.

So, Ive created another table for Groups with the following fields:
SurvID
QstnID
Grp1ID
Grp1Name
Grp1Vis
Grp2ID
Grp2Name
Grp2Vis
Grp3ID
Grp3Name
Grp3Vis


So if there are 52 questions in Grp1 you would store Grp1Name redundanly 52
times, and correct the change of spelling 52 times if you detect an error...!?
OUCH! That's "spreadsheet thinking" and is not good design.

--

John W. Vinson [MVP]
  #8  
Old August 2nd, 2009, 08:58 PM posted to microsoft.public.access.tablesdbdesign
ALEX
external usenet poster
 
Posts: 731
Default set up tables relationship

Thanks, John.

As I said before the same question can belong to different grouping
methodology.
E.g.
SurvID Qstns: Grp1 Grp2 Grp3
10 Question1 External Customers Engagement Leadership
10 Question2 Internal Customers Satisfaction Management
.....
11 Can be different

The customer requirements are to have it as this.

How would you suggest to approach it?

Thanks


"John W. Vinson" wrote:

On Sat, 1 Aug 2009 20:49:01 -0700, Alex
wrote:

Hello everybody,

I created a survey questions table with the following fields:

SurvID
QstnID
QstnText
QstnCtrlType
AnswCtrlType
QstnType
Grp1ID
Grp2ID
Grp3ID
PageID
PageType
OrderByID

The Group fields imply that each question can belong to a max three
independent groups.


If each Question can belong to zero, one or more groups, and each Group may
apply to zero, one, or more Questions... *you have a many to many
relationship*.

In Access (or any relational database) the proper way to model this is with
three tables:

Questions
SurvID
QstnID
etc

Groups
GrpID
Group
other information about the group as a whole

GroupMembership
SurvID
QstnID joint links to Questions
GrpID which group is this question in

If a question is in three groups you would have three RECORDS in
GroupMembership.

So, I’ve created another table for Groups with the following fields:
SurvID
QstnID
Grp1ID
Grp1Name
Grp1Vis
Grp2ID
Grp2Name
Grp2Vis
Grp3ID
Grp3Name
Grp3Vis


So if there are 52 questions in Grp1 you would store Grp1Name redundanly 52
times, and correct the change of spelling 52 times if you detect an error...!?
OUCH! That's "spreadsheet thinking" and is not good design.

--

John W. Vinson [MVP]

  #9  
Old August 2nd, 2009, 09:58 PM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default set up tables relationship

On Sun, 2 Aug 2009 12:58:01 -0700, Alex
wrote:

Thanks, John.

As I said before the same question can belong to different grouping
methodology.
E.g.
SurvID Qstns: Grp1 Grp2 Grp3
10 Question1 External Customers Engagement Leadership
10 Question2 Internal Customers Satisfaction Management
....
11 Can be different

The customer requirements are to have it as this.


Don't confuse data PRESENTATION with data STORAGE.

You still have a many to many relationship. Storing it incorrectly will not
help you.

How would you suggest to approach it?


Just as I suggested in my prior post. You can use a multiselect listbox or a
subform to display it and edit it, or (with a little bit of code) denormalize
for display purposes. Or, if you are willing to pay the price (far more
complex queries searching three fields instead of one, inability to sort by
group, etc.) you can use your three field denormalized table structure. It's
your call!
--

John W. Vinson [MVP]
  #10  
Old August 2nd, 2009, 10:47 PM posted to microsoft.public.access.tablesdbdesign
ALEX
external usenet poster
 
Posts: 731
Default set up tables relationship

Thanks again, John.

You’re saying “Just as I suggested in my prior post.” I tried to find that
suggestion. Could you please point me out there as I could see the only post
about Stevie?

Yes, I understand that presentation can be different from a db. The previous
example was for demonstrating a logic behind.

How about if we create a third table where we’ll have repeating questions
with groups with having a primary key by those two fields?

E.g.,
SurvID QsntID GrpID
10 1 1
10 1 2
....
10 2 3
10 2 7

Then a tblGroups table could have the only SurID and GrpID, GrpName fields
without QsntID.

Please, advise



"John W. Vinson" wrote:

On Sun, 2 Aug 2009 12:58:01 -0700, Alex
wrote:

Thanks, John.

As I said before the same question can belong to different grouping
methodology.
E.g.
SurvID Qstns: Grp1 Grp2 Grp3
10 Question1 External Customers Engagement Leadership
10 Question2 Internal Customers Satisfaction Management
....
11 Can be different

The customer requirements are to have it as this.


Don't confuse data PRESENTATION with data STORAGE.

You still have a many to many relationship. Storing it incorrectly will not
help you.

How would you suggest to approach it?


Just as I suggested in my prior post. You can use a multiselect listbox or a
subform to display it and edit it, or (with a little bit of code) denormalize
for display purposes. Or, if you are willing to pay the price (far more
complex queries searching three fields instead of one, inability to sort by
group, etc.) you can use your three field denormalized table structure. It's
your call!
--

John W. Vinson [MVP]

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:35 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.