Difference between revisions of "Read the notes about this table."

From SQLZOO
Jump to: navigation, search
Line 5: Line 5:
 
   <li>The first record is <code>Afghanistan</code> in <code>Asia</code> </li>  
 
   <li>The first record is <code>Afghanistan</code> in <code>Asia</code> </li>  
 
   <li>The final record is <code>Zimbabwe</code> in <code>Africa</code>.</li>  
 
   <li>The final record is <code>Zimbabwe</code> in <code>Africa</code>.</li>  
   <li>The table has five columns or <code>attributes</code> . These are:  
+
   <li>The table has eight columns or <code>attributes</code> . These are:  
<table class="sqlmine"><tbody><tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th><th>Default</th><th>Extra</th></tr><tr><td>name</td><td>varchar(50)</td><td>NO</td><td>PRI</td><td class="r">null</td><td class="r"></td></tr><tr><td>continent</td><td>varchar(60)</td><td>YES</td><td>MUL</td><td class="r">null</td><td class="r"></td></tr><tr><td>area</td><td>decimal(10,0)</td><td>YES</td><td></td><td class="r">null</td><td class="r"></td></tr><tr><td>population</td><td>decimal(11,0)</td><td>YES</td><td></td><td class="r">null</td><td class="r"></td></tr><tr><td>gdp</td><td>decimal(14,0)</td><td>YES</td><td></td><td class="r">null</td><td class="r"></td></tr><tr><td>capital</td><td>varchar(60)</td><td>YES</td><td></td><td class="r">null</td><td class="r"></td></tr><tr><td>tld</td><td>varchar(5)</td><td>YES</td><td></td><td class="r">null</td><td class="r"></td></tr><tr><td>flag</td><td>varchar(255)</td><td>YES</td><td></td><td class="r">null</td><td class="r"></td></tr></tbody></table>
+
<table class="sqlmine">
 +
<tbody><tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th><th>Default</th><th>Extra</th></tr><tr><td>name</td><td>varchar(50)</td><td>NO</td><td>PRI</td><td class="r">null</td><td class="r"></td></tr><tr><td>continent</td><td>varchar(60)</td><td>YES</td><td>MUL</td><td class="r">null</td><td class="r"></td></tr><tr><td>area</td><td>decimal(10,0)</td><td>YES</td><td></td><td class="r">null</td><td class="r"></td></tr><tr><td>population</td><td>decimal(11,0)</td><td>YES</td><td></td><td class="r">null</td><td class="r"></td></tr><tr><td>gdp</td><td>decimal(14,0)</td><td>YES</td><td></td><td class="r">null</td><td class="r"></td></tr><tr><td>capital</td><td>varchar(60)</td><td>YES</td><td></td><td class="r">null</td><td class="r"></td></tr><tr><td>tld</td><td>varchar(5)</td><td>YES</td><td></td><td class="r">null</td><td class="r"></td></tr><tr><td>flag</td><td>varchar(255)</td><td>YES</td><td></td><td class="r">null</td><td class="r"></td></tr></tbody></table>
 
   </li>
 
   </li>
 
</ul>
 
</ul>
  
  <h3>An extract from the table <code>bbc</code></h3>  
+
  <h3>An extract from the table <code>world</code></h3>  
 
<table border='1' id='usrResult0' ><tr>
 
<table border='1' id='usrResult0' ><tr>
 
<th>name</th>
 
<th>name</th>
Line 47: Line 48:
 
   <h2>Original source</h2>
 
   <h2>Original source</h2>
  
   <p>This data has been collected from the BBC country profiles - it
+
   <p>This data has been collected from http://www.wikidata.org - it
 
   may be a little out of date. The latest version can be found at  
 
   may be a little out of date. The latest version can be found at  
http://news.bbc.co.uk/1/hi/world/default.stm
 
 
Some changes have been made to the data - the reader should assume
 
Some changes have been made to the data - the reader should assume
   that errors and omissions are due to me and not the peerless BBC.</p>
+
   that errors and omissions are due to me and not the most excellent wikidata site.</p>
  
 
  <h2>Area</h2>
 
  <h2>Area</h2>
Line 59: Line 59:
 
   <h2>GDP</h2>
 
   <h2>GDP</h2>
  
  <p>I have taken the liberty of multiplying the GNI per capita (as published
+
  by the BBC) by the population. I am pretty sure that this is not correct
 
  but these tutorials are about databases not about economics.
 
  </p>
 
 
 
 
   <h2>Scientific Notation</h2>
 
   <h2>Scientific Notation</h2>
  

Revision as of 09:19, 13 September 2017

The world table.

Some points to note:

  • There is a table called world with nearly 200 records.
  • The first record is Afghanistan in Asia
  • The final record is Zimbabwe in Africa.
  • The table has eight columns or attributes . These are: <tbody></tbody>
    FieldTypeNullKeyDefaultExtra
    namevarchar(50)NOPRInull
    continentvarchar(60)YESMULnull
    areadecimal(10,0)YESnull
    populationdecimal(11,0)YESnull
    gdpdecimal(14,0)YESnull
    capitalvarchar(60)YESnull
    tldvarchar(5)YESnull
    flagvarchar(255)YESnull

An extract from the table world

name region area population gdp
Yemen Middle East 536869 21500000 12255000000
Zambia Africa 752614 11000000 4950000000
Zimbabwe Africa 390759 12900000 6192000000

Footnotes

Per Capita GDP

The per capita GDP is the GDP divided by the population. It is a rough measure of the average salary. A rich country is one with a high per capita GDP.

Original source

This data has been collected from http://www.wikidata.org - it may be a little out of date. The latest version can be found at Some changes have been made to the data - the reader should assume that errors and omissions are due to me and not the most excellent wikidata site.

Area

The area is measured in square kilometers.

GDP


Scientific Notation

Some implementations of SQL may show large numbers in scientific notation. The number 6.23 E9 means 6.23 x 10 9 which is 6.23 x 1,000,000,000 which is 6,230,000,000
A Million is 10 6 which is 1,000,000
A Billion is 10 9 which is one thousand million which is 1,000,000,000
A Trillion is 10 12 , which is one million million which is 1,000,000,000,000.


Language: English  • Deutsch