-1

I saw a lot types of DB and tables, but ill have web where people insert data in different languages (some people in english, some in spanish etc.). Website can be open in these languages and which language someone choose, see web just in this language. The point is, that english people see data, what english data was inserted. Should i have tables for all languages (when "maybe" the same information will not have the same id) ?

Thanks guys.

  • Look for different collation available. `utf8_general_ci` is the best IMHO for multiple languages. Also check [this](https://stackoverflow.com/q/341273/3094731) question. – Abdullah Khan Jul 30 '17 at 13:22

1 Answers1

0

It is not necessary to have a separate table for each language. But of course, everything depends on your type and amount of data. Moreover, some data does not need any translation. Just an example for people storing some descriptions for different pictures:

table pictures (picture_id, picture_url, description_id)
table desciptions (id, desciption_id, description_text, lang_id)

so, your basic query would look smth like this:

select * from pictures JOIN desctiptions ON (description_id)
where lang_id = X;

so, picture is same for all languages, and description will be shown in a specific language X. Note, that you can store descriptions in all languages in the same table.

well, that was just a suggestion... may be it will help in your future research.

UPDATE: answering your comment about different ids for same translated data. now i'm going to give an example of data in these two tables:

pictures:

1, 'image.jpg', 1

2, 'image2.jpg', 2

descriptions:

1, 1, 'some text', 1

2, 1, 'algún texto', 2

3, 2, 'another text', 1

4, 2, 'otro texto', 2

here you can see, that description_id refers actually to some kind of a meta-description-text (if i can say so), which can be in several languages.

but as i said, you can also have separate tables for separate languages, if the data is big. you just have to assure, that different translations of the same text share some common id.

sorry, if that's not what you asked, but i've understood it just the way i did, and tried my best to help.

Inna Tichman
  • 606
  • 5
  • 12
  • Thank you, but I think that you may misunderstood. I am working on a web page where all the language versions will be editable from the side of a user of certain language (like wikipedia or similar pages) and they may be able to add different entries, if someone adds data in EN and sb else adds the same data in ES, the IDs will differ. Is it OK to have a new table for each language in my DB? Thanks a lot – Martyyn Jul 31 '17 at 15:29