Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / August 2004

Tip: Looking for answers? Try searching our database.

2 Primary Keys

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Amir - 08 Aug 2004 04:50 GMT
Hi!

Can someone explain to me what is the purpose of using more the one
primary key in a table?
What will be the result of doing so?

If I have a table of Products which has two primary keys:
1. ProductID
2. SupplierID

If I set the ProductID to be indexed (allow duplicates) and the
SupplierID to be indexed (duplicates are not allowed) does that
mean I could have different products with the same ID, but
not if they are from the same supplier?

What is the advantage of using this method of double primary
key as opposed to using validation rules?

Regards.
Douglas J. Steele - 08 Aug 2004 04:17 GMT
Just a semantic pont, but, by definition, you can't have 2 primary keys.

Are you asking about having a primary key that has more than one field in
it? In that case, then yes, you can have the same product for multiple
suppliers, but you can't repeat a product for the the same supplier.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Hi!
>
[quoted text clipped - 15 lines]
>
> Regards.
JulieD - 08 Aug 2004 05:15 GMT
Hi

following from Doug's post ...
leave the index settings alone ... creating a primary key with two fields
will do the type of "validation" that you want .. .

however be careful if you set the primary key with the fields described you
are in fact saying that supplier A can only EVER buy product A once ...
maybe you need to include a date field in the primary key so that supplier A
can only purchase product A on a single date, but can purchase product A
again later on.

Regards
JulieD

> Just a semantic pont, but, by definition, you can't have 2 primary keys.
>
[quoted text clipped - 21 lines]
> >
> > Regards.
Amir - 08 Aug 2004 07:15 GMT
Hi there!

In my DB there is a table with double field primary key:
It's primary key is builded from the ReceiptNumber and
the ReceiptSupplier Fields. I thought this is good because
one supplier can't have more than one Receipt with the same
number, but different suppliers can use the same receipt number.

What should I put in the index? After all, I want
to allow duplicates in the receipt numbers
but I only want to allow it if it's for different suppliers.

Amir.

> Hi
>
[quoted text clipped - 36 lines]
> > >
> > > Regards.
Douglas J. Steele - 08 Aug 2004 11:54 GMT
As Julie said, you put both fields in the primary key.

When you have the table open in Design mode, highlight both fields, then
click on the "Key" icon to create the primary key.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Hi there!
>
[quoted text clipped - 53 lines]
> > > >
> > > > Regards.
Amir - 09 Aug 2004 01:50 GMT
OK, Thank you very much!

> As Julie said, you put both fields in the primary key.
>
[quoted text clipped - 61 lines]
> > > > >
> > > > > Regards.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.