mysql - Primary key on isolated table -
i cannot find solution problem , question is: have create primary key here?
details
my website has table in database called translations
in put each single sentence/word different translations. have structure:
id | lang | text ------------------- 01 | 01 | hello 01 | 02 | ciao 01 | 03 | salut 02 | 01 | surname 02 | 02 | cognome 02 | 03 | nom
the field id
connected word, field lang
number indicates translation (01 = english, 02 = italian, 03 = french) , text
translation of word.
in case, if need (for example) word hello know has id = 1 , can choose language.
is way create kind of table? not sure find easy because can call:
select text tablename id = ? , lang = ?
you can see ? because bind params pdo. 'lang' constant retrieved form cookie (01,02,03).
important note: here have no primary keys, have set id
, lang
unique
if want keep table structure , have one translation per language each word, can use id
+ lang
primary key
create table translations ( id int, lang int, text varchar(150) not null, primary key (id, lang) );
Comments
Post a Comment