Giter VIP home page Giter VIP logo

neo4j-fleets's Introduction

A neo4j database of airline fleets.

Database structure.

The nodes and relationships in the graph are summarized below.

Graph Structure

Node Label Node Properties
Airline name*, status (Active or Inactive)
Country name*
Series name*
Model name*
Aircraft msn (manufacturer's serial number), ff_day, ff_month, ff_year (day, month, year of first flight), registration (registration code), status (Active, Scrapped, Stored, Written off, On order, or Unknown)

* There is a uniqueness constraint on this property for the given node label.

None of the relationships in the graph have any properties.

Get the database dump.

The already-created database is located in fleets.graphdb.zip.

Create the database from scratch.

Alternatively, to create the database from scratch, do the following in the given order:

  • Execute scrape_airlines.py. This will create a 180KB file airlines_raw.csv in the current directory.
  • Execute scrape_aircraft.py. This will create a 2,181KB file aircraft_raw.csv in the current directory.
  • Execute clean.py. This will create a 98KB file airlines_clean.csv and a 2,140KB file aircraft_clean.csv in the current directory. The raw datasets airlines_raw.csv and aircraft_raw.csv can be deleted by uncommenting os.remove() (lines 41 and 42) in clean.py. Or you can just delete them. :)

Before going on to the below steps, make sure Neo4j is up and running at http://localhost:7474/db/data. If the URL is something else, change the value of this string at line 5 of the following files.

  • Execute load_airlines.py.
  • Execute load_aircraft.py.

After these scripts complete, the database should be fully populated.

Example queries.

Which airlines own the most active Boeing 747s (top 10)? How many do they own? In which countries are these airlines based?

MATCH (c:Country)<-[:BASED_IN]-(a:Airline)<-[:OWNED_BY]-(:Aircraft {status:'Active'})-[:SERIES]->()-[:MODEL]->(m:Model {name:'Boeing 747'})
WITH a, COUNT(m) AS count, c
ORDER BY count DESC
RETURN a.name AS Airline, c.name AS Country, count AS `Number of Boeing 747 Owned`
LIMIT 10

Query 1

Visualize all the Airbus aircraft owned by Lufthansa.

MATCH p = (:Airline {name:'Lufthansa'})<-[:OWNED_BY]-(:Aircraft)-[:SERIES]->(:Series)-[:MODEL]->(m:Model)
WHERE substring(m.name, 0 , 6) = 'Airbus'
RETURN p

Query 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.