How to get the mapping relationship between two columns in a table

If a table have column A and B

Count(distinct A) as Da

Count(distinct B) as Db

Count(distinct A, B) as Dab

 

The Da/Db<=Dab, this will be always true;

1. if(Da=Db=Dab) => A:B as 1:1

2. if(Da<(Db=Dab)) => A:B as 1:N

3. if(Db<(Da=Dab)) => A:B as N:1

4. if(Da!=Db!=Dab) => A:B as N:N //relashionship is mess

 

For example for 4, how to generate the smaple data, first build a 1:N and then change the column to be N:N, like below
1    2

1    3

1    4 

2    5

=>

1   2

1   3

1   4

2   4

Da=2, Db=3,Dab=4

 

posted @ 2016-12-08 18:43  Researcher  阅读(118)  评论(0编辑  收藏  举报