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  

autonumber relationship



 
 
Thread Tools Display Modes
  #1  
Old June 23rd, 2009, 03:19 PM posted to microsoft.public.access.tablesdbdesign
CuriousMark
external usenet poster
 
Posts: 61
Default autonumber relationship

Trying to set up many-to-many relationship with an intersection table, but
having trouble with enforce referential integrity. Each table on the "one"
side has a primary key field with autonumber data type. The corresponding
field in the intersection table is a number data type. So when I try to
enforce referential integrity I get the error "Relationship must be on the
same number of fields with the same data types". I thought this is the way
many-to-many relationships are supposed to be created. What am I missing?
  #2  
Old June 23rd, 2009, 04:51 PM posted to microsoft.public.access.tablesdbdesign
Klatuu
external usenet poster
 
Posts: 7,074
Default autonumber relationship

Think of each of the sides as being independant.

tblOneSide
OneSideID PK - Autonumber
other fields

tblOtherSide
OtherSideID PK - Autonumber

tblJunction
JunctionID PK - Autonumber
OneSideID Foreign Key - Long Integer
OtherSideID Foreign Key - Long Integer


--
Dave Hargis, Microsoft Access MVP


"CuriousMark" wrote:

Trying to set up many-to-many relationship with an intersection table, but
having trouble with enforce referential integrity. Each table on the "one"
side has a primary key field with autonumber data type. The corresponding
field in the intersection table is a number data type. So when I try to
enforce referential integrity I get the error "Relationship must be on the
same number of fields with the same data types". I thought this is the way
many-to-many relationships are supposed to be created. What am I missing?

  #3  
Old June 23rd, 2009, 05:43 PM posted to microsoft.public.access.tablesdbdesign
CuriousMark
external usenet poster
 
Posts: 61
Default autonumber relationship

I understand that. But the problem is that when I create a relationship
between OneSideID in tblOneSide and OneSideID in tblJunction, I get an error
when I check the enforce referential integrity option because the field is
Autonumber in one table and Number in the other.

"Klatuu" wrote:

Think of each of the sides as being independant.

tblOneSide
OneSideID PK - Autonumber
other fields

tblOtherSide
OtherSideID PK - Autonumber

tblJunction
JunctionID PK - Autonumber
OneSideID Foreign Key - Long Integer
OtherSideID Foreign Key - Long Integer


--
Dave Hargis, Microsoft Access MVP


"CuriousMark" wrote:

Trying to set up many-to-many relationship with an intersection table, but
having trouble with enforce referential integrity. Each table on the "one"
side has a primary key field with autonumber data type. The corresponding
field in the intersection table is a number data type. So when I try to
enforce referential integrity I get the error "Relationship must be on the
same number of fields with the same data types". I thought this is the way
many-to-many relationships are supposed to be created. What am I missing?

  #4  
Old June 23rd, 2009, 06:23 PM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default autonumber relationship

On Tue, 23 Jun 2009 09:43:01 -0700, CuriousMark
wrote:

I understand that. But the problem is that when I create a relationship
between OneSideID in tblOneSide and OneSideID in tblJunction, I get an error
when I check the enforce referential integrity option because the field is
Autonumber in one table and Number in the other.


Is the Autonumber the default Long Integer type, or is it a GUID?
Is the foreign key field a Number of Long Integer size (or some other size,
which would cause this problem)?
--

John W. Vinson [MVP]
  #5  
Old June 23rd, 2009, 06:29 PM posted to microsoft.public.access.tablesdbdesign
Fred
external usenet poster
 
Posts: 1,451
Default autonumber relationship

An autonumber field is a long integer type.

So make your FK also a long integer type. In table design, after you pick
"number" (as you've already done) look at the dialog box at the bottom and
pick the number type.
  #6  
Old June 23rd, 2009, 06:36 PM posted to microsoft.public.access.tablesdbdesign
CuriousMark
external usenet poster
 
Posts: 61
Default autonumber relationship

Thanks.....fk was Integer instead of Long Integer....

"John W. Vinson" wrote:

On Tue, 23 Jun 2009 09:43:01 -0700, CuriousMark
wrote:

I understand that. But the problem is that when I create a relationship
between OneSideID in tblOneSide and OneSideID in tblJunction, I get an error
when I check the enforce referential integrity option because the field is
Autonumber in one table and Number in the other.


Is the Autonumber the default Long Integer type, or is it a GUID?
Is the foreign key field a Number of Long Integer size (or some other size,
which would cause this problem)?
--

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 01:25 PM.


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