Database Reference
In-Depth Information
While some connections between nodes naturally suggest how the direction should be set, others have a mutual
or bidirectional relationship. Consider Figure 3-6 , in which “GraphStory is a partner with NeoTechnology.” In these
bidirectional relationships, a second relationship connection, as with directed relationship, is unnecessary. Again, as
is the case with directed relationships, it is faster to have a single relationship with an arbitrary direction.
Figure 3-6. Bidirectional relationship with an arbitrary direction
Modeling Constraints
Ensuring that specific properties within the model remain unique is an important feature of any database and Neo4j is
no different. With Neo4j 2.0, the concept of adding unique constraints based on labels was added. You can use unique
constraints, as shown in Listing 3-1, to ensure that property values are unique for all nodes with a specific label. If you
are creating the constraint after nodes have been created, then be aware that the new constraint could take some time
to become enforced as any existing data must be scanned beforehand.
Listing 3-1. Creating a Unique Constraint
CREATE CONSTRAINT ON (business:Business) ASSERT business.businessname IS UNIQUE
When adding a unique constraint on a node's property, please note that this process will also create an index on
the specific property and, therefore, you will not be able to add a separate index for the property. The index can be
used to perform lookups for specific nodes. If you need for some reason to remove the constraint, as shown in
Listing 3-2, and require an index on that property, then you will need to create a new index to support lookups.
Listing 3-2. Dropping a Unique Constraint
DROP CONSTRAINT ON (business:Business) ASSERT business.businessname IS UNIQUE
Modeling Use Cases
To begin building out the model for the application to be developed in the later chapters of the topic, the following
sections examine in turn the five areas identified as the most significant portions of consumer and business
data—namely, social, interest, consumption, location, and intent graphs.
Social Graph
The social graph is the most widely discussed type of graph in the list of graph use cases. In its more well-known
incarnation, the social graph represents the degree of connection between users on a particular application,
such as Twitter. Facebook's social graph is the largest social graph in the world, developed on a mostly proprietary
technology stack.
 
Search WWH ::




Custom Search