I need some best-practice and performance advice.
Let's say I have three tables: Employees, Jobs and Ranks. Every employee has a job and a rank, so obviously I should reference those tables in my Employees table.
My question is, which of these options is best:
1) Each job and rank are stored with a unique ID paired a descriptive name. The Employees table should reference the unique ID in the other table, thus saving memory (the descriptive name is only saved once in the Jobs/Ranks table), but to see the descriptive names I'll need to do JOIN
s:
SELECT Employees.EMPL_ID, Ranks.R_NAME, Jobs.J_NAME
FROM Jobs
JOIN Ranks ON Ranks.R_ID=Employees.RANK
JOIN Jobs ON Jobs.J_ID=Employees.JOB
2) Just unique descriptive names. It can be a waste of memory, because i repeatedly save the descriptive name of each rank / job, but I save time on my SELECT
statements
<EDIT:>
Just to clarify, my main concern is the performance I'll have to deal with if I'll need to perform SELECT
s with multiple JOIN
s instead of one SELECT
statement.
I want to be able to deal with lots of traffic - specifically, Employees requests to see their Job and Rank.
<EDIT>
Examples:
Option 1 (IDs and names):
Employees:
__________________________
/ EMPL_ID | RANK | JOB \
| 1 | 2 | 3 |
| 1 | 1 | 3 |
| 1 | 1 | 1 |
\__________|________|______/
Ranks:
__________________
/ R_ID | R_NAME \
| 1 | GRUNT |
| 2 | BOSS |
\________|_________/
Jobs:
____________________
/ J_ID | J_NAME \
| 1 | JANITOR |
| 3 | PRESIDENT |
\________|___________/
Option 2 (unique names):
Employees:
_______________________________
/ EMPL_ID | RANK | JOB \
| 1 | BOSS | PRESIDENT |
| 1 | GRUNT | PRESIDENT |
| 1 | GRUNT | JANITOR |
\__________|________|___________/
Ranks:
__________
/ R_NAME \
| GRUNT |
| BOSS |
\__________/
Jobs:
___________
/ J_NAME \
| JANITOR |
| PRESIDENT |
\___________/