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  

Primary Keys and Relationships



 
 
Thread Tools Display Modes
  #1  
Old May 21st, 2004, 10:41 PM
TR
external usenet poster
 
Posts: n/a
Default Primary Keys and Relationships

I cannot form relationships with my tables. I keep getting indeterminate realtionships. I believe this is becasue I cannot define a primary key. I want to use three fields to define my primary key; however, I continue to get an error message that there are duplicates or the indexes are improperly marked. I indexed the fields to indicate yes or no for duplicates, but I still come up with an error. Any words of advice?
  #2  
Old May 22nd, 2004, 01:11 AM
rpw
external usenet poster
 
Posts: n/a
Default Primary Keys and Relationships

Usually you combine fields into a composite key when you know that the combination will not ever produce duplicates. The fact that the error message is saying that there are duplicates indicates that the combination is not producing a unique key.

The other problem you are having with 'indeterminate relationships' is possibly caused by how you are relating one table to another.

For example, if you have one table that has an Autonumber Primary Key (which is long-integer) and you want to link it to another table, the second table must have a field that is of the long-integer type and possess the same field length. The fields do not have to be of the same name, but it sure helps keeping things clear. (I suspect that when you are using a single field PK you do not have any of the problems you described.)

If you have three fields in tblOne that make up the composite PK, then tblTwo must have (in addition to its PK) three fields of the same type that match the composite key. In the relationships window, you select all three fields and drag them into tblTwo and then define which fields relate to which fields.

Of course, the easy fix for the first problem of having duplicates is to add an Auto#PK and relate the tables that way.

Hope this helps,

rpw



----- TR wrote: -----

I cannot form relationships with my tables. I keep getting indeterminate realtionships. I believe this is becasue I cannot define a primary key. I want to use three fields to define my primary key; however, I continue to get an error message that there are duplicates or the indexes are improperly marked. I indexed the fields to indicate yes or no for duplicates, but I still come up with an error. Any words of advice?
  #3  
Old May 23rd, 2004, 03:19 AM
John Vinson
external usenet poster
 
Posts: n/a
Default Primary Keys and Relationships

On Fri, 21 May 2004 14:41:02 -0700, "TR"
wrote:

I cannot form relationships with my tables. I keep getting indeterminate realtionships. I believe this is becasue I cannot define a primary key. I want to use three fields to define my primary key; however, I continue to get an error message that there are duplicates or the indexes are improperly marked. I indexed the fields to indicate yes or no for duplicates, but I still come up with an error. Any words of advice?


How are you trying to set the Primary Key? In table design view you
can ctrl-click each of the three fields, so they are all selected, and
then click the "key" icon; unless there are existing records for which
this set of fields has duplicates, you'll get a three-field primary
key which can then be used for your relationships. You need to draw
the relationship line THREE TIMES, one for each pair of matching
fields. Each field *individually* can have duplicates and should be
indexed as such, if you choose to create a separate index on the
individual field (it may not be necessary to do so).

If the program says there are duplicates ... there are probably
duplicates, and you'll need to fix them first. Run the "Find
Duplicates Query" wizard on the three fields to identify which records
are causing the problem.


John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 




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 12:29 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.