database - How adding redundant data can get rid of complex join in Denormalization? -


i going through denormalizaition definition , wondering how adding redundant data can rid of complex join ?

consider following 2 relations:

department (department_id pk, department_name, manager_employee_id) employee (employee_id pk, employee_name, department_id) 

to list of employee names managers' names, need query following:

select e.employee_name, m.employee_name manager_name employee e inner join department d on e.department_id = d.department_id inner join employee m on d.manager_employee_id = m.employee_id 

now, if denormalize transitive functional dependency employee_id -> department_id -> manager_employee_id -> employee_name employee table, our tables this:

department (department_id pk, department_name, manager_employee_id) employee (employee_id pk, employee_name, department_id, manager_employee_id, manager_name) 

practically, might not design since redundancies result in data consistency if it's not kept in sync. however, we'll ignore risk purpose of example.

with new tables, can list of employee , manager names this:

select employee_name, manager_name employee 

redundancy can queries expressed more simply, can introduce risk of data inconsistency needs considered , controlled. redundancy requires more storage space , can make queries slower, since fewer rows can fit page on disk. on other hand, can make queries faster eliminating joins or calculations, , can used enforce consistency. each case needs considered on own merits.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -