Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Hands-On Graph Analytics with Neo4j

You're reading from   Hands-On Graph Analytics with Neo4j Perform graph processing and visualization techniques using connected data across your enterprise

Arrow left icon
Product type Paperback
Published in Aug 2020
Publisher Packt
ISBN-13 9781839212611
Length 510 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Scifo Scifo
Author Profile Icon Scifo
Scifo
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Section 1: Graph Modeling with Neo4j
2. Graph Databases FREE CHAPTER 3. The Cypher Query Language 4. Empowering Your Business with Pure Cypher 5. Section 2: Graph Algorithms
6. The Graph Data Science Library and Path Finding 7. Spatial Data 8. Node Importance 9. Community Detection and Similarity Measures 10. Section 3: Machine Learning on Graphs
11. Using Graph-based Features in Machine Learning 12. Predicting Relationships 13. Graph Embedding - from Graphs to Matrices 14. Section 4: Neo4j for Production
15. Using Neo4j in Your Web Application 16. Neo4j at Scale 17. Other Books You May Enjoy

SQL and joins

Let's briefly focus on relational databases. Imagine we want to create a Question and Answer website (similar to the invaluable Stack Overflow). The requirements are the following:

  • Users should be able to log in.
  • Once logged in, users can post questions.
  • Users can post answers to existing questions.
  • Questions need to have tags to better identify which question is relevant for which user.

As developers or data scientists, who are used to SQL, we would then naturally start thinking in terms of tables. Which table(s) should I create to store this data? Well, first we will look for entities that seem to be the core of the business. In this QA website, we can identify the following:

  • Users, with attributes: ID, name, email, password
  • Questions: ID, title, text
  • Answers: ID, text
  • Tags: ID, text

With those entities, we now need to create the relationships between them. To do so, we can use foreign keys. For instance, the question has been asked by a given user, so we can just add a new column to the question table, author_id, referencing the user table. The same applies for the answers: they are written by a given user, so we add an author_id column to the Answer table:

It becomes more complicated for tags, since one question can have multiple tags and a single tag can be assigned to many questions. We are in the many-to-many relationship type, which requires adding a join table, a table that is just there to remember that kind of relationship. This is the case of the QuestionTag table in the preceding diagram; it just holds the relationship between tags and questions.

You have been reading a chapter from
Hands-On Graph Analytics with Neo4j
Published in: Aug 2020
Publisher: Packt
ISBN-13: 9781839212611
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images