common fields

L

Lauren B

If I have two tables, each containing "user_ID" as the primary key, what
code do I need to write so that when I populate the "user_ID" in one, will
it automatically populate the other?

One table contains basic user information (name, address, phone#, etc.), the
other table contains specific computer system information for each
particular user. I have both fields represented on one form. Clearly, all
fields save to their corresponding table; however, I want the "user_ID"
(which is a unique name assigned to each entry by the individual using the
database, not an auto-generated number) to populate both tables.

Thank you in advance for any assistance.

LB
 
N

Nikos Yannacopoulos

Lauren,

I think you ought to take a step back and reconsider your design. You
have two types of entities, Users and Computers. Two points here:
1. a computer, as a separate entity, should have its own Computer_ID,
rather than relying on the User_ID to identify it;
2. The relationship between the two is not necessarily 1-to-1! What if a
user at some point requires a desktop in the office and a laptop for
travelling, at the same time?
I'd propose something like:

tblUsers
User_ID (PK)
UserName
Address
Phone
....

tblComputers
Computer_ID (PK)
User_ID (Foreign Key)
Type
Model
Processor
RAMsize
....

This will also make life easier when a computer is reassigned to another
user - just change the FK field in tblComputers.

HTH,
Nikos
 

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

Top