Skip to content

Latest commit

 

History

History
74 lines (54 loc) · 2.75 KB

04.md

File metadata and controls

74 lines (54 loc) · 2.75 KB

Neo4J

In this assignment, we will play with graph databases and airport data.

Load the data

Last time I tried this assignment, some had trouble loading the data. So, I will give you a few ways to load the data. We will use the data set from neo4j site

Way 1: Use DB that I setup

Copy and paste is the easiest way, but it crashes a lot of computers. But, give it a try!

Download and unzip the flights file. Open the file in your favorite text editor. Copy and paste the create command into your browser (as we did in class). Wait a little bit for it to paste and run the command.

Hopefully that worked!

Way 2: Use DB that I setup

This is a little more work, but you will learn a bit about how neo4j handles files. Warning You must do this when Neo4J is NOT running.

Download the flights database and put it in the correct place:

tar xvzf flights.db.tgz
mv flights.db <Root of Course Repo>/env/neo4j/data/databases
cd <Root of Course Repo>/env/neo4j/data/databases
mv graph.db graph.db.bak
mv flights.db graph.db

Start Neo4J

cd env/neo4j
docker run \
    -p 7474:7474 -p 7687:7687 \
    -v ${PWD}/data:/data \
    -e NEO4J_AUTH=none adv-db/neo4j

If all goes well, you should be good to go.

Answer queries

For the assignment, feel free to work in the browser, the shell, or via REST (or try them all). You will provide queries for the following:

  1. Write a query that will list all the airports in the graph.
  2. Write a query that will report the number of airports in the graph.
  3. Bozeman's airport code is "BZN". Write a query that tells you if Bozeman is in the list. Do not manually look through the list in the previous problem.
  4. Write a query that reports if Helena in the list.
  5. For the previous two questions, try to write your query for Helena and Bozeman so that the only change to the query is the airport code. (For reference Bozeman is in the data set and Helena is not (because Bozeman rocks!)
  6. When I wrote this assignment, I was on a very long flight to Washington Dulles (airport code IAD). According to our data set, what is the shortest path that I could have gone (in terms of number of hops)? (Do not worry about origin and destination.)
  7. I used to live in NYC (near Laguardia Airport), how many flight options would I have from Laguardia (LGA) to Dulles (IAD). (Hint check out allShortestPaths.)
  8. For each airpoort a, get the average ticket cost of flying to a.

Submission

Put all your queries in a file called queries.cypher put all content for submission in a folder neo4j-lab. Tar and gzip the folder (eg tar cvzf neo4j-lab.tgz neo4j-lab) and submit on D2L.