Book Image

Building web applications with Python and Neo4j

By : Sumit Gupta
Book Image

Building web applications with Python and Neo4j

By: Sumit Gupta

Overview of this book

Table of Contents (14 chapters)
Building Web Applications with Python and Neo4j
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding relationships to models


Neomodel provides the following classes in the neomodel package for defining relationships between nodes or entities:

  • Relationship: This class is used to define a bi-directional relationship in which the "direction" of the relationship does not matter. It can be in any direction. For example, in our social data model we are using the FRIEND relationship in which direction does not matter, because if one person declares being a friend to another then vice-versa is also true.

  • RelationshipTo: It is used to define the outgoing relationship.

  • RelationshipFrom: It is used to define the incoming relationship.

All of these classes accept four parameters and expose the connect() method to establish a relationship with the given node. The following is the explanation of each parameter required by the relationship classes:

  • Class name: This is the name of the class that enjoys the relationship with the class in which the relationship is defined.

  • Relationship type: This is...