0% found this document useful (0 votes)
56 views8 pages

9 Neo4j

Uploaded by

Leticia Campi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views8 pages

9 Neo4j

Uploaded by

Leticia Campi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Hi, Neo4j is excellent for modeling complex and connected data.

I mean, for recommendations, species intelligence, social computing, geospatial data,


system administration, logistics, time series, and more.
>> [SOUND] Here we have a sample of a graph database.
Alice is friend of Bob, who is friend of Zach, and Zach is also friend of Alice.
Zach loves Harriet and Ingrid.
Ingrid and Harriet dislike each other.
Bob is friend of James.
James is boss and friend of Zach.
James is friend of Grace, who is married to Fred.
James and Charlie are colleagues and friends.
Charlie is colleague of Davina, and Davina is friend of Edward, who is friend of Fred.
[MUSIC]
To install and execute Neo4j, you need to download neo4j-community from the site.
Unzip and install the file in your hard disk.
Start the server according to your operating system, and in a browser, go to your
localhost webadmin, with 7474 as default.
The browser includes Dashboard, data browser, console, etc.
And also you can use REST to go to the root node for example.
>> [SOUND] Neo4j uses cipher as its query language.
Cipher is a formal language used to populate database and make requests.
It uses both indexes and traversals, which means to go through the nodes of the graph
to obtain data.
>> There are some clauses to create and populate your database graph.
The Create clause creates nodes and relationships.
The Delete clause deletes graph elements, nodes, relationships or paths.
Any node to be deleted must also have all associated relationships explicitly deleted.
Detach delete, deletes a node or set of nodes.
All associated relationships will automatically be deleted.
Set updates labels on nodes and properties on nodes and relationships.
Remove removes properties and labels from nodes and relationships.
Foreach updates data within a list, whether components of a path or the result of
aggregation.
To resolve queries, we have Match and Where sentences.
The Match clause is to specify a pattern of nodes and relationships.
The Where subclause is to constrain the results.
Consider the following graph.
We will create two nodes, we do create sentences where Emil and Johan are two
people that were born on Sweden.
We can also create the relationship between Emil and Johan with the create sentence.
However, we need to get to person instances for Emil and Ian with match and where
sentences as conditions, and then create the nodes relationship between Emil and Ian.
There are many programming languages supported.
>> You can have a look to the following link for REST or Java API.
>> We can use declarative language to travel a graph.
For example, if you need to search for a person named Emil, the following query
should be submitted.
The match clause is to specify a pattern of nodes and relationships such as the
following, which is a single node pattern with a label person which will assign matches
to the variable n.
[MUSIC]
The where clause is the constrain the results.
n.name = "Emil" allows to compare name property to the value "Emil".
And the RETURN clause is used to request a particular result.
[MUSIC]
The main reason for using indexes in a graph database is to find the starting point in
the graph as fast as possible.
After that you rely on in-graph structures and relationships to achieve high
performance.
Those graph queries themselves do not need indexes to run fast.
Indexes can be added at any time.
Note that it will take some time for an index to come online when there's existing data.
In this case we want to create an index to speed up finding people by name in the
database.
We CREATE INDEX ON :Person(name).
Normally, you don't specify indexes when querying for data.
They will be used automatically.
This means that we can simply look up the Emil node with MATCH.
And the index will kick in behind the scenes to boost performance.
In the case of relation and databases if you use many to many relationships you
have to introduce a joint table that holds foreign keys of both participating tables.
Increasing the joint operation costs.
Each node in the graph database model directly and physically contains a list
of relationships records that represent each relationships to other nodes.
These relationships records Organize by type and direction.
I may hold additional attributes.
Whenever you run the equivalent of a joint operation, the database just uses these list
and has direct access to the connected nodes.
Eliminating the need of an expensive search or much computation.
Now you're able to set executing queries to a sample graph called the movie database.
The model is composed by notes, movie, and person, and relationships act, directed,
and produced.
Download the movie database from the link that is shown.
Stop the Neo4j server and see the download file.
Override graph.db in path to Neo data.
Start the server again with bin/neo4j start.
Open the Neo4j web interface on the link that is shown.
And execute the following sample queries and show the results.
As a summary of neo4j, we can say that it is a graph database.
With full ACID conformance, including long-lasting data, with nodes such as
relationships that can have metadata.
Its query language is called Cypher, and it is based on integrated pattern matching.
Neo is best used for graphic style data, rich or complex, interconnected.
>> For example, to look for roads in social relationships, public transfer links, road
maps or water ports of these.
Next week we will learn the main characteristics of dated data applications.
See you then.

You might also like