Ad

Tuesday, February 18, 2020

Neo4j Graph Database Basics 2021-2022

Neo4j models graphs - relationships (edges) of nodes. It is in contrast with Relational Database, traditional tabular database. SQL Joints are expensive, costly, and hard-to-learn (confusing for analysts).  

Graph: a collection of nodes (Vertices) and relationships (Edges) that connect them. The math symbol of it is G(V, E). 

Graph data is everywhere in real life. It is intuitive to model real world data using graph models.

UI - Neo4j Browser

Neo4j Browser is the query workbench using JavaScript bolt under the hood. Bolt is a binary protocol, a fast one, Neo4j uses for connections. 


Data Modeling

First step of getting started with graph database is to model the data in a graph. It is important to model and store data as a graph. 

Neo4j uses a property graph model. 

Neo4j can store direction one way but can query either ways. There are four main elements: node, can be labeled, similar to SQL table name, can have key property value pairs. Property can go on node or labels. 

Node
Relationship
Labels 

Data modeling can be done with a white board or using apjones Arrows App 

Relationship edge can also have property associated with it. 

Cypher

Cypher is the language developers use to make queries against a graph / retrieve information from a graph. It also controls what results are returned. Developers also use cypher to create nodes and relationships, modify nodes and relationships in a graph. 
Neo4j cypher query executed in session get back cursor of records

Cypher is an open sourced graph database query language, a part of the open cypher project. Other graph databases use cypher too. Not just Neo4j

Cypher versus SQL Comparison

MATCH ~= FROM
WHERE ~= WHERE
RETURN ~= SELECT

View Schema

Call apoc to view schema
https://neo4j.com/developer/kb/viewing-schema-data-with-apoc/

WHERE CLAUSE allows developers to filter nodes and relationships. 

CRUD with Cypher Neo4j

SELECT STATEMENT
SELECT all nodes
MATCH (n)
RETURN n

SELECT all nodes with a specific label
MATCH (n:Label)
RETURN n

Match all relationships in neo4j graph
MATCH(m)--(n)
RETURN m, n

Neo4j create statement
CREATE(nodefirst:Label {propertname:"Property Name", propertyagain:99999})
CREATE (nodeagain)-[:REL_TO { roleproperty: ["List Item"]}]->(nodefirst)

Merge operation: equivalent of a SQL update, first look up if node exists, if not create it, don't create duplicates / new record if a record already exists. Get or Create.  

Call - cypher keyword to call functions and procedures

Read more about user defined procedures source 11

You try write and customize your own procedure
Cypher styling and query guide source 12

Graph database can also be queried and modeled using ORMs. 



APOC

Neo4j procedures (apoc) are community driven code modules. There are high quality NLP apoc procedures for Neo4j. 

"Just in time for GraphConnect, Michael released version 3.4.0.3 of the popular APOC library. This release has support for defining custom procedures and functions implemented in plain Cypher and then calling them like regular ones, as well as a new procedure for scraping web pages" - May 2020 

11- https://neo4j.com/docs/java-reference/current/extending-neo4j/procedures-and-functions/procedures/
12- https://neo4j.com/docs/cypher-manual/current/styleguide/
Use cases for Neo4j:
Salmon researchers, salmon hatchling in northern atmosphere, knowledge graph, information management.
Graphs, in general, is great for highly connected data. 
Neo4j for journalist
Panama paper is available as a sandbox dataset
Investigative journalist: panama paper paradise paper
Relationship model can be super insightful in data analysis and for relationship modeling, Neo4j is great.



Can even use graph for chemicals drug discovery



Use for recommendation collaborative filtering



Fraud prevention











Use graph when context matters. How did the data result happen?







Graphing interaction data is also very useful. Relationship data is important.







Neo4j lead data scientist Alicia Frame PhD talks works on graph algorithms







Learn Neo4j (Neo4j Tutorials)

Neo4j Sandbox Feature : Neo4j tutorials can be run in Neo4j Sandboxes

Use :play to launch Neo4j tutorials

Using the :play feature in Neo4j sandbox and sandbox datasets, you can give your cypher skill a try and get started with Neo4j. It is insightful, easy and a lot of fun.

You can create your own Neo4j Browser Guide (tutorial). 

Graph Academy


Neo4j 4.0

Advanced Neo4j Experts

You can become a Neo4j Ninja, Neo4j expert, and join the Neo4j Speaker Program. Neo4j investigative journalism program

Certification available

Neo4j Community and Neo4j Universe

"GraphXR is a browser-based visual analytics platform that delivers unprecedented speed, power, and fluidity to anyone working with connected, high-dimensional, and big data." GraphXR in its own words.

Become a super user
Become a Neo4j Ninja
 
Load CSV

GRANDSTACK - Hosting Neo4j Website

Neo4j Desktop : allows managing multiple projects databases
Neo4j Graph Apps: graph apps are applications that interact with Neo4j database through the desktop app. Graph apps are single page applications (SPAs) that are built with vanilla JavaScript or front end web development frameworks. 


Advanced Algorithms with Neo4j  | Advanced Graph Algorithms
The study of graph theory and graph algorithms is set to be pioneered by Euler.  The interesting problem The Seven Bridges of Königsberg is solved using graph concepts. 

Use call to launch Neo4j helper functions, stored procs, and algorithms

Algorithms:
Page Rank


Neo4j NLP library

Launch Neo4j on google cloud

Can host a Neo4j graph database and deploy using GKE. 

Launching Neo4j on Google Kubernetes Market Place
 https://medium.com/google-cloud/launching-neo4j-on-googles-kubernetes-marketplace-97c23c94e960
Neo4j prefers SSDs.
A strong password is automatically chosen. Not neo4j's typical default.
Retrieve it in cloud shell. 
 $ kubectl get secrets my-graph-neo4j-secrets -o yaml | grep neo4j-password: | sed 's/.*neo4j-password: *//' | base64 --decode
3lg81oVvGY



Graph Academy | Getting Certified
Certification exam 
Duration 1 hour 80 questions
Introduction to Neo4j Online Course and Tutorial
Duration 1 day
Course Outline
Introduction to Graph Databases
Introduction to Neo4j
Setting up your Development Environment Tutorial
Introduction to Cypher
Getting More out of Queries
Creating Nodes and Relationships
Getting More out of Neo4j

graphaware has plugin for tokenization
3rd party natural language processing platform for neo4j graphs

Using Python with Neo4j py2neo

No comments:

Post a Comment

React UI, UI UX, Reactstrap React Bootstrap

React UI MATERIAL  Install yarn add @material-ui/icons Reactstrap FORMS. Controlled Forms. Uncontrolled Forms.  Columns, grid