I’m trying to understand database normalization, I understand the general idea, but what is the right approach and what would be excess.
So for example I have a standard employee-department database as the first step.
Tables are
EMPLOYEES:
id, first_name, last_name, dob, email, city, address, department_name
So, to normalize this as the first step I would move department name to a separate table and would join when necessary as many-to-one.
EMPLOYEES:
id, first_name, last_name, dob, email, city, address, department_id
DEPARTMENTS
id, name
Would this be enough for normalization or is it better to move all other fields but department_id to a second table like employees_meta? Imagine if we have 20 more fields in the table describing the employee, what then would be normal?
If we are talking about optimizing a webpage, would the right normalization be to have only the fields we always show when we work with employee table, and all other information we don’t use so frequently to be moved to different tables?
Move city field into separated table, and I think it’s enough to be normal. The simple key for database normalization is avoiding duplicate value and separate it into single table. However, some case of data doesn’t need to separate like sex field, it’s better to use enum data type then then separate into other table.
Note: To much joining table on query will get lower performance.