Re: Tables cities and table user

From: J.O. Aho <user_at_example.net>
Date: Sun, 10 Feb 2019 15:47:09 +0100
Message-ID: <gcarrdF24r3U1_at_mid.individual.net>


On 2/9/19 10:50 AM, ^Bart wrote:

>> SELECT id_city,name,'IT' from cities_it
>> union all
>> SELECT id_city,name,'UK' from cities_uk

>
> I didn't understand what happen in the cities table when you use the
> union all command...
>
>> or, even better (before someone else askes this question):
>> Why do you have mulitple tables with city names?

>
> Because I think to store all cities from more or less ten countries or
> the entire world it's too heavy to to it just in one table!

Your "cities" table will be as heavy as one table with all the cities from all the ten countries, but your "cities" will consume more memory/disk as it will have ten columns (one for each country) instead of one column telling the country.

When you want to get the city name you will need to join in yet another table and you have to do so over the right column to the right table (this can lead to wrong joining and you get the wrong city name).

In the end your design will get a lot slower than using one table for all the cities.

-- 

  //Aho
Received on Sun Feb 10 2019 - 15:47:09 CET

Original text of this message