Hello and thanks for reading.
Suppose I have the following three tables:
How can I correctly join them through a link table? Should I use more than one? What I am doing is this:
1 ) Declare each key on each table:
TABLE1:
LOAD
A & B AS KEY_A_B,
X
FROM TABLE1.QVD
TABLE2:
LOAD
A & B AS KEY_A_B,
A & B & C & D AS KEY_A_B_C_D,
Y
FROM TABLE2.QVD
TABLE3:
LOAD
A & B AS KEY_A_B,
A & B & C & D AS KEY_A_B_C_D,
Z
FROM TABLE3.QVD
2) Join them through one LINK TABLE
LINK_TABLE:
LOAD DISTINCT
KEY_A_B,
A,
B
RESIDENT TABLE1
CONCATENATE
LOAD DISTINCT
KEY_A_B,
KEY_A_B_C_D,
A,
B,
C,
D
RESIDENT TABLE2
CONCATENATE
LOAD DISTINCT
KEY_A_B,
KEY_A_B_C_D,
A,
B,
C,
D
RESIDENT TABLE3
You can already guess what's going on here: If I proceed this way, I end up creating a synthetic key (of keys...) between my link table and TABLE1 and 2 (because they share KEY_A_B and KEY_A_B_C_D), so, how do I proceed in this case? Should I concatenate KEY_A_B and KEY_A_B_C_D into a single key? This sound really dirty and unnecessary complex. Should I use another LINK TABLE separately?
I would really appreciate your help on this matter. Thank you very much.