Say i have many tables in database that contain numeric id e.g. fields user_type, user_status, user_currency etc.
now i do have to display this information along other info on my pages of my website, say i have 10 pages where some of above info will be printed
METHOD 1 when i write query i do something like
SELECT ...
user_status
...
FROM users
WHERE user_id = 5
then i pass to template language, i use Smarty v3
and then inside page template i do something like
{section ...}
...
{if $users[0].user_status == 1}
New User
{elseif $users[0].user_status == 2}
Application Accepted
{elseif $users[0].user_status == 3}
Payment received
{/if}
...
{/section}
so same code basically goes into 10 different pages and when i change something or add new status, currency etc i got to go to each page and add it to the if statement
I think this method is very unreliable and time consuming
METHOD 2 so i started to do it like this i create another table with user statuses e.g. tbl_user_statuseds
user_status_id status_name
1 New User
2 Application Accepted
3 Payment received
...
then in main query for each page i do something like this
SELECT ...
tbl_user_statuseds.status_name
...
FROM users
LEFT JOIN tbl_user_statuseds ON tbl_user_statuseds.user_status_id = users.user_status
WHERE user_id = 5
and in page i just use {$users[0].status_name}
this takes out editing on each page if i add new status. All has to be done is add new line in database table statuses once
However with second method i have now about 10 tables in database that just contain the numerical id descriptions tbl_user_statuseds, tbl_currency_names, tbl_user_sex etc.
METHOD 3 i wonder would it be a good practice to use once table to store this ids? E.g.
tbl_id_labels
id id_type id_number id_label
421 2 1 New User
422 2 2 Application Accepted
423 2 3 Payment received
424 8 1 USD
425 8 2 EURO
426 5 1 Male
427 5 2 Female
...
Then i just do same as method 2 except i left join this table based on id_number e.g.
SELECT ...
tbl_id_labels.status_name
...
FROM users
LEFT JOIN tbl_id_labels ON tbl_id_labels.id_number = users.user_status AND tbl_id_labels.id_type = 2
WHERE user_id = 5
This way i only have one table with all labels for numeric id's i have in my system. If i have to add one in the future its not too difficult, all that matters is id_type and id_number, field id is just for compatibility.
Do you see any problem with third method, or can you advice better approach?