Difference between revisions of "MAPREDUCE Elite"
From NoSQLZoo
Line 13: | Line 13: | ||
pp = pprint.PrettyPrinter(indent=4) | pp = pprint.PrettyPrinter(indent=4) | ||
</pre> | </pre> | ||
− | ==Introducing the elite database== | + | ==Introducing the elite database **WORK IN PROGRESS== |
These questions will introduce the "elite" database, which contains data about the video game [https://www.elitedangerous.com/ Elite Dangerous]<br/> | These questions will introduce the "elite" database, which contains data about the video game [https://www.elitedangerous.com/ Elite Dangerous]<br/> | ||
There are two collections, <code>commodities</code> and <code>systems</code>. Inside <code>systems</code> there is are nested documents called <code>stations</code><br/> | There are two collections, <code>commodities</code> and <code>systems</code>. Inside <code>systems</code> there is are nested documents called <code>stations</code><br/> | ||
A <b>system</b> has many <b>stations</b>, and a <b>station</b> imports,exports, and bans many <b>commodities</b> | A <b>system</b> has many <b>stations</b>, and a <b>station</b> imports,exports, and bans many <b>commodities</b> | ||
<br/><br/> | <br/><br/> | ||
− | + | Though it could, <code>commodities</code> does not make use of nested documents and the average document looks something like this. | |
<pre> | <pre> | ||
{ | { | ||
Line 27: | Line 27: | ||
} | } | ||
</pre> | </pre> | ||
− | + | <code>systems</code> look like this. For readability this example only has one station. | |
<pre> | <pre> | ||
{ | { | ||
− | "_id" : ObjectId(" | + | "_id" : ObjectId("55afa14a369fd51c351f1cb8"), |
"stations" : [ | "stations" : [ | ||
{ | { | ||
Line 81: | Line 81: | ||
"allegiance" : "Empire", | "allegiance" : "Empire", | ||
"updated_at" : 1430931668, | "updated_at" : 1430931668, | ||
− | |||
"state" : "None", | "state" : "None", | ||
"needs_permit" : 0, | "needs_permit" : 0, | ||
Line 92: | Line 91: | ||
"population" : 6544826 | "population" : 6544826 | ||
} | } | ||
+ | |||
+ | </pre> | ||
+ | <div class=hint title="a full list of keys used in the elite dangerous database"> | ||
+ | <pre> | ||
+ | Commodities: "_id", "name", "average_price", "category" | ||
+ | Systems: | ||
+ | "_id", | ||
+ | "allegiance", | ||
+ | "faction", | ||
+ | "government", | ||
+ | "id", | ||
+ | "name", | ||
+ | "needs_permit", | ||
+ | "population", | ||
+ | "power_control_faction", | ||
+ | "primary_economy", | ||
+ | "security", | ||
+ | "state", | ||
+ | "stations", | ||
+ | "updated_at", | ||
+ | "x", | ||
+ | "y", | ||
+ | "z" | ||
+ | Systems.stations: | ||
+ | "allegiance", | ||
+ | "government", | ||
+ | "has_blackmarket", | ||
+ | "has_commodities", | ||
+ | "has_outfitting", | ||
+ | "has_rearm", | ||
+ | "has_refuel", | ||
+ | "has_repair", | ||
+ | "has_shipyard", | ||
+ | "import_commodities", | ||
+ | "export_commodities", | ||
+ | "max_landing_pad", | ||
+ | "name", | ||
+ | "state", | ||
+ | "updated_at", | ||
+ | quit | ||
</pre> | </pre> |
Revision as of 17:02, 22 July 2015
#ENCODING import io import sys sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-16') #MONGO from pymongo import MongoClient client = MongoClient() client.progzoo.authenticate('scott','tiger') db = client['progzoo'] #PRETTY import pprint pp = pprint.PrettyPrinter(indent=4)
Introducing the elite database **WORK IN PROGRESS
These questions will introduce the "elite" database, which contains data about the video game Elite Dangerous
There are two collections, commodities
and systems
. Inside systems
there is are nested documents called stations
A system has many stations, and a station imports,exports, and bans many commodities
Though it could, commodities
does not make use of nested documents and the average document looks something like this.
{ "_id" : ObjectId("55af74e7402aa43f1ce7e3a3"), "name" : "Explosives", "average_price" : 267, "category" : "Chemicals" }
systems
look like this. For readability this example only has one station.
{ "_id" : ObjectId("55afa14a369fd51c351f1cb8"), "stations" : [ { "max_landing_pad_size" : "L", "has_blackmarket" : 0, "has_commodities" : 0, "updated_at" : 1430931780, "id" : 5611, "has_outfitting" : 1, "government" : "Patronage", "state" : "None", "system_id" : 1, "has_shipyard" : 1, "type" : "Unknown Starport", "prohibited_commodities" : [ "Narcotics", "Combat Stabilisers", "Slaves", "Personal Weapons", "Battle Weapons", "Toxic Waste" ], "faction" : "Empire League", "has_rearm" : 1, "allegiance" : "Empire", "has_refuel" : 1, "name" : "Smoot Gateway", "export_commodities" : [ "Water Purifiers", "Bauxite", "Rutile" ], "listings" : [ ], "distance_to_star" : 4761, "import_commodities" : [ "Polymers", "Aluminium", "Leather" ], "economies" : [ "Extraction", "Industrial" ], "has_repair" : 1 } ], "name" : "1 G. Caeli", "faction" : "Empire League", "government" : "Patronage", "allegiance" : "Empire", "updated_at" : 1430931668, "state" : "None", "needs_permit" : 0, "y" : -83.53125, "x" : 80.90625, "security" : "Medium", "z" : -30.8125, "primary_economy" : "Industrial", "id" : 1, "population" : 6544826 }
Commodities: "_id", "name", "average_price", "category" Systems: "_id", "allegiance", "faction", "government", "id", "name", "needs_permit", "population", "power_control_faction", "primary_economy", "security", "state", "stations", "updated_at", "x", "y", "z" Systems.stations: "allegiance", "government", "has_blackmarket", "has_commodities", "has_outfitting", "has_rearm", "has_refuel", "has_repair", "has_shipyard", "import_commodities", "export_commodities", "max_landing_pad", "name", "state", "updated_at", quit