Best way to split a table in Parent-Child to avoid duplicated information in MySQL -
what easiest way split location table in mysql?
current table has: country_code, country_name, state_code, state_name, city_code, city_name
i split in 3 tables
country table (parent) : country_code, country_name
state table (child-parent): country_code, state_code, state_name
city table (child): state_code, city_code, city_name
is possible simple query after creating each table , foreign key separately?
thanks,
your structure normalized you're going get. use foreign key on city table state_code, , same state table country table on country_code.
when query table, inner join between tables needed data state , country.
to populate existing table, loop through table , insert unique countries new country table, unique states, , 3rd query cities.
Comments
Post a Comment