3 table relationship

Romio68

Registered User.
Local time
Today, 22:07
Joined
Sep 4, 2013
Messages
27
Table 1 contains
State codes - Text - 2chr - Indexed - No Duplicates
State names - Text

Table 2 contains
State Codes - text - 2 chr - Indexed - Duplicates OK
City Codes - Numeric - Indexed - Duplicates OK - Format 000
City Name - text

Table 3 contains
Branch Code - Numeric - Indexed - Duplicates OK - Format 000

the mix of the 3 should be unique

There is only 1 Branch 001 in City 001 in State NY
There is only 1 Branch 002 in City 001 in State NY
There is only 1 Branch 001 in City 002 in State NY

What fields should I put in table 3 and what relations should I build between the tables to have referential integrity.

When I update/delete a state, it should propagate to cities in the state and branches in the city of the state.

Until now I used only relations between 2 tables, so I am a bit lost
Thank You
 
Bad table design.

Table 1 is tblStates, each is unique => OK
Table 2 is tblCities, multiple cities can have the same index number => not OK

Then table 3 is tblBranches. Add a unique index on both BranchID and CityID.
 

Users who are viewing this thread

Back
Top Bottom