Efficient way of creating large table
I am trying to create a database of 3 continents (Africa, Asia and Europe), different number of countries from each and different number of languages spoken in each country. For example,
Continent-Country-Language
Africa - Egypt 开发者_运维知识库- Arabic
Africa - Egypt - English
Africa - Somalia - English
Asia - China - English
Asia - China - Mandarin
Asia - China - Cantonese
Asia - Japan - japanese
Asia - Iraq - Arabic
Europe - Germany - German
Europe - Belgium - Dutch
Europe - Belgium - French
The table above becomes incredibly huge if 5 continents, 150 countries and 2000 languages are used! In addition if each variable is linked to a single external link, the total work becomes so painful.
My question is how can I create such large table in a more efficient way?
TIA!
Don't.
Create five tables - one for continents, one for countries, one to link languages and countries, and finally one for languages.
Continent ContinentCountry Country CountryLanguage Language
------------ ---------------- ---------- --------------- -----------
continent_id <- continent_id name language_id -> language_id
name country_id -> country_id <- country_id name
This is called Database Normalization.
The goal of database normalization is to decompose relations with anomalies in order to produce smaller, well-structured relations.
From Wikipedia's article on Database Normalization.
精彩评论