database design for dictionary application

后端 未结 4 1036
盖世英雄少女心
盖世英雄少女心 2020-12-28 09:56

Currently I\'d like to develop dictionary application for mobile device. The dictionary itself use offline file/database to translate the word. it just translates for two la

4条回答
  •  不思量自难忘°
    2020-12-28 10:20

    At least it for each translation there are a few translation possibilities depending on the context. if you like to do a bidirectional dictionary for two languages you need at least three tables:

    ENGLISH
    ID | WORD
    1  | 'dictionary'
    
    GERMAN
    ID | WORD
    1  | 'lexikon'
    2  | 'wörterbuch'
    
    TRANSLATION_EN_DE
    ID_EN | ID_DE
    1     | 1
    1     | 2
    

    The first two tables are containing all the words that are known in that language and the bidirectional mapping is done by the 3rd mapping table. this is a common n:n mapping case. with two more tables you're always able to add a new language into you're dicitionary. If you're doing it with one table you'll have multiple definitions for a single word thus no normalized db.

    you can also merge your language tables into a single table defining the words language by another column (referencing a language table). in that case you'll need a 2-column index for the language and the word itsself.

提交回复
热议问题