CMSI 486: Welcome to Week 11

This Week's Class Agenda

What's Going On This Week

  1. Introduction to Neo4J
  2. Some fun queries
  3. Project SCRUMS

Introduction to Neo4J

Last week we delved into the basics of graph databases based on the O'Reilly book, which is freely available [as you may remember] from the neo website and also is on my git. We saw some of the basics of neo, and how the Cypher query language works, using the idea of ASCII art to show relationshipe, nodes, and so on. Now it's time to get a bit deeper into things by actually doing some demonstrations.

Installation

First, download the community edition from the Neo4J website. When you visit this page, you'll see the download link, as you'd expect. when you click that, you'll get redirected to the initial page during the download which is here. This page is important, because it has installation and startup instructions. NOTE: on mac, the process is pretty much like anything else you install on mac, so just follow the directions that are provided. For Windows, it's just an .exe file, so you just virus scan it, then double click on it to start the installation process. Very straightforward. When the installation is complete, you'll see the happy little dialog box that says you've completed the installation. There's a checkbox that you can check [it may be opt-in] to start the server. You can do that, or elect to start it yourself as follows.

Next start the server using the windows start button, finding the installation folder, opening it, and clicking on the Neo4J Community Edition program. This will bring up a dialog box which will ask you to select a database directory to use. Just take the default for now, since you'll still get to play with it later. There is an options button on the page; clicking that will bring up [yet another] dialog from which you can get information on:

  1. neo4j.conf file location - C:\Users\Beej\AppData\Roaming\Neo4j Community Edition\neo4j.conf
  2. Java VM tuning - C:\Users\Beej\AppData\Roaming\Neo4j Community Edition\neo4j-community.vmoptions
  3. plugins and extensions - C:\Users\Beej\Documents\Neo4j\default.graphdb\plugins

This information is really just for your information at this point, so you can see where the configurations are stored. You can click the close button when you are done poking around, and the dialog will…

Next, click the start button, and the server will start up. However, you will not see any cool messages during start up like we saw in the server window with Mongo. Just the progress bar with turn yellow for a bit. When the server is ready for connections, the progress bar will turn green with envy. The light is green, the trap is clean…

Now, guess what? The interface to neo is through your browser! Open a browser and point it to the IP address http://127.0.0.1:7474 to get the neo log in page. The default credentials are username: neo4j and password: neo4j. Clever and secure, huh? Note that as soon as you log in the first time, you will be required to change your password. Pick something you'll remember because if you forget it you'll have to do all this over again. BTW, the server also responds to http://localhost:7474. You may have guessed that 7474 is the default port number.

Beginnings…

Once you are logged in, you'll see the basic start page. The top line of the web page is the command line. Type in commands here. The dollar sign [$] is the prompt. You can copy and paste into and out of it, and you can use the up and down arrows to recall previous commands [with a little fussing around, though]. You can type :help to get help on things. You can type :play <database> graph to access a database. You type :server disconnect to end your session and return to the login screen on your browser window.

Notice the colon character that precedes the commands. This is set up to differentiate between commands to the server [and the client] and commands that are Cypher queries.

When you run a query, the result opens a new canvas or sub-window in the browser. You can click and drag in the window to see different parts of the result. Much the same as in relational databases that return a table as a query result, neo often returns a graph as the result. In the result window, you can click on the tools at the left to get different views. There are colors that coordinate the different parts of the result. The blue color shows how many total nodes exist in that query result. Other colors show labeled items of the graph. For example, in the movie database [we'll see in a minute] the green color shows the "person" labeled nodes, and the red color shows the "movie" labeled nodes. Colors are automatically assigned, but can be changed at your discretion. You can close the result window when the query is complete if you like or you can leave it open. You can also roll it up. Because this is a browser, you can have as many of these windows open as you like.

We will create the movie graph database using the code provided with our installation. In the command line, you can type in your commands, or just click on the command in the browser window if running a demo or if you have a previous command result available. Simply clicking a command puts it into the command line. You can click the "play" button on the command line to execute the command, or click the "x" button to clear the command line. You click the "star" button to "favorite" a query. Note that because the query isn't executed until you click the play button, you can have multiple lines to be done at the same time. The result window includes the Cypher query; clicking on THAT will put the query back into the command line at the top again. Each query pane has a "close" button so you can either leave it open or close it as needed

Some fun queries

Now it's time for your favorite TV Game show: Six Degrees of Kevin Bacon!!

Here are some sample queries that we can run on the movie database and see how things work. Feel free to stop me for experimentation as we go through these. Although I'm still a neo-phyte [get it?!?] we can play around with things and all of us can learn.

Some complex queries

The chapter in your Neo text book about recommender systems has some very interesting queries. This kind of system is used in businesses to model product relationships, to recommend products to customers, and to detect fraud. Such systems consist of two main pieces:

We will look at a neo example for this from your text book, chapter 6, starting on page 115. This example shows a simple database that contains:

  1. ten products, spread over…
  2. three product brands, and…
  3. fifty relationships between people who bought the products

We'll look at the database, the data, and several simple and complex queries used to pattern match and extract recommendation data.

SCRUM: Project teams

  1. Arteaga, Peters, & West
  2. Bahar & Garcia
  3. Bennett & Mikol
  4. Boyac, Li, & Lopez
  5. Braekman, Persily, & Wroblewski
  6. Crowther, Rajavasireddy, & Simmons
  7. Derham & Ochsner
  8. Filler & Zafiris
  9. Jay & Nguyen & Prochnow
  10. Kern & Lizarda & Moini
  11. Martin
  12. Flora & Namba & Santander
  13. Nguyen & Ruiz & Tollive
  14. Patterson & Richardson
  15. Raymundo & Swaminarayan
  16. Kang & Patterson
  17. Wiggins