Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Neo4j Graph Data Modelling

You're reading from  Neo4j Graph Data Modelling

Product type Book
Published in Jul 2015
Publisher
ISBN-13 9781784393441
Pages 138 pages
Edition 1st Edition
Languages
Concepts

Table of Contents (16) Chapters

Neo4j Graph Data Modeling
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Graphs Are Everywhere Modeling Flights and Cities Formulating an Itinerary Modeling Bookings and Users Refactoring the Data Model Modeling Communication Chains Modeling Access Control Recommendations and Analysis of Historical Data Wrapping Up Index

Adding comments to Neo4j


As discussed earlier, comments can be used by users to ask more questions or clarify something to other users. Since chronology is important, we will create a chain for the comments. The assumption here is that for a new question or clarification, a new comment chain will be started with the first comment in the chain being in response to the review being commented on.

Before we add comments, we should set up a constraint on comments to ensure that we don't create comments with the same ID, as shown in the following query:

neo4j-sh (?)$ CREATE CONSTRAINT ON (comment:Comment) ASSERT comment._id IS UNIQUE;

The output of the preceding query is as follows:

+-------------------+
| No data returned. |
+-------------------+
Constraints added: 1

To add a comment to the review, we can use the following query:

CREATE (comment:Comment{_id:"df23c188-2349-11e5-8966-6c40089a9424", text:"What was wrong with the service?", created_on: 1391550607.342643}))
WITH comment
MATCH (review:Review...
lock icon The rest of the chapter is locked
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 $15.99/month. Cancel anytime}