I'm having a problem creating a view on some data that involves two one-to-many joins like this:
tbl1 m----> tbl2 <----n tbl3
and I need to create a view on the data from all three tables without duplicates from tbl1 and tbl3.
The problem is that tbl1 and tbl3 are not related at all, except that they are linked by data in tbl2.
Think of it like this: you have a project, which can have multiple consultants, and multiple stakeholders, and the data must be returned in such a way that each consultant and each stakeholder appears once in the output (the project name must appear multiple times of course). The issue is that the following two datasets are logically distinct but semantically identical:
proj A, consultant A, stakeholder A
proj A, consultant B, stakeholder B
--
proj A, consultant B, stakeholder A
proj A, consultant A, stakeholder B
but what I'm aiming for is:
proj A, consultant A, stakeholder A
proj A, consultant B, stakeholder B
I've heard this described as a fan trap, but usual solutions involve reorganzing the data so that tbl3 joins tbl1 joins tbl2, but in my case there is no link there
Incidently, the intended platform for this is DB2 and/or SQL Server. Any help appreciated, thanks.