I'm now to this point of my project that I need to design my database (Oracle). Usually for the status and countries tables I don’t use a numeric primary key, for example
STATUS (max 6)
AC --> Active
DE --> Deleted
COUNTRIES (total 30)
UK --> United Kingdom
IT --> Italy
GR --> Greece
These tables are static, not updated through the application and it's not foreseen to be change in the future so there is no chance having update problems in tables that will use these values as foreign keys.
The main table of the application will use status and country (more than once e.g. origin country, destination country) and it is foreseen that 600000 rows will be added per year
So my question is, will these VARCHAR(2) keys will have an impact in the performance when querying the join of there 3 tables. Will the first be significantly slower than the second?
SELECT m.*,
s.status_name,
c.country_name
FROM main m, status s, countries c
WHERE m.status_cd = s.status_cd
AND m.country_cd = c.country_cd
AND m.status_cd = 'AC'
AND m.country_cd = 'UK'
SELECT m.*,
s.status_name,
c.country_name
FROM main m, status s, countries c
WHERE m.status_cd = s.status_cd
AND m.country_cd = c.country_cd
AND m.status_cd = 1
AND m.country_cd = 2
Clarification:
Status is not binary ("max 6" next to the table name). The values will probably be:
* active
* deleted
* draft
* send
* replaced
and we need to display the decoded values to the user, so we need the names.