mysql - The logic of field type in relationship -
i have tables user preferences currency
, language
, ...
currency
structure , sample records :
id | title | slug ----+------------+-------- 1 | dollar | usd 2 | ca dollar | cad 3 | euro | eur 4 | swiss franc| chf
language
structure , sample records :
id | title | code | flag ----+-------------+-----------+---------- 1 | english | en | img/flags/en.png 2 | french | fr | img/flags/fr.png
i want create relation between these tables , users
tables, want know field better foreign key ? example in currency
table currency.id
or currency.slug
?
if see sql speed should go currency.id because finding integer value lots many rows (in thousands) would faster finding varchar.
but here see currency won't more 500 can use both won't affect speed.
you can use both in particular example: currency.id or currency.slug
Comments
Post a Comment