Book Image

Neo4j Cookbook

By : Ankur goel, Ankur Goel
Book Image

Neo4j Cookbook

By: Ankur goel, Ankur Goel

Overview of this book

Table of Contents (17 chapters)
Neo4j Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Retail data modeling with Neo4j


In this recipe, you will learn how to model retail data using Neo4j.

Getting ready

Install the Neo4j graph database over the host machine using the recipe described in Chapter 1, Getting Started with Neo4j. This installation process will depend on your preference for your machine OS type.

How to do it...

Let's model this data to build a retail insight engine:

Customer – [HAVE] – Location
Customer – [BUYS] – Product[s]
Product – [HAVE] – Categories
Customer-[LOOKS]- Product[s]

The following screenshot shows the retail graph modeling:

Let's answer some questions on the basis of our retail graph, which are as follows:

  • The day on which there is the highest sale of wine: Let's find out on which day there is the highest sale of wine. In this, we will also make use of an aggregated model, where the given dates will be aggregated on the basis of days, as follows:

    MATCH (p:Product{name:"perfume"})-[r:SOLD_ON]->(d:date)<-[X:DAY_OF_WEEK]-(w:Weekday)
    RETURN w, count(r)...