473,772 Members | 3,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multi-table lookups

Hi. I'm trying to create a query that pulls information
from 3 seperate tables. Here's how I want it to work:

User is prompted for SSN

Table 1:
SSN
Name
Gender

Table 2:
SSN
Age
Repetitions

Table 3:
Gender
Age
Repetitions
Score

After the user inputs the SSN, I need to look up the score
from table 3 based on age and repetitions from table 2. I
thought DLookUp() was the way to do it, but (1) I've been
having problems with it and (2) I've read that it isn't
the most effective way to lookup that kind of information.

Can anyone help me? I can create this query either
through QBE or SQL.

Thanks

Rob Mazur
Nov 12 '05 #1
8 2583
TC
Rob, no-one can reliably answer questions like this, unless you state the
primary key of each table involved.

HTH,
TC
"Rob Mazur" <rp*****@hotmai l.com> wrote in message
news:2d******** *************** ***@posting.goo gle.com...
Hi. I'm trying to create a query that pulls information
from 3 seperate tables. Here's how I want it to work:

User is prompted for SSN

Table 1:
SSN
Name
Gender

Table 2:
SSN
Age
Repetitions

Table 3:
Gender
Age
Repetitions
Score

After the user inputs the SSN, I need to look up the score
from table 3 based on age and repetitions from table 2. I
thought DLookUp() was the way to do it, but (1) I've been
having problems with it and (2) I've read that it isn't
the most effective way to lookup that kind of information.

Can anyone help me? I can create this query either
through QBE or SQL.

Thanks

Rob Mazur

Nov 12 '05 #2
Why do you have/need 3 tables? Can't Tables 1 and 2 be merged? How
are they related (1-1, 1-M?) What are you *really* trying to achieve
here? What's in the "repetition s" table? Rules?

Don't know about anyone else, but I'd certainly need more information
before I could even guess what's going on. My initial guess is that
you need to normalize, but I can't even tell that without further
information about what you're trying to model.
Nov 12 '05 #3
pi********@hotm ail.com (Pieter Linden) wrote in message news:<bf******* *************** ***@posting.goo gle.com>...
Why do you have/need 3 tables? Can't Tables 1 and 2 be merged? How
are they related (1-1, 1-M?) What are you *really* trying to achieve
here? What's in the "repetition s" table? Rules?

Don't know about anyone else, but I'd certainly need more information
before I could even guess what's going on. My initial guess is that
you need to normalize, but I can't even tell that without further
information about what you're trying to model.


Okay, here's the scoop. I have 3 tables: (1) Solider Information
(Name, Gender, SSN[Primary Key], Unit), (2) APFT Record (SSN, Rank,
Age, PTTestDate, PURaw, SURaw, 2MileRunRaw, etc), (3) ScoreLookup
(Age, PURaw, PUScore, SURaw, 2MileRunRaw, 2MileRunScore).

The thought here was to have individual tables for Solider
Information, PT Test scores and the ScoreLookup table would contain
the Raw score (repetitions) to actual score. For example, a 19 year
old Male who did 40 push ups has a score of 57. So, the lookup needs
to be based on age, gender and raw score.

I felt from a management standpoint having this information in
seperate tables would be easier. Honestly, I'm not sure if that's the
right/best way to accomplish this task. Since PT Tests are held at a
minimum of every 6 months, there would be at least 2 entries in the
APFT table (possibly more depending on length of stay at a duty
station). I couldn't use the [APFT Record].[SSN] as a primary key,
because it wouldn't allow duplicate entries (unless my relationship
was screwed up.)

Thanks for your help on this.

Rob
Nov 12 '05 #4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'd change the table designs (the below CREATE TABLE statements use
the ANSI/JET DDL):

Table Units is a lookup table of Unit names associated w/ ID numbers
that other tables will use instead of the Unit name.

CREATE TABLE Units (
Unit COUNTER NOT NULL , -- Counter is JET AutoNumber
UnitName VARCHAR(35) NOT NULL PRIMARY KEY,
CONSTRAINT idxUnit UNIQUE (Unit)
)

Personal info (Age & Rank) particular to one individual (solider)
usually should be in the same table instead of in many tables
(Soliders & PTTests).

CREATE TABLE Soliders (
SoliderID COUNTER NOT NULL ,
SSN VARCHAR(9) NOT NULL PRIMARY KEY,
LastName VARCHAR(25) NOT NULL,
FirstName VARCHAR(20) ,
Rank VARCHAR(5) NOT NULL ,
Age INTEGER ,
Unit INTEGER NOT NULL REFERENCES Units,
CONSTRAINT idxSoliderID UNIQUE (SoliderID)
)

Table PTTests is another lookup table that will be used like the Units
table. This table helps normalize the APFT and ScoreLookup tables -
you don't have to have a column for each test.

CREATE TABLE PTTests (
TestID COUNTER NOT NULL CONSTRAINT idxTestID UNIQUE ,
TestName VARCHAR(30) NOT NULL PRIMARY KEY
)

PTTests data would look like this:

TestID TestName
- ------ --------
1 PURaw
2 PUScore
3 SURaw
4 2MileRunRaw
.... etc. ...

I'm not sure about the "raw" and "score" test names. These may be 2
different things. IOW, the Tests may in fact be PU, SU, 2MileRun,
etc., and Raw is a datum that is independent of the solider's score -
i.e., the Raw value is a value that the solider's test score is
compared against. Correct? Anyway, I made the remaining tables using
that assumption.

[APFT = Army Physical Fitness Test?]

This table holds each solider's test score, per test date. This is
the table that will have the most "work" (data entry). SoliderID
refers to table Soliders - there is where you'll get the solider's age
& rank. The primary key allows only one type of test per solider per
date.

CREATE TABLE APFT (
SoliderID INTEGER NOT NULL REFERENCES Soliders ,
PTTestDate DATETIME NOT NULL ,
TestID INTEGER NOT NULL REFERENCES PTTests ,
Score INTEGER NOT NULL ,
CONSTRAINT PK_APFT PRIMARY KEY (SoliderID, PTTestDate, TestID)
)

CREATE TABLE ScoreLookup (
TestID INTEGER NOT NULL REFERENCES PTTests ,
Age INTEGER NOT NULL ,
Raw INTEGER NOT NULL PRIMARY KEY ,
CONSTRAINT PK_ScoreLookup PRIMARY KEY (TestID, Age, Raw)
)

I'm not sure about this table - I'm assuming it holds data about what
the aveage/lowest (?) "raw" score is for each age group, per test.
That's the way I set it up.

- --
MGFoster:::mgf
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP8OVE4echKq OuFEgEQLrHQCeKh okd+HLn6eMr4+jM BhAmjU295QAoNrI
e4CmBe3NIBPQQUg Kx8nmsO0y
=ZNJC
-----END PGP SIGNATURE-----
Rob Mazur wrote:
pi********@hotm ail.com (Pieter Linden) wrote in message news:<bf******* *************** ***@posting.goo gle.com>...
Why do you have/need 3 tables? Can't Tables 1 and 2 be merged? How
are they related (1-1, 1-M?) What are you *really* trying to achieve
here? What's in the "repetition s" table? Rules?

Don't know about anyone else, but I'd certainly need more information
before I could even guess what's going on. My initial guess is that
you need to normalize, but I can't even tell that without further
information about what you're trying to model.

Okay, here's the scoop. I have 3 tables: (1) Solider Information
(Name, Gender, SSN[Primary Key], Unit), (2) APFT Record (SSN, Rank,
Age, PTTestDate, PURaw, SURaw, 2MileRunRaw, etc), (3) ScoreLookup
(Age, PURaw, PUScore, SURaw, 2MileRunRaw, 2MileRunScore).

The thought here was to have individual tables for Solider
Information, PT Test scores and the ScoreLookup table would contain
the Raw score (repetitions) to actual score. For example, a 19 year
old Male who did 40 push ups has a score of 57. So, the lookup needs
to be based on age, gender and raw score.

I felt from a management standpoint having this information in
seperate tables would be easier. Honestly, I'm not sure if that's the
right/best way to accomplish this task. Since PT Tests are held at a
minimum of every 6 months, there would be at least 2 entries in the
APFT table (possibly more depending on length of stay at a duty
station). I couldn't use the [APFT Record].[SSN] as a primary key,
because it wouldn't allow duplicate entries (unless my relationship
was screwed up.)

Thanks for your help on this.

Rob


Nov 12 '05 #5
TC

"Rob Mazur" <rp*****@hotmai l.com> wrote in message
news:2d******** *************** ***@posting.goo gle.com...
pi********@hotm ail.com (Pieter Linden) wrote in message

news:<bf******* *************** ***@posting.goo gle.com>...
Why do you have/need 3 tables? Can't Tables 1 and 2 be merged? How
are they related (1-1, 1-M?) What are you *really* trying to achieve
here? What's in the "repetition s" table? Rules?

Don't know about anyone else, but I'd certainly need more information
before I could even guess what's going on. My initial guess is that
you need to normalize, but I can't even tell that without further
information about what you're trying to model.


Okay, here's the scoop. I have 3 tables: (1) Solider Information
(Name, Gender, SSN[Primary Key], Unit), (2) APFT Record (SSN, Rank,
Age, PTTestDate, PURaw, SURaw, 2MileRunRaw, etc), (3) ScoreLookup
(Age, PURaw, PUScore, SURaw, 2MileRunRaw, 2MileRunScore).


(snip)

You're still not giving the primary key for each table. Believe me, this
will cause you grief in the long run.

TC

Nov 12 '05 #6
"TC" <a@b.c.d> wrote in message news:<106981578 6.72334@teuthos >...
"Rob Mazur" <rp*****@hotmai l.com> wrote in message
news:2d******** *************** ***@posting.goo gle.com...
pi********@hotm ail.com (Pieter Linden) wrote in message

news:<bf******* *************** ***@posting.goo gle.com>...
Why do you have/need 3 tables? Can't Tables 1 and 2 be merged? How
are they related (1-1, 1-M?) What are you *really* trying to achieve
here? What's in the "repetition s" table? Rules?

Don't know about anyone else, but I'd certainly need more information
before I could even guess what's going on. My initial guess is that
you need to normalize, but I can't even tell that without further
information about what you're trying to model.


Okay, here's the scoop. I have 3 tables: (1) Solider Information
(Name, Gender, SSN[Primary Key], Unit), (2) APFT Record (SSN, Rank,
Age, PTTestDate, PURaw, SURaw, 2MileRunRaw, etc), (3) ScoreLookup
(Age, PURaw, PUScore, SURaw, 2MileRunRaw, 2MileRunScore).


(snip)

You're still not giving the primary key for each table. Believe me, this
will cause you grief in the long run.

TC


TC:

That's part of the problem. I've tried a couple of different primary
keys with no success. Any suggestions on that?

Also, it was suggested the the Solider Information and APFT Record
tables be combined. Good/Bad idea?

Thanks for the help so far.

Rob
Nov 12 '05 #7

"Rob Mazur" <rp*****@hotmai l.com> wrote in message
news:2d******** *************** ***@posting.goo gle.com...
"TC" <a@b.c.d> wrote in message news:<106981578 6.72334@teuthos >...
"Rob Mazur" <rp*****@hotmai l.com> wrote in message
news:2d******** *************** ***@posting.goo gle.com...
pi********@hotm ail.com (Pieter Linden) wrote in message

news:<bf******* *************** ***@posting.goo gle.com>...
> Why do you have/need 3 tables? Can't Tables 1 and 2 be merged? How
> are they related (1-1, 1-M?) What are you *really* trying to achieve > here? What's in the "repetition s" table? Rules?
>
> Don't know about anyone else, but I'd certainly need more information > before I could even guess what's going on. My initial guess is that
> you need to normalize, but I can't even tell that without further
> information about what you're trying to model.

Okay, here's the scoop. I have 3 tables: (1) Solider Information
(Name, Gender, SSN[Primary Key], Unit), (2) APFT Record (SSN, Rank,
Age, PTTestDate, PURaw, SURaw, 2MileRunRaw, etc), (3) ScoreLookup
(Age, PURaw, PUScore, SURaw, 2MileRunRaw, 2MileRunScore).


(snip)

You're still not giving the primary key for each table. Believe me, this
will cause you grief in the long run.

TC


TC:

That's part of the problem. I've tried a couple of different primary
keys with no success. Any suggestions on that?

Also, it was suggested the the Solider Information and APFT Record
tables be combined. Good/Bad idea?

Thanks for the help so far.

Rob

Rob, post the fields of the specific table in question, & a brief
description of what a single row in that table, represents. Something along
the following lines:

tblPerson - one row for each person known to the system.
surname - person's surname
DOB - person's date of birth.
etc.

Then we can help you find the primary key.

Primary keys are a fundamentl component of a relational database management
system like Access. Nothing else will work properly - everything else will
go wrong - if you don't have the right primary keys.

HTH,
TC

Nov 12 '05 #8
">
Rob, post the fields of the specific table in question, & a brief
description of what a single row in that table, represents. Something along
the following lines:

tblPerson - one row for each person known to the system.
surname - person's surname
DOB - person's date of birth.
etc.

Then we can help you find the primary key.

Primary keys are a fundamentl component of a relational database management
system like Access. Nothing else will work properly - everything else will
go wrong - if you don't have the right primary keys.

HTH,
TC


TC:

I apologize for not posting a reply sooner, it's been busy around
here. I willpost those tables/fields tomorrow AM.

Thanks again
Nov 12 '05 #9

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

Similar topics

37
4896
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours, Pujo
4
4674
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
3879
by: * ProteanThread * | last post by:
but depends upon the clique: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=954drf%24oca%241%40agate.berkeley.edu&rnum=2&prev=/groups%3Fq%3D%2522cross%2Bposting%2Bversus%2Bmulti%2Bposting%2522%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den ...
0
3787
by: frankenberry | last post by:
I have multi-page tiff files. I need to extract individual frames from the multi-page tiffs and save them as single-page tiffs. 95% of the time I receive multi-page tiffs containing 1 or more black and white CCITT4 compressed files (frames) inside the tiff. Every now and then I receive a mixture of black and white CCITT4 and JPEG compressed files, and sometimes just multi-page tiffs with JPEG only. The code runs great when dealing with the...
6
8181
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
4
17876
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the problem is the charset? How I can avoid this warning? But the worst thing isn't the warning, but that the program doesn't work! The program execute all other operations well, but it don't print the converted letters: for example, in the string...
5
5998
by: Shane Story | last post by:
I can seem to get the dimensions of a frame in a multiframe tiff. After selecting activeframe, the Width/Height is still really much larger than the page's actual dimensions. When I split a TIFF to several PNG files this causes a problem, becuase the resulting image is (the page to the far left and a lot of black space surrounding it and a filesize that is larger than needed. Any ideas?
5
5767
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone know a good place to start looking for some theory on the subject of multi user applications? I know only bits and pieces, like about transactions, but a compendium of possible approches to multi user programming would be very appreciated!
5
3285
by: dkelly925 | last post by:
Is there a way to add an If Statement to the following code so if data in a field equals "x" it will launch one report and if it equals "y" it would open another report. Anyone know how to modify this? Private Sub cmdPreview_Click() On Error GoTo Err_Handler 'Purpose: Open the report filtered to the items selected in the list box. 'Author: Allen J Browne, 2004. http://allenbrowne.com Dim varItem As Variant 'Selected items
0
2328
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing Systems (MuCoCoS'08) Barcelona, Spain, March 4 - 7, 2008; in conjunction with CISIS'08. <http://www.par.univie.ac.at/~pllana/mucocos08> *********************************************************************** Context
0
9620
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10104
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9912
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.