One-To-One Tables

D

David W. Fenton

Side-issue: Person-to-Company sounds like a many-to-one
relationship. I thought the purpose of join tables was to handle
many-to-many relationships.

Person-to-Company is very often a many-to-many because a person can
have a position at more than one company/organization. I could be
both president and CEO of ACME Corp., and also on the board of
InfiniCorp, and then a partner in PrivateVentures, LLC. What I've
just described is N:N for person/company, and 1:N for a person's
position(s) within each company.
Main issue: I like the concept of composite keys, but I read
somewhere on the internet from one published expert that composite
keys should be avoided because they create problems.

They do. They repeat a whole lot of data, which means you lose the
efficiency of Jet/ACE when retrieving the index pages, and then only
the needed data pages. If most of the data is in the foreign key,
Jet/ACE may not need to retrieve anything but the index, but the
number of index pages isn't going to be much larger for the same
number of rows, so I'd think that those composite keys would cause a
lot more data to be pulled across the Internet.

I don't use a composite key for any table whose PK is the foreign
key in another table. That is, if the table is not the parent in a
relationship with another table, a composite key is fine, particular
if it's a composite key of foreign keys, as in a many-to-many join
table.
My own experience is that even though Access
knows that a composite key is two fields that sometimes act as
one, Access apparently does not provide ready-made support for
this reality. For example, I like to use a list box as a
navigation tool to allow the user to pick a record, but this won't
work with composite keys because the list box is incapable of
passing the value of more than one field.

Well, not as a bound column, but you can still get the data in the
other columns. I think you use ItemData(i).Column -- I always have
to look it up, to be honest.

But for a bound listbox, it doesn't work well.

I don't bind many listboxes, but I certainly use lots of bound combo
boxes, and the problem with composite keys is identical there.
Another question: In your first example, does your junction table
actually store PersonID and CompanyID twice, once as PK and again
as FK?

No. I was describing the INDEXES not the fields. The table has only
the two fields, and there's a composite PK made up of the two
fields, and each field is individually a FK.
 
O

oldblindpew

David,
Thank you for your clear and practical answers.

I have reexamined the question of reading data from various columns in a
list box selection. I had thought before that this could only be
accomplished for a multiselect list box, and obviously, selecting more than
one record to navigate to would be undesirable. However, it appears one can
read any column in a list box selection by using the list box's Column
property. I haven't tested it yet, though.

As for the main topic of this thread, I have about come full circle back to
my original plan of using 1:1 tables for insurance information. This is due
mostly to the nature of the data: Insurance requirements are not all the same
kind of thing, and I don't think it would do to put them all in one master
table, like state name abbreviations. Also, I have many Agreements in my
Agreements table, but not all of them have Insurance, so this is a classic
example where a separate 1:1 table is justified.

Some may argue that store inventory items are all different, but they all go
in one table. My Agreement is just an Order, and my Insurance Requirements
just the Order Detail. Maybe, but store items share a common set of fields:
Item No, Description, Quantity, Unit of Measure, Unit Price, Shipping Weight.
Insurance requirements, in contrast, can be Y/N, Dollar amounts, Dates, or
Numeric values.

I think I'll just have to go ahead and find out the hard way. One thing
about Access is that so far, with my simple application, it hasn't been too
hard to make changes.
--OBP
 
D

David W. Fenton

As for the main topic of this thread, I have about come full
circle back to my original plan of using 1:1 tables for insurance
information. This is due mostly to the nature of the data:
Insurance requirements are not all the same kind of thing, and I
don't think it would do to put them all in one master table, like
state name abbreviations. Also, I have many Agreements in my
Agreements table, but not all of them have Insurance, so this is a
classic example where a separate 1:1 table is justified.

I used to be big on supertypes and subtypes, but found that the
outer joins needed to display all of them in a single list (or
UNION) were an unacceptable performance drain.

Now, with server-side views doing the joins, it might not be as bad,
but with Jet/ACE, it can be a complete killer.

That said, I just implemented a Customer History table that has
foreign keys on 3 different tables and does exactly what I just
described. It is performing just fine -- dunno why, but maybe I'm
just better at it than I used to be.

The perfect 1:1 scenario is when you create a basic record and then
some records then eventually reach a state when a bunch of other
fields need to be filled out, but not all of the basic records reach
that point. In a case management database for a psychiatric clinic,
the 1:1 side table recording the demographics, and were not filled
out until the case was closed. That was a perfect application of
1:1, as cases that never closed but were simply abandoned did not
have the demographics. It also made it easy to deal with the
demographic data as separate from the information specific to the
individual, which was good for confidentiality.

But I haven't encountered that many such situations.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top