0

my basic requirement is I have some languages in the languages table. then I am adding my words and their translations in different languages. So to store that data I hope I am right the situation is one-to-many relationships. please have a look at the image. enter image description here

am I using a correct design? Or it could be better than this? any suggestions?

Shadow
  • 33,525
  • 10
  • 51
  • 64
Rakesh Kohali
  • 275
  • 2
  • 5
  • 17

2 Answers2

1

The following tables could be used:

  • language
    • id (key)
    • short text
  • term
    • language id (key)
    • id (key)
    • text
  • translation
    • language_id1 (key)
    • term_id1 (key)
    • language_id2 (key)
    • term_id2 (key)
Xypron
  • 2,215
  • 1
  • 12
  • 24
0

Here's my suggestion. I normally prepend my IDs by the table name to make it easier to read. Obviously, you can use the naming standards you prefer.

Language
- LanguageID
- Description

Term
- TermID

Translation
- LanguageID
- TermID
- Text

As for the key for the Translation table, it depends on how many translations you will allow per language.

If you allow multiple, then add a TranslationID.

If you want to force just one, use a concatenated key of LanguageID and TermID. See How to properly create composite primary keys - MYSQL

I know it looks odd to have a table with just a key in it, but this structure has multiple advantages.

  • It will allow you to query only one field when doing a search, regardless of whether you're translating FROM English or TO English.
  • If one day, you need to translate between languages other than English, you're already set.
  • You can translate the same word more than once, depending on its different meanings.

Here is an example of how to use it

Language
1 English
2 French
3 Spanish

Term
1

Translation
1 1 Dog
1 1 Hound  -- (if this is allowed, add a TranslationID)
2 1 Chien
3 1 Perro   
chabzjo
  • 606
  • 1
  • 5
  • 10
  • Every translation a -> b is indicates also a translation b -> a. So why would you want translation texts in a different table than source texts? – Xypron May 12 '18 at 08:28
  • @Xypron: The translation texts are all in the Translation table, just like for your suggestion. – chabzjo May 12 '18 at 16:22