Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking 2 tables

Status
Not open for further replies.

zorigo

Programmer
Apr 24, 2002
1
US
I am attempting to build a membership application, that when people sign up, their personal data (i.e. name address, etc.) goes into a table called tblPersonalData and their Username & Password info goes into another called tblLoginData. Each of these tables has a column called UserID, that I have set as an identity column so that it auto-increments each time a new user signs up. My question is how do I make it so that the 2 UserID columns in each table are directly related. I am concerned that 2 people will sign up at the same time and accidentally get each other's username and or password, etc.
 
It sounds like you have a personal entity and a login entity, where each should have its own id. The userid identifies the person and loginid should identify the login. The userid should be a foreign key in the login table to relate the user to the login. The userid cannot be an identity field in the login table instead it must be a value that comes from the personal table. The personal record must exist before the login record to furnish the value for the foreign key in the login table.

Access will allow you to setup referential integrity where the userid value cannot exist in the login table unless it exists in the personal table. Referential integrity is the relationship between a primary key in one table and a foreign key in another table.

When adding records to the login table the userid can be a pick list that is made from the personal table.
 
To eliminate the possibility of people picking the same username, just set that up as an indexed column with duplicates not allowed in the table. You could do the same for the password, but if the username is different, what's the difference if two or more people pick the same password?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top