Creating a pk with a calculated autonumber to create relationships (1 Viewer)

mandy4514

New member
Local time
Today, 07:38
Joined
Sep 24, 2012
Messages
4
I am trying to create four tables: Company, Contact, Activities, and Opportunities. I want them to relate hierarchically. A Company can have many contacts, contacts can have multiple Activities and Opportunities. But you can't have contacts without a company and you can't have Activities and Opportunities without having a contact. I want all PK's in all tables to link to one another, that you cannot create one without the other. Does anyone know how I can do this in Access 2010?
YYMM00000-000000-A0000
CompanyID-ContactID-ActivityID
or
YYMM00000-000000-O0000
CompanyID-ContactID-OpportunityID
Thanks,
Amanda
 

llkhoutx

Registered User.
Local time
Today, 06:38
Joined
Feb 26, 2001
Messages
4,018
In your case, don't use a a constructed primary key. Use unique autonumber primary keys for each table and foreign keys to indicate the relationships.

Example
Company table:
PKCompany
etc.

Contact Table:
PKContact
FKcompany
etc.

Activity Table
PKActivity
FKContact

PKCompany=FKCompany
PKContact=FKContact
 

Users who are viewing this thread

Top Bottom