Cookies help us deliver our services. By using our services, you agree to our use of cookies. More information

MAPREDUCE Elite

From NoSQLZoo
Revision as of 14:23, 22 July 2015 by 40166222 (talk | contribs) (Created page with "<pre class=setup> #ENCODING import io import sys sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-16') #MONGO from pymongo import MongoClient client = MongoClien...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
#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

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

The average document in commodities looks something like this.

{
        "_id" : ObjectId("55af74e7402aa43f1ce7e3a3"),
        "name" : "Explosives",
        "average_price" : 267,
        "category" : "Chemicals"
}

Whilst the average document in systems looks like this. This example only has one station for readability.

{
        "_id" : ObjectId("55af74ee369fd56a7387891d"),
        "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,
        "power_control_faction" : null,
        "state" : "None",
        "needs_permit" : 0,
        "y" : -83.53125,
        "x" : 80.90625,
        "security" : "Medium",
        "z" : -30.8125,
        "primary_economy" : "Industrial",
        "id" : 1,
        "population" : 6544826
}