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
  #11  
Old August 3rd, 2009, 12:03 AM 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 14:47:01 -0700, Alex
wrote:

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?


Sorry, here it is again.

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.


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.


Exactly!

--

John W. Vinson [MVP]
  #12  
Old August 3rd, 2009, 12:44 PM posted to microsoft.public.access.tablesdbdesign
BruceM[_4_]
external usenet poster
 
Posts: 558
Default set up tables relationship

The John who responded to warn about Steve's trolling tendencies is
different from John Vinson, in case that is not clear. No problem, just
mentioning it.

"Alex" wrote in message
...
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 03:25 AM.


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