Simple solution.
- Remove DEPT_NAME column from STAFFS table.
- JOIN DEPARTMENTS table using DEPT_CODE when ever you want to do so
This is called normalisation
Domanda
I'm creating 2 test tables in my oracle 10g database: STAFFS and DEPARTMENTS. Neither table has any primary keys, constraints, joins or any other thing since I don't know any of those anyway. Both are just plain tables with their fields.
In DEPARTMENTS, I have 2 fields: DEPT_NAME and DEPT_CODE. This table will serve as a reference table.
In STAFFS, I have 4 fields: STAFF_ID, STAFF_NAME, DEPT_NAME, and DEPT_CODE.
Say I change the DEPT_NAME of a staff record, how do I make the DEPT_CODE for that staff also change? I've tried creating triggers but all I get is either some mutating error thing or some recursive have been reach error.
Soluzione
Simple solution.
This is called normalisation