Re: Lookup Evils
- From: Jessi <Jessi@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 20 Mar 2008 15:05:01 -0700
Yeah, this particular database is for storing/retreiving/analyzing
groundwater data. I wish there were more examples out there for designing
this kind of database but they are usually more geared toward business use.
Anyway, I tried adding the units table to the relation window again and that
seems to work fine (I can create both relationships and enforce referential
integrity). I just didn't know if there was something "wrong" with adding
the table to the window more than once. As far as the primary key is
concerned, I too have been thinking about whether I want to use the unit for
the primary key. Its an ongoing debate and I'll have to read more to make
that decision. That's for your useful comments/suggestions.
Jessi
"Evi" wrote:
I can't comment on your table structure - I've no experience in this kind of.
db but I can see why you wanted all those unit fields now.
Does it tell you why you can't re-inforce ref integ?
If it's because you want to link the table twice, then just add the units
table a second time to the relationship window.
I suspect that it is because you have made the Unit Abbreviation the Primary
Key field of the Units Table but someone has not used your current
convention (eg they may have put a space in front of the l or written cms
instead of cm).
We can spot the faulty entries by using a Find Unmatched Query to find
anything in your main table's units field that isn't in your Units table.
You can then edit those entries by hand
Switch on Name Autocorrect, just for now. (switch it off when you've
finished everything)
I'm not sure that it is a good idea to use the Unit Abbreviation field as
the Primary Key field (someone else can confirm or deny this). Autonumbers
are safer because they can't be edited at all. They look ugly in tables but
the user need never see them. The combo boxes will contain them in their
first column but the wizard will encourage you to hide this so that the user
will only see the second column with the actual letters.
Lets say you add an Autonumber field to your Units table (call it UnitID)
To start with, add a number field to your Main Input table, never mind what
you call it, lets say also UnitID. In the end you can rename it by the same
name as your original field if you have to.
Once you have used your FindUnmatched table to check that both table have
the same data in the MeasurementUnit field then you can put both tables into
a query window and join them by the Measurement unit field (ie not the ID
field)
Check that the Input table still has the same number of records as before
you joined them. Put the letter fields from both tables into your query grid
and check if they have the same letters in them. (a fairly quick glance at
an example of each unit should do the trick)
Remove the other fields. Change the query to an Update Query. Add the UnitId
field from your Main table.
In the Update To line put
tblMeasurementUnits!UnitID
Do the same for the other UnitID type fields in your other tables.
Because the tables are linked, the UnitID field in your main table will now
have the correct ID number so that if it is added to a query with the
UnitAbbreviation field from the Measurements table you will see the correct
measurement.
Change the query back to a Select query and add fields and in the query
window to and check that all the fields in your main table are now filled.
then you can decide if you want to rename your Main Table's UnitID Field to
the name of your letter field.
Evi
"Jessi" <Jessi@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3BF0E553-3C50-48F1-90B3-8702266D2C48@xxxxxxxxxxxxxxxx
Thank you for the reply Evi.an
I thought I would provide a more concrete example.
tblWellCasingDetails
StationID (pk)
ComponentID (pk)
ComponentDescription
InnerDiameter
InnerDiameterUnit
TopZoneDepth
BottomZoneDepth
DepthUnit
DepthReference
Comments
tblHorizontalSurveyData
StationID (pk)
SurveyDate
SurveyGeneration (pk)
CurrentSurvey
SurveyCompany
XCoordinate
YCoordinate
CoordinateUnit
CoordinateSystem
HorizontalDatum
Notes
tblMeasurementUnits
Unit (pk)
UnitFullName
MeasurementSystem
MeasurementType
The first two tables above both contain fields which require an input for
the "Unit". In fact, tbl:WellCasingDetails has two fields which require
input for the "Unit" (InnerDiameterUnit and DepthUnit). The tabletables
tbl:MeasurementUnits is meant to serve as a look up table for the two
above and several others. I can create a relationship betweenrelationship
tbl:MeasurementUnits and tbl:HorizontalSurveyData and enforce referential
integrity. However, I run into a problem when I try to create a
from InnerDiameterUnit and from DepthUnit in the tbl:WellCasingDetails tothe
tbl:MeasurementUnits. I can create the relationships, but cannot enforceQueries
referential integrity. Any suggestions?
Jessi
"Evi" wrote:
.. Putting the units in another table is an excellent idea.
It is indeed good design to create a relationship. However, if you add a
field to an existing table, you may need to run a series of Update
Referentialto get you started before you join up the tables and 'Enforce
comboIntegrity'
You may even need to update some of the records by hand (using your
itemsbox in a form of course) before you can join your tables in the
Relationships Window. (I've even had to resort to calling one of the
couldin my 'lookup' table 'Unknown' because the unit that the inputter used
thehave been almost anything. But this just highlighted the necessity for
or intable)
You can add a 'lookup' table more than once to the relationship window
manya query grid so it can join to more than one table but I have a sinking
feeling that you may have a design problem when you say that you have
tables intables in which there is a Unit field - but then maybe I'm being
unnecessarily gloomy.
Evi
"Jessi" <Jessi@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BBB53505-7F56-429A-A623-1E9FFDEE0E52@xxxxxxxxxxxxxxxx
My question is related to the whole discussion of "lookup evils".lookup)
I now understand the logic of only including the user interface (the
in the form rather than directly in the table. If you have many
unitwhich there is a "Unit" field. The unit field stores a measurement
contains a(ft,
cm, m, L, gallon, etc.). As nearly every table in the database
standard"Unit" field I wanted to create a lookup table in which to store the
appropriate units so that users are forced to enter the unit in a
level.form. I see that I can do this by using a combo box at the form
tableBut,
is it necessary or good design to create a relationship between the
anddata is being entered into and the input table? I apologize if thisquestion
isn't worded very well, I'm still learning the terminology.
Jessi
"BruceM" wrote:
Thanks for pointing that out. I did a little more experimenting,
list. Ifound
no problems in sorting by the lookup field when it uses a value
aredoingexpect it would be the same if I used a one-column row source query.
However, if I'm going to construct a combo box anyhow I'll just keep
it on a form. I see no use for a user interface in a table.
"Pat Hartman(MVP)" <patsky@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:u26RjXsTGHA.4080@xxxxxxxxxxxxxxxxxxxxxxx
Everything the referenced link says is correct but there really
thecases
where the Lookups won't cause any harm. Let me try to separate
that istimes
when a lookup causes a problem and when it doesn't.
Lookup not OK:
1. you have a table of values and that table has a primary key
have adifferent from the value you want to display. For example, you
andlookuptable of department names and each department has an ID. Adding a
at the table level will cause problems with both nested queries
ifVBA
departmentName.code due to the confusion between the departmentID and the
want to
Lookup OK:
1. You have a table of values and the primary key is the value you
display. An example might be a State code table. This won't work
beyou
want to display the StateName. In that case the key field would
thedifferent from the display field.
2. You have a small list of values and the value you display is
thevalue
you want to save. An example might be Male, Female, Unknown. If
avalue you want to save is a code - M, F, U then you should not use
withtable
level lookup. Keep in mind that combos and listboxes work fine
want totext
values but you need numeric values for option groups so if you
numeric/textuse
an option group on a form, you'll have to work around the
notconversion problem with code.
In ALL cases, lookups on Forms do not cause problems. If you are
themultipleusing lookup value tables, you need to be very careful to keep
instances of combos in sync. You will keep a validation rule at
ontable
forms tolevel to ensure that bad data cannot be entered and use combos on
changesprovide pick lists but you will be responsible for making the same
to the table field's validation rule property and all combos based
problemthat
list. The next version of Access will take care of this little
aof
olderkeeping the value list and the combos in sync but the current and
versions do not. That is why most professionals rely on a table.
I happen to use a common table for all my simple lookups. It is
essentially a table within a table. I have forms and reports and
howevertable
that I add to all my applications.
"HelenJ" <HelenJ@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:6851185B-1E56-4CD5-B70A-05912C0BA400@xxxxxxxxxxxxxxxx
I have been reading all about the evils of lookups in tables,
tocould
someone please explain how you avoid using them - is the answer
necessaryhave
many
tiny tables with potentially only 2 fields (assuming it is
haveto
have
a PK in every table) and often only 2 records.
I am just starting the design of a new database and I seem to
create aseveral
fields which have 2 or sometimes 3 options and it seems a lot to
table for this.
Many thanks
Helen
- References:
- Re: Lookup Evils
- From: Jessi
- Re: Lookup Evils
- From: Evi
- Re: Lookup Evils
- From: Jessi
- Re: Lookup Evils
- From: Evi
- Re: Lookup Evils
- Prev by Date: Re: Membership database updates
- Next by Date: Re: Membership database updates
- Previous by thread: Re: Lookup Evils
- Next by thread: Re: Lookup Evils
- Index(es):
Relevant Pages
|
Loading