Field Properties for Primary and Foreign Keys

  • Thread starter Harold via AccessMonster.com
  • Start date
H

Harold via AccessMonster.com

Do the field properties have to be the same for the primary key and the
foreign key? Does the data type have to be the same? If I have AutoNumber on
one does the other have to be AutoNumber? If I have long Interger on one does
the other have to be the same? If not what should they be? If the Primary key
was set as required should the foreign key be a required field?

Also, If I set the primary key to AutoNumber what should the foreign keys
field be? AutoNumber? Number? Text?

For some reason the relationship thing is very hard to grasp.

Thanks,
Harold
 
R

Rick Brandt

Harold said:
Do the field properties have to be the same for the primary key and
the foreign key?
No

Does the data type have to be the same?

The types need to be "compatible". Not necessarily identical.
If I have AutoNumber on one does the other have to be AutoNumber?

No. In fact that would not be a workable solution anyway.
If I have long Interger on one does the other have to be the same? If not what
should they be?

See second response.
If the Primary key was set as required should the
foreign key be a required field?

That is typical, but depends on your data requirements. If you want to
allow child records that have no parent then you cannot make the foreign
field a required field. If you want to avoid such "orphans" then you would
make the foreign field a required field.
Also, If I set the primary key to AutoNumber what should the foreign
keys field be? AutoNumber? Number? Text?

Usually LongInteger.
 
H

Harold via AccessMonster.com

Lynn said:
If you set your the Primary Key of the parent table to AutoNumber, then your
foreign key in any child tables should be Long Integer.
Do the field properties have to be the same for the primary key and the
foreign key? Does the data type have to be the same? If I have AutoNumber
[quoted text clipped - 12 lines]
Thanks,
Harold




Thank you!

Harold
 

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