If I’m making a database to store all the states, counties and cities along with info for each such as state website url, governor, etc. Is the best way to set up the counties functionality like:
'Counties' Table (One)
with two fields -> 'state' and 'county'
Texas Anderson
Texas Bell
Texas Dalhart
New York Albany
New York Allegany
with each row having a unique ID?
Or make a counties table for each state? Or make one counties table with each state being a different field?
The more I explain the more I’m almost certain it’s the first way, but I’ve never done this before so I wanted to check.
A state to county is a one to many relationship.
Simple enough
Because county names may be duplicated across different states you may want your counties table to have a CountyID auto identity number like an int to serve as a key. I’m not sure why you are introducing an additional
IDfield for the row. What makes it unique is the combination of state and county. No single county can belong to two states. They may have the same name but they do not belong to the same state.