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

How to get the mapping relationship between two columns in a table的更多相关文章

  1. Database: key

    super-key: Any key that has more columns than necessary to uniquely identify each row in the table i ...

  2. [转]Entity Framework Fluent API - Configuring and Mapping Properties and Types

    本文转自:https://msdn.microsoft.com/en-us/data/jj591617#1.2 When working with Entity Framework Code Firs ...

  3. SAP CRM One order里user status和system status的mapping逻辑

    Below example show: How the mapping relationship between User status and System status maintained in ...

  4. JavaPersistenceWithHibernate第二版笔记-第六章-Mapping inheritance-004Table per class hierarchy(@Inheritance..SINGLE_TABLE)、@DiscriminatorColumn、@DiscriminatorValue、@DiscriminatorFormula)

    一.结构 You can map an entire class hierarchy to a single table. This table includes columns for all pr ...

  5. 冰冻三尺非一日之寒-mysql(orm/sqlalchemy)

    第十二章  mysql ORM介绍    2.sqlalchemy基本使用 ORM介绍: orm英文全称object relational mapping,就是对象映射关系程序,简单来说我们类似pyt ...

  6. Hive Tutorial(上)(Hive 入门指导)

    用户指导 Hive 指导 Hive指导 概念 Hive是什么 Hive不是什么 获得和开始 数据单元 类型系统 内置操作符和方法 语言性能 用法和例子(在<下>里面) 概念 Hive是什么 ...

  7. Programming Entity Framework 翻译(1)-目录

    1. Introducing the ADO.NET Entity Framework ado.net entity framework 介绍 1 The Entity Relationship Mo ...

  8. kudu

    Kudu White Paper http://www.cloudera.com/documentation/betas/kudu/0-5-0/topics/kudu_resources.html h ...

  9. DTrace to Troubleshoot Java Native Memory Problems

    How to Use DTrace to Troubleshoot Java Native Memory Problems on Oracle Solaris 11 Hands-On Labs of ...

随机推荐

  1. var与let的区别

    var与let的区别 前言: 在没接触Es6之前,我们在js中声明都是通过var来声明变量的,var声明变量虽说方便,但是,又有一些自己的诟病,下边来说一说,这三个的区别! var var相信大家都不 ...

  2. TCP错误恢复特性之一TCP重传

    TCP的错误恢复特性是我们用来定位.诊断并最终修复网络高延迟的最好工具. 常见的TCP错误恢复特性有:TCP重传.TCP重复确认和快速重传 1. TCP重传: 重传数据包是TCP最基本的错误恢复特性之 ...

  3. oracle常用函数及关键字笔记

    --函数及关键字--1.trim,ltrim,rtrim 去除字符,无指定默认去除空格SELECT TRIM('a' FROM 'aafhfhaaaaaaaa'), LTRIM('aafhfhaaaa ...

  4. Oracle锁表处理操作笔记

    --查看锁表进程SQL语句1: SELECT sess.sid, sess.serial#, lo.oracle_username, lo.os_user_name, ao.object_name, ...

  5. Java负载均衡-輪詢法

    import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Set; /* ...

  6. Redis 错误1067:进程意外终止,Redis不能启动,Redis启动不了

    Redis 错误1067:进程意外终止,Redis不能启动,Redis启动不了 >>>>>>>>>>>>>>> ...

  7. Odoo之Field

    字段描述符包含了字段的定义,下面是实例化一个字段时的属性: class Field(object): :param string: 字段标签(用户所见),如果不设置ORM将取用类的字段名(大写).:p ...

  8. install.php文件建表时设置编码方式

    DROP TABLE IF EXISTS `".$db_prefix."adminlog`;CREATE TABLE `".$db_prefix."adminl ...

  9. (转)Java线程:大总结

    Java线程:大总结   Java线程是Java语言中一个非常重要的部分,Java5之前,多线程的语言支持还是比较弱的,内容也较少,写一个复杂的多线程程序是相当有挑战性的.   在Java5以后,Ja ...

  10. LeetCode-Palindrome Partitioning II[dp]

    Palindrome Partitioning II Given a string s, partition s such that every substring of the partition ...