#metadata for sorting
CORR_MD = {
  "aka_name": {
    "id": 1.0,
    "person_id": 0.0378195
  },
  "aka_title": {
    "id": 0.983477,
    "movie_id": 0.86907,
    "kind_id": 0.495698,
    "production_year": 0.0976516,
    "episode_of_id": 0.00405949,
    "season_nr": 0.481375,
    "episode_nr": 0.0570756
  },
  "cast_info": {
    "id": 1.0,
    "movie_id": 0.00577839,
    "person_id": 0.702236,
    "person_role_id": 0.427597,
    "nr_order": 0.0107366,
    "role_id": 1.0
  },
  "char_name": {
    "id": 0.999012,
    "imdb_id": 0
  },
  "comp_cast_type": {
    "id": 1.0
  },
  "company_name": {
    "id": 0.891632,
    "imdb_id": 0
  },
  "company_type": {
    "id": 1.0
  },
  "complete_cast": {
    "id": 1.0,
    "movie_id": 0.225815,
    "subject_id": 1.0,
    "status_id": 0.669621
  },
  "info_type": {
    "id": 1.0
  },
  "keyword": {
    "id": 0.994607
  },
  "kind_type": {
    "id": 1.0
  },
  "link_type": {
    "id": 1.0
  },
  "movie_companies": {
    "id": 1.0,
    "movie_id": 0.454579,
    "company_id": 0.591842,
    "company_type_id": 1.0
  },
  "movie_info": {
    "id": 0.499308,
    "movie_id": 0.110962,
    "info_type_id": 0.122835
  },
  "movie_info_idx": {
    "id": 1.0,
    "movie_id": 0.99953,
    "info_type_id": 0.333712
  },
  "movie_keyword": {
    "id": 1.0,
    "movie_id": 0.999617,
    "keyword_id": 0.0163728
  },
  "movie_link": {
    "id": 1.0,
    "movie_id": 0.992493,
    "linked_movie_id": 0.0323019,
    "link_type_id": 0.164079
  },
  "name": {
    "id": 1.0,
    "imdb_id": 0
  },
  "person_info": {
    "id": 1.0,
    "person_id": 0.402016,
    "info_type_id": 0.102871
  },
  "role_type": {
    "id": 1.0
  },
  "title": {
    "id": 0.998105,
    "kind_id": 0.395775,
    "production_year": 0.151194,
    "imdb_id": 0,
    "episode_of_id": 0.994194,
    "season_nr": 0.340666,
    "episode_nr": 0.0350549
  },
  "an": {
    "id": 1.0,
    "person_id": 0.0378195
  },
  "at": {
    "id": 0.983477,
    "movie_id": 0.86907,
    "kind_id": 0.495698,
    "production_year": 0.0976516,
    "episode_of_id": 0.00405949,
    "season_nr": 0.481375,
    "episode_nr": 0.0570756
  },
  "ci": {
    "id": 1.0,
    "movie_id": 0.00577839,
    "person_id": 0.702236,
    "person_role_id": 0.427597,
    "nr_order": 0.0107366,
    "role_id": 1.0
  },
  "chn": {
    "id": 0.999012,
    "imdb_id": 0
  },
  "cct": {
    "id": 1.0
  },
  "cn": {
    "id": 0.891632,
    "imdb_id": 0
  },
  "ct": {
    "id": 1.0
  },
  "cc": {
    "id": 1.0,
    "movie_id": 0.225815,
    "subject_id": 1.0,
    "status_id": 0.669621
  },
  "it": {
    "id": 1.0
  },
  "k": {
    "id": 0.994607
  },
  "kt": {
    "id": 1.0
  },
  "lt": {
    "id": 1.0
  },
  "mc": {
    "id": 1.0,
    "movie_id": 0.454579,
    "company_id": 0.591842,
    "company_type_id": 1.0
  },
  "mi": {
    "id": 0.499308,
    "movie_id": 0.110962,
    "info_type_id": 0.122835
  },
  "mi_idx": {
    "id": 1.0,
    "movie_id": 0.99953,
    "info_type_id": 0.333712
  },
  "miidx": {
    "id": 1.0,
    "movie_id": 0.99953,
    "info_type_id": 0.333712
  },
  "mk": {
    "id": 1.0,
    "movie_id": 0.999617,
    "keyword_id": 0.0163728
  },
  "ml": {
    "id": 1.0,
    "movie_id": 0.992493,
    "linked_movie_id": 0.0323019,
    "link_type_id": 0.164079
  },
  "n": {
    "id": 1.0,
    "imdb_id": 0
  },
  "pi": {
    "id": 1.0,
    "person_id": 0.402016,
    "info_type_id": 0.102871
  },
  "rt": {
    "id": 1.0
  },
  "t": {
    "id": 0.998105,
    "kind_id": 0.395775,
    "production_year": 0.151194,
    "imdb_id": 0,
    "episode_of_id": 0.994194,
    "season_nr": 0.340666,
    "episode_nr": 0.0350549
  }
}


DUP_MD = {
  "aka_name": {
    "id": 0.0,
    "person_id": 0.3473942188425703
  },
  "aka_title": {
    "id": 0.0,
    "movie_id": 0.43113002149550034,
    "kind_id": 0.9999861676317049,
    "production_year": 0.9996486578453043,
    "episode_of_id": 0.9979168453347571,
    "season_nr": 0.9998921075272982,
    "episode_nr": 0.9995545977408976
  },
  "cast_info": {
    "id": 0.0,
    "movie_id": 0.9356699609646669,
    "person_id": 0.8882085129809085,
    "person_role_id": 0.913356465035109,
    "nr_order": 0.9999698435697951,
    "role_id": 0.9999997240948746
  },
  "char_name": {
    "id": 0.0,
    "imdb_id": 1
  },
  "comp_cast_type": {
    "id": 0.0
  },
  "company_name": {
    "id": 0.0,
    "imdb_id": 1
  },
  "company_type": {
    "id": 0.0
  },
  "complete_cast": {
    "id": 0.0,
    "movie_id": 0.30774697412740126,
    "subject_id": 0.999992597253581,
    "status_id": 0.999992597253581
  },
  "info_type": {
    "id": 0.0
  },
  "keyword": {
    "id": 0.0
  },
  "kind_type": {
    "id": 0.0
  },
  "link_type": {
    "id": 0.0
  },
  "movie_companies": {
    "id": 0.0,
    "movie_id": 0.5832956451350796,
    "company_id": 0.9099331270830714,
    "company_type_id": 0.9999996167301872
  },
  "movie_info": {
    "id": 0.0,
    "movie_id": 0.8335891910597659,
    "info_type_id": 0.9999952816577343
  },
  "movie_info_idx": {
    "id": 0.0,
    "movie_id": 0.6667299501316635,
    "info_type_id": 0.9999971015206872
  },
  "movie_keyword": {
    "id": 0.0,
    "movie_id": 0.894606436131071,
    "keyword_id": 0.9703423727472292
  },
  "movie_link": {
    "id": 0.0,
    "movie_id": 0.7863048406454194,
    "linked_movie_id": 0.4609947993065742,
    "link_type_id": 0.9994999333244433
  },
  "name": {
    "id": 0.0,
    "imdb_id": 1
  },
  "person_info": {
    "id": 0.0,
    "person_id": 0.8141759032656547,
    "info_type_id": 0.999992914174115
  },
  "role_type": {
    "id": 0.0
  },
  "title": {
    "id": 0.0,
    "kind_id": 0.999998022395188,
    "production_year": 0.9999481867539238,
    "imdb_id": 1,
    "episode_of_id": 0.979638580854966,
    "season_nr": 0.9999624255085707,
    "episode_nr": 0.9941047600552305
  },
  "an": {
    "id": 0.0,
    "person_id": 0.3473942188425703
  },
  "at": {
    "id": 0.0,
    "movie_id": 0.43113002149550034,
    "kind_id": 0.9999861676317049,
    "production_year": 0.9996486578453043,
    "episode_of_id": 0.9979168453347571,
    "season_nr": 0.9998921075272982,
    "episode_nr": 0.9995545977408976
  },
  "ci": {
    "id": 0.0,
    "movie_id": 0.9356699609646669,
    "person_id": 0.8882085129809085,
    "person_role_id": 0.913356465035109,
    "nr_order": 0.9999698435697951,
    "role_id": 0.9999997240948746
  },
  "chn": {
    "id": 0.0,
    "imdb_id": 1
  },
  "cct": {
    "id": 0.0
  },
  "cn": {
    "id": 0.0,
    "imdb_id": 1
  },
  "ct": {
    "id": 0.0
  },
  "cc": {
    "id": 0.0,
    "movie_id": 0.30774697412740126,
    "subject_id": 0.999992597253581,
    "status_id": 0.999992597253581
  },
  "it": {
    "id": 0.0
  },
  "k": {
    "id": 0.0
  },
  "kt": {
    "id": 0.0
  },
  "lt": {
    "id": 0.0
  },
  "mc": {
    "id": 0.0,
    "movie_id": 0.5832956451350796,
    "company_id": 0.9099331270830714,
    "company_type_id": 0.9999996167301872
  },
  "mi": {
    "id": 0.0,
    "movie_id": 0.8335891910597659,
    "info_type_id": 0.9999952816577343
  },
  "mi_idx": {
    "id": 0.0,
    "movie_id": 0.6667299501316635,
    "info_type_id": 0.9999971015206872
  },
  "miidx": {
    "id": 0.0,
    "movie_id": 0.6667299501316635,
    "info_type_id": 0.9999971015206872
  },
  "mk": {
    "id": 0.0,
    "movie_id": 0.894606436131071,
    "keyword_id": 0.9703423727472292
  },
  "ml": {
    "id": 0.0,
    "movie_id": 0.7863048406454194,
    "linked_movie_id": 0.4609947993065742,
    "link_type_id": 0.9994999333244433
  },
  "n": {
    "id": 0.0,
    "imdb_id": 1
  },
  "pi": {
    "id": 0.0,
    "person_id": 0.8141759032656547,
    "info_type_id": 0.999992914174115
  },
  "rt": {
    "id": 0.0
  },
  "t": {
    "id": 0.0,
    "kind_id": 0.999998022395188,
    "production_year": 0.9999481867539238,
    "imdb_id": 1,
    "episode_of_id": 0.979638580854966,
    "season_nr": 0.9999624255085707,
    "episode_nr": 0.9941047600552305
  }
}


MIN_MD = {
  "aka_name": {
    "id": 1,
    "person_id": 4
  },
  "aka_title": {
    "id": 1,
    "movie_id": 0,
    "kind_id": 1,
    "production_year": 1888,
    "episode_of_id": 10,
    "season_nr": 1,
    "episode_nr": 1
  },
  "cast_info": {
    "id": 1,
    "movie_id": 1,
    "person_id": 1,
    "person_role_id": 1,
    "nr_order": 0,
    "role_id": 1
  },
  "char_name": {
    "id": 1,
    "imdb_id": 0
  },
  "comp_cast_type": {
    "id": 1
  },
  "company_name": {
    "id": 1,
    "imdb_id": 0
  },
  "company_type": {
    "id": 1
  },
  "complete_cast": {
    "id": 1,
    "movie_id": 285,
    "subject_id": 1,
    "status_id": 3
  },
  "info_type": {
    "id": 1
  },
  "keyword": {
    "id": 1
  },
  "kind_type": {
    "id": 1
  },
  "link_type": {
    "id": 1
  },
  "movie_companies": {
    "id": 1,
    "movie_id": 2,
    "company_id": 1,
    "company_type_id": 1
  },
  "movie_info": {
    "id": 1,
    "movie_id": 1,
    "info_type_id": 1
  },
  "movie_info_idx": {
    "id": 1,
    "movie_id": 2,
    "info_type_id": 99
  },
  "movie_keyword": {
    "id": 1,
    "movie_id": 2,
    "keyword_id": 1
  },
  "movie_link": {
    "id": 1,
    "movie_id": 2,
    "linked_movie_id": 284,
    "link_type_id": 1
  },
  "name": {
    "id": 1,
    "imdb_id": 0
  },
  "person_info": {
    "id": 1,
    "person_id": 4,
    "info_type_id": 15
  },
  "role_type": {
    "id": 1
  },
  "title": {
    "id": 1,
    "kind_id": 1,
    "production_year": 1880,
    "imdb_id": 0,
    "episode_of_id": 2,
    "season_nr": 1,
    "episode_nr": 1
  },
  "an": {
    "id": 1,
    "person_id": 4
  },
  "at": {
    "id": 1,
    "movie_id": 0,
    "kind_id": 1,
    "production_year": 1888,
    "episode_of_id": 10,
    "season_nr": 1,
    "episode_nr": 1
  },
  "ci": {
    "id": 1,
    "movie_id": 1,
    "person_id": 1,
    "person_role_id": 1,
    "nr_order": 0,
    "role_id": 1
  },
  "chn": {
    "id": 1,
    "imdb_id": 0
  },
  "cct": {
    "id": 1
  },
  "cn": {
    "id": 1,
    "imdb_id": 0
  },
  "ct": {
    "id": 1
  },
  "cc": {
    "id": 1,
    "movie_id": 285,
    "subject_id": 1,
    "status_id": 3
  },
  "it": {
    "id": 1
  },
  "k": {
    "id": 1
  },
  "kt": {
    "id": 1
  },
  "lt": {
    "id": 1
  },
  "mc": {
    "id": 1,
    "movie_id": 2,
    "company_id": 1,
    "company_type_id": 1
  },
  "mi": {
    "id": 1,
    "movie_id": 1,
    "info_type_id": 1
  },
  "miidx": {
    "id": 1,
    "movie_id": 2,
    "info_type_id": 99
  },
  "mi_idx": {
    "id": 1,
    "movie_id": 2,
    "info_type_id": 99
  },
  "mk": {
    "id": 1,
    "movie_id": 2,
    "keyword_id": 1
  },
  "ml": {
    "id": 1,
    "movie_id": 2,
    "linked_movie_id": 284,
    "link_type_id": 1
  },
  "n": {
    "id": 1,
    "imdb_id": 0
  },
  "pi": {
    "id": 1,
    "person_id": 4,
    "info_type_id": 15
  },
  "rt": {
    "id": 1
  },
  "t": {
    "id": 1,
    "kind_id": 1,
    "production_year": 1880,
    "imdb_id": 0,
    "episode_of_id": 2,
    "season_nr": 1,
    "episode_nr": 1
  }
}


MAX_MD = {
  "aka_name": {
    "id": 901343,
    "person_id": 4167489
  },
  "aka_title": {
    "id": 377960,
    "movie_id": 2525672,
    "kind_id": 7,
    "production_year": 2016,
    "episode_of_id": 25391,
    "season_nr": 63,
    "episode_nr": 4315
  },
  "cast_info": {
    "id": 36244344,
    "movie_id": 2525975,
    "person_id": 4061926,
    "person_role_id": 3140339,
    "nr_order": 1115798165,
    "role_id": 11
  },
  "char_name": {
    "id": 3140339,
    "imdb_id": 0
  },
  "comp_cast_type": {
    "id": 4
  },
  "company_name": {
    "id": 234997,
    "imdb_id": 0
  },
  "company_type": {
    "id": 4
  },
  "complete_cast": {
    "id": 135086,
    "movie_id": 2528312,
    "subject_id": 2,
    "status_id": 4
  },
  "info_type": {
    "id": 113
  },
  "keyword": {
    "id": 134170
  },
  "kind_type": {
    "id": 7
  },
  "link_type": {
    "id": 18
  },
  "movie_companies": {
    "id": 2609129,
    "movie_id": 2525745,
    "company_id": 234997,
    "company_type_id": 2
  },
  "movie_info": {
    "id": 14835720,
    "movie_id": 2526430,
    "info_type_id": 110
  },
  "movie_info_idx": {
    "id": 1380035,
    "movie_id": 2525793,
    "info_type_id": 113
  },
  "movie_keyword": {
    "id": 4523930,
    "movie_id": 2525971,
    "keyword_id": 134170
  },
  "movie_link": {
    "id": 29997,
    "movie_id": 186175,
    "linked_movie_id": 2524994,
    "link_type_id": 17
  },
  "name": {
    "id": 4167491,
    "imdb_id": 0
  },
  "person_info": {
    "id": 2963664,
    "person_id": 4167491,
    "info_type_id": 39
  },
  "role_type": {
    "id": 12
  },
  "title": {
    "id": 2528312,
    "kind_id": 7,
    "production_year": 2019,
    "imdb_id": 0,
    "episode_of_id": 2528186,
    "season_nr": 2013,
    "episode_nr": 91821
  },
  "an": {
    "id": 901343,
    "person_id": 4167489
  },
  "at": {
    "id": 377960,
    "movie_id": 2525672,
    "kind_id": 7,
    "production_year": 2016,
    "episode_of_id": 25391,
    "season_nr": 63,
    "episode_nr": 4315
  },
  "ci": {
    "id": 36244344,
    "movie_id": 2525975,
    "person_id": 4061926,
    "person_role_id": 3140339,
    "nr_order": 1115798165,
    "role_id": 11
  },
  "chn": {
    "id": 3140339,
    "imdb_id": 0
  },
  "cct": {
    "id": 4
  },
  "cn": {
    "id": 234997,
    "imdb_id": 0
  },
  "ct": {
    "id": 4
  },
  "cc": {
    "id": 135086,
    "movie_id": 2528312,
    "subject_id": 2,
    "status_id": 4
  },
  "it": {
    "id": 113
  },
  "k": {
    "id": 134170
  },
  "kt": {
    "id": 7
  },
  "lt": {
    "id": 18
  },
  "mc": {
    "id": 2609129,
    "movie_id": 2525745,
    "company_id": 234997,
    "company_type_id": 2
  },
  "mi": {
    "id": 14835720,
    "movie_id": 2526430,
    "info_type_id": 110
  },
  "miidx": {
    "id": 1380035,
    "movie_id": 2525793,
    "info_type_id": 113
  },
  "mi_idx": {
    "id": 1380035,
    "movie_id": 2525793,
    "info_type_id": 113
  },
  "mk": {
    "id": 4523930,
    "movie_id": 2525971,
    "keyword_id": 134170
  },
  "ml": {
    "id": 29997,
    "movie_id": 186175,
    "linked_movie_id": 2524994,
    "link_type_id": 17
  },
  "n": {
    "id": 4167491,
    "imdb_id": 0
  },
  "pi": {
    "id": 2963664,
    "person_id": 4167491,
    "info_type_id": 39
  },
  "rt": {
    "id": 12
  },
  "t": {
    "id": 2528312,
    "kind_id": 7,
    "production_year": 2019,
    "imdb_id": 0,
    "episode_of_id": 2528186,
    "season_nr": 2013,
    "episode_nr": 91821
  }
}


REL_MD = {
	'aka_name'			:		['id', 'person_id'],
	'an'				:		['id', 'person_id'],
	'aka_title'			:		['id', 'movie_id', 'kind_id', 'production_year', 'episode_of_id', 'season_nr', 'episode_nr'],
	'at'				:		['id', 'movie_id', 'kind_id', 'production_year', 'episode_of_id', 'season_nr', 'episode_nr'],
	'cast_info'			:		['id', 'movie_id', 'person_id', 'person_role_id', 'nr_order', 'role_id'],
	'ci'				:		['id', 'movie_id', 'person_id', 'person_role_id', 'nr_order', 'role_id'],
	'char_name'			:		['id', 'imdb_id'],
	'chn'				:		['id', 'imdb_id'],
	'comp_cast_type'	:		['id'],
	'cct'				:		['id'],
	'company_name'		:		['id', 'imdb_id'],
	'cn'				:		['id', 'imdb_id'],
	'company_type'		:		['id'],
	'ct'				:		['id'],
	'complete_cast'		:		['id', 'movie_id', 'subject_id', 'status_id'],
	'cc'				:		['id', 'movie_id', 'subject_id', 'status_id'],
	'info_type'			:		['id'],
	'it'				:		['id'],
	'keyword'			:		['id'],
	'k'					:		['id'],
	'kind_type'			:		['id'],
	'kt'				:		['id'],
	'link_type'			:		['id'],
	'lt'				:		['id'],
	'movie_companies'	:		['id', 'movie_id', 'company_id', 'company_type_id'],
	'mc'				:		['id', 'movie_id', 'company_id', 'company_type_id'],
	'movie_info'		:		['id', 'movie_id', 'info_type_id'],
	'mi'				:		['id', 'movie_id', 'info_type_id'],
	'movie_info_idx'	:		['id', 'movie_id', 'info_type_id'],
	'miidx'				:		['id', 'movie_id', 'info_type_id'],
	'mi_idx'			:		['id', 'movie_id', 'info_type_id'],
	'movie_keyword'		:		['id', 'movie_id', 'keyword_id'],
	'mk'				:		['id', 'movie_id', 'keyword_id'],
	'movie_link'		:		['id', 'movie_id', 'linked_movie_id', 'link_type_id'],
	'ml'				:		['id', 'movie_id', 'linked_movie_id', 'link_type_id'],
	'name'				:		['id', 'imdb_id'],
	'n'					:		['id', 'imdb_id'],
	'person_info'		:		['id', 'person_id', 'info_type_id'],
	'pi'				:		['id', 'person_id', 'info_type_id'],
	'role_type'			:		['id'],
	'rt'				:		['id'],
	'title'				:		['id', 'kind_id', 'production_year', 'imdb_id', 'episode_of_id', 'season_nr', 'episode_nr'],
	't'					:		['id', 'kind_id', 'production_year', 'imdb_id', 'episode_of_id', 'season_nr', 'episode_nr']
}

ALIAS_MD = {
	'aka_name'			:		'an',
	'an'				:		'aka_name',
	'aka_title'			:		'at',
	'at'				:		'aka_title',
	'cast_info'			:		'ci',
	'ci'				:		'cast_info',
	'char_name'			:		'chn',
	'chn'				:		'char_name',
	'comp_cast_type'	:		'cct',
	'cct'				:		'comp_cast_type',
	'company_name'		:		'cn',
	'cn'				:		'company_name',
	'company_type'		:		'ct',
	'ct'				:		'company_type',
	'complete_cast'		:		'cc',
	'cc'				:		'complete_cast',
	'info_type'			:		'it',
	'it'				:		'info_type',
	'keyword'			:		'k',
	'k'					:		'keyword',
	'kind_type'			:		'kt',
	'kt'				:		'kind_type',
	'link_type'			:		'lt',
	'lt'				:		'link_type',
	'movie_companies'	:		'mc',
	'mc'				:		'movie_companies',
	'movie_info'		:		'mi',
	'mi'				:		'movie_info',
	'movie_info_idx'	:		'miidx',
	'miidx'				:		'movie_info_idx',
	'mi_idx'			:		'movie_info_idx',
	'movie_keyword'		:		'mk',
	'mk'				:		'movie_keyword',
	'movie_link'		:		'ml',
	'ml'				:		'movie_link',
	'name'				:		'n',
	'n'					:		'name',
	'person_info'		:		'pi',
	'pi'				:		'person_info',
	'role_type'			:		'rt',
	'rt'				:		'role_type',
	'title'				:		't',
	't'					:		'title'
}

#metadata for join
UNIQUE_ATTRIBUTES_MD = {
	'company_type'		:		['id','kind'],
	'comp_cast_type'	:		['id','kind'],
	'kind_type'			:		['id','kind'],
	'role_type'			:		['id', 'role'],
	'link_type'			:		['id', 'link'],
	'info_type'			:		['id', 'info'],
	'movie_link'		:		['id'],
	'keyword'			:		['id'],
	'complete_cast'		:		['id'],
	'company_name'		:		['id'],
	'aka_title'			:		['id'],
	'aka_name'			:		['id'],
	'movie_info_idx'	:		['id'],
	'title'				:		['id'],
	'movie_companies'	:		['id'],
	'person_info'		:		['id'],
	'char_name'			:		['id'],
	'name'				:		['id'],
	'movie_keyword'		:		['id'],
	'movie_info'		:		['id'],
	'cast_info'			:		['id']
}

if __name__ == "__main__":

	for key in REL_MD:
		print(key)