What's a zip join? Have you ever heard of that, or a pairwise join?

和自甴很熟 提交于 2019-11-27 18:00:44

问题


This section of Slick's documentation page is quite odd.

What is this zip join? It says that it means:

a pairwise join of two queries

but what that means @.@ I don't know

I've tried Googling for both "zip join" and "pairwise join"... but no results to do with databases.

I do get this from Wikipedia when I search on "pairwise" though...


Could somebody give me some examples illustrating the differences between a zip join and a normal outer or inner join? Thanks!


回答1:


Zip joins are only meaningful when talking about ordered sets. Instead of joining based on the value of a column, you are joining based on the row number.

Table1

[λ]  [color] 
400  violet 
415  indigo 
475  blue   
510  green  
570  yellow 
590  orange 
650  red    

Table2

[flame]  [element]
green    boron
yellow   sodium
white    magnesium
red      calcium
blue     indium

Table1 INNER JOIN Table2 ON [color] = [flame] : only matching rows

[λ]  [color]  [flame]  [element]
475  blue     blue     indium 
510  green    green    boron
570  yellow   yellow   sodium
650  red      red      calcium

Table1 OUTER JOIN Table2 ON [color] = [flame] : all rows, matched where possible

[λ]  [color]  [flame]  [element]
400  violet   NULL     NULL
415  indigo   NULL     NULL
475  blue     blue     indium
510  green    green    boron
570  yellow   yellow   sodium
590  orange   NULL     NULL
650  red      red      calcium
NULL NULL     white    magnesium

Table1 "zip joined" to Table2 : all rows, regardless of match

[λ]  [color]  [flame]  [element]
400  violet   green    boron
415  indigo   yellow   sodium
475  blue     white    magnesium
510  green    red      calcium
570  yellow   blue     indium
590  orange   NULL     NULL
650  red      NULL     NULL

Zip joins are combining the data like a zipper, pairing the first row from one table with the first row from the other, second paired with second, etc. It's not actually looking at that data. They can be generated very quickly, but they won't mean anything unless there is some meaningful order already present in your data or if you just want to generate random pairings



来源:https://stackoverflow.com/questions/17581414/whats-a-zip-join-have-you-ever-heard-of-that-or-a-pairwise-join

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!