-- Generate all the result-inputs dependencies as a view, based on the value associations
drop table if exists dependency;
drop view if exists dependency;
create view dependency (result_id, input_id) as
	select r.id, i.id
	from r_value_assoc va
	inner join r_result_val rv on rv.id=va.resultval_id
	inner join r_input_val iv on iv.id=va.inputval_id
	inner join r_result r on rv.result_id=r.id
	inner join r_input i on i.id=iv.input_id
	group by r.id, i.id
	order by r.id asc, i.id asc;
