Skip to main content
added 3 characters in body
Source Link
Accollativo
  • 509
  • 1
  • 5
  • 10

In postgresql I have a table with a list of cities. One row for city. Around 15000 rows. A column is CITY_NAME, now I have to add an english translation of the city name. The problem is that only 10 cities out of 15000 have an english translation. I was thinking about two solutions:

  1. Add a new rowcolumn CITY_NAME_ENG with english translation, and keep the value to NULL for record without translation.
  2. Duplicate the rows of the cities that have an english translation, keep only a column CITY_NAME and add a new column called LANGUAGE.

The second solution seems more elegant (and would be good if other languages will be add), but the select of all cities in a particular language seems tricky.

Are there other solutions? Which is better? NULL value occupy memory?

In postgresql I have a table with a list of cities. One row for city. Around 15000 rows. A column is CITY_NAME, now I have to add an english translation of the city name. The problem is that only 10 cities out of 15000 have an english translation. I was thinking about two solutions:

  1. Add a new row CITY_NAME_ENG with english translation, and keep the value to NULL for record without translation.
  2. Duplicate the rows of the cities that have an english translation, keep only a column CITY_NAME and add a new column called LANGUAGE.

The second solution seems more elegant (and would be good if other languages will be add), but the select of all cities in a particular language seems tricky.

Are there other solutions? Which is better? NULL value occupy memory?

In postgresql I have a table with a list of cities. One row for city. Around 15000 rows. A column is CITY_NAME, now I have to add an english translation of the city name. The problem is that only 10 cities out of 15000 have an english translation. I was thinking about two solutions:

  1. Add a new column CITY_NAME_ENG with english translation, and keep the value to NULL for record without translation.
  2. Duplicate the rows of the cities that have an english translation, keep only a column CITY_NAME and add a new column called LANGUAGE.

The second solution seems more elegant (and would be good if other languages will be add), but the select of all cities in a particular language seems tricky.

Are there other solutions? Which is better? NULL value occupy memory?

Source Link
Accollativo
  • 509
  • 1
  • 5
  • 10

Create a column mostly with null data SQL like

In postgresql I have a table with a list of cities. One row for city. Around 15000 rows. A column is CITY_NAME, now I have to add an english translation of the city name. The problem is that only 10 cities out of 15000 have an english translation. I was thinking about two solutions:

  1. Add a new row CITY_NAME_ENG with english translation, and keep the value to NULL for record without translation.
  2. Duplicate the rows of the cities that have an english translation, keep only a column CITY_NAME and add a new column called LANGUAGE.

The second solution seems more elegant (and would be good if other languages will be add), but the select of all cities in a particular language seems tricky.

Are there other solutions? Which is better? NULL value occupy memory?