Know the Neo4j

Well, we now know the Neo4j a NoSQL graph database.

An investment of 15 minutes is enough. 🙂

NoSQL?

It bluntly NoSQL means Not Only SQL, was created as an alternative to solve problems that relational databases can’t solve.

There are several databases following NoSQL, each focused on its specialty like the MongoDB which is oriented document.

graphs?

They are structures composed of vertices and edges created by mathematicians to study relationships between objects.

Remember

Before we begin to know the Neo4j, remember this phrase: “Use the right tool for the job”.

nj4

It is important to know the NoSQL databases, but does not mean that you will arrive tomorrow in your company and begin to eliminate relational databases. It is wise to assess the problem and look for the best tool to solve, either using a database NoSQL, NewSQL or relational.

Starting …

neo4j-logo-2015[1]

The Neo4j is a NoSQL open-souce graph database. It is suitable for working with a large amount of data (big data), especially when the problem is the relationship between objects.

The best example of objects that have relationship is a social network, it is indicated to find such mutual friends. I can cite other examples as a routing system to find the best route between two points and also an e-commerce where we can make product recommendations based on the products the customer is looking for.

For the above examples the Neo4j be very efficient in data recovery.

Advantages

Some advantages of Neo4J:

  • He is a NoSQL database with ACID support
  • Features support for clustering
  • Works with the data in memory (speeeeeed!)
  • Enables hot backups and other advantages will punctuating the following topics …

Use

You can use the Neo4j as Embedded database (Local database file).

nj5

You can also install the server Neo4j

nj6

The correct url is http://localhost:7474/ (/webadmin is the old web-ui)

After a few clicks it is ready for use and in addition to the server you get a great web interface for administration that enables navigate the nodes and configure the database easily.

 nj7

Visit here to download.

Structure

Understanding the Structure

  • Node (Represent entities such as people, bands or any item that can be shared.)

  • Relationships (make the connection between nodes)

  • Properties (represent a set of data within the nodes or relationships)

Language

The Neo4j uses language Cypher which is equivalent to SQL on a relational database. Syntax quite different from the “SQL”, really oriented relationships.

I will show here only the basics of how to create and link records to other syntax recommend official documentation , an EXCELLENT documentation where you can even run the commands, really nice!

The Create would be equivalent to an insert in the relational:

CREATE (n: Person {name: ‘Andres’, title: ‘Developer’})

Below is an example creating us with the name property for bands and name and age for people.

NJ2

Now building relationships between people and band.

nj1

With this example we can find out like that Eder and Thiago have in common (which bands they like). See how is the result in the web interface.

nj11

ps: START is deprecated, you would start your query with MATCH (p:Person)

Also find out what people like the band “Daft Punk”. And so in many ways we can map relationships which these objects have …

Importantly, if we have the index code (root), whether the number of records in the database increases, the return time is always the same

it’s can only maintain the same turnaround time as to reach the content we will go through only the related nodes, ie you do not need to sweep the remaining records.

 API 

The Neo4j has native support for several languages ​​such as Java, .NET, Python, Ruby, PHP, etc. R

nj8

And another big advantage is that the Neo4J Server has support for REST

nj9

With this you can start playing with Neo4j, choose your language and be happy!

PS: Only illustrative images. For information, see the documentation of API Java and REST.

We’ll talk also about NewSQL. Wait.

thanks for read this post!!

The following two tabs change content below.

Raphael Krauss

Software Engineer
+ 10 years experience in development and supporting applications, works in Softplan company as software development, working with the maintenance of basic development frameworks. With knowledge in Delphi, Java, Jsp, Servlets, Hibernate, Mobile Android and also the Oracle Database, SQLServer, DB2, MySQL, PostgreSQL. Specializes in performance analysis and application monitoring techniques. Working on projects with agile methodologies like Scrum, XP and using best practices such as Clean code and Design patterns. It also has experience in managing continuous integration environments (version control, continuous Build and tools for static code analysis).

Latest posts by Raphael Krauss (see all)

About Raphael Krauss

+ 10 years experience in development and supporting applications, works in Softplan company as software development, working with the maintenance of basic development frameworks. With knowledge in Delphi, Java, Jsp, Servlets, Hibernate, Mobile Android and also the Oracle Database, SQLServer, DB2, MySQL, PostgreSQL. Specializes in performance analysis and application monitoring techniques. Working on projects with agile methodologies like Scrum, XP and using best practices such as Clean code and Design patterns. It also has experience in managing continuous integration environments (version control, continuous Build and tools for static code analysis).

6 thoughts on “Know the Neo4j

  1. Hi Raphael,

    thanks a lot for your bog post.

    It would be cool if you could update some things.

    1. the url is http://localhost:7474/ (/webadmin is the *old* web-ui)
    2. Please update the logo: https://dl.dropboxusercontent.com/u/14493611/logo-neo4j.svg
    3. Section API
    START is deprecated, you would start your query with MATCH (p:Person)

    Please also link to the Neo4j Manual for the API section: http://neo4j.com/docs/stable/tutorials-cypher-java.html

    The execute() method now lives directly on GraphDatabaseService

    In the REST API section please link to http://neo4j.com/docs/stable/rest-api-transactional.html

    Please make sure to use labels in all the examples

    In the browser visualization, the recent one looks differently, you also would want to configure the style to show the band and artist name as caption.

    1. thanks for jexp tips.

      I actually used a previous version of Neo4j for this post. Sorry.

      I’ll put their comments in the post, thank you for your availability to comment.

      check back often

      hug

    1. I didn’t use even the combination c ++ and Neo4j. But I love challenges. You have some challenge for me?

      rapha.krauss (at) gmail (dot) com

      🙂

      I would be happy to help you…

      1. Thank you Raphael.
        I would like to know the best way to create Cypher query in C++ and then use the query on a neo4j database. I would like everything to be done in C++.

        I think you can use libcurl to connect and query the database.

        It would be nice if you can create an example for us.

        Thank you,

Leave a Reply