Chapter 5. Perspectives

This chapter describes Perspectives in Neo4j Bloom and how to work with them.

In Neo4j Bloom, a Perspective defines a certain business view or domain that can be found in the target Neo4j graph. A single Neo4j graph can be viewed through different Perspectives, each tailored for a different business purpose.

Perspectives define:

5.1. Perspective - a business view of the graph

Within a graph there are often multiple smaller graphs which are connected to each other. Sometimes you need to see everything. Other times it’s helpful to have a more focused view. Defining a Perspective allows you to select what parts of the graph to show and how to show them.

Let’s use the Northwind example data set. Northwind is a fictional company with a database that tracks their product catalog, sales orders, and sales staff.

Figure 5.1. Northwind ER Diagram
image22

When importing Northwind directly into a Neo4j graph there is a 1:1 correspondence of tables to labels, which means that for each record a node has been created with a label that matches the original name of the table. Each foreign key reference gets converted into a graph relationship.

After starting this Neo4j database and launching Bloom, you’ll be prompted to select a Perspective. If you have any previously defined Perspectives, they will be available for selection. Otherwise, you can ask Bloom to auto-generate a Perspective. That’s a good place to start. Bloom will categorize the nodes into entities, select useful captions and assign color-coding.

You’ll be able to search and explore the entire Northwind graph.

Figure 5.2. Northwind as a Graph
northwind as a graph

While everyone in the organization could benefit from a graph view, not everyone needs to see everything. For instance, the shipping department of Northwind may only need to see orders, products, and customers. You can create another Perspective that highlights only those categories.

Figure 5.3. Northwind Shipping Perspective
northwind shipping perspective

Similarly, you can create Perspectives that are specific to the sales department, purchasing department, or customer service department.

Figure 5.4. Northwind Sales Perspective
northwind sales perspective
Figure 5.5. Northwind Purchasing Perspective
northwind purchasing perspective
Figure 5.6. Northwind Customer Perspective
northwind customer perspective

5.2. Perspective creation and use

5.2.1. Creating a Perspective

perspective creation

Perspectives can be selected or created from the Perspective gallery, found in the Perspective drawer. There are two options when you opt to create a new Perspective:

  1. Generate Perspective - With this option, Bloom will analyze the labels within the graph, identifying the smallest number of labels that uniquely categorize all nodes. Bloom will then create the perspective and auto-fill in the requisite category definitions, choose properties for captioning categories, populate list of available relationship types, and set default styles. Once created, the Perspective definition can be edited and reconfigured differently at any time.

    When Bloom connects to a database for the first time, auto generating the Perspective might be the best option in most cases.

  2. Blank Perspective - With this option, you can build a Perspective from scratch by defining each category and configuring properties and styling for it. Bloom will still add the list of available relationship types.

    Choose this option when you have a large number of labels in the data, but your Perspective only needs to contain a small subset of them. It will be more efficient to create the Perspective manually rather than auto-generating it and reconfiguring to remove many categories.

Perspective Export and Import

You can also export the Perspective definition in a serialized json file format. This is useful to either save the definition as of a certain time, or to migrate Perspectives between different environments. The json file can then be imported using Bloom connected to the same or a different database.

Both exporting and importing a Perspective can be done from the Perspective gallery.

perspective export import

5.2.2. Components of a Perspective

perspective components

The Perspective designer is shown above. In this designer, you can specify Categories, Relationships and Search phrases for a Perspective.

Categories

Within a Perspective, a category defines each business entity – Person, Place or Thing – which will be visible through the Perspective. Typically, a single graph label will map to a particular category, but multiple labels may also be mapped to a single category.

When you create a category, Bloom analyzes the graph to find the related properties and other labels that occur on nodes that have the category-defining label. You can then choose which properties should be excluded from the visualization, and which to use for captions inside of nodes. Bloom will assign a default color for the category, but you can change the default color and node sizes from the Legend panel. You can also give the category an icon from an extensive library of searchable icons. Rule-based styling can also be applied at any stage.

If a node has multiple labels, and the labels are mapped to different categories, the category which is defined first in the Perspective definition will be used by Bloom for that node. Hence the styling of the node will be driven by the first category to which any of its labels are mapped. For example, if Tom Hanks has the Person and Actor labels, and there are two respective categories defined for Actor and Person in that order, the styling for the Tom Hanks node will be derived from the Actor category. However, when searching for all Person nodes, Tom Hanks will still be returned in the query results since it has a Person label on it.

Relationships

Based on the Perspective’s purpose, it may be useful to limit the relationship types that are available for user exploration. The Perspective designer lets you choose one or more relationship types from the list of available types in the graph, and hide them. By default, all relationship types are visible.

Similar to category styling, relationship type styling options for color, thickness, and rule-based styles are available in the Legend panel.

Search phrases

Search phrases are defined and scoped for a particular Perspective, as they usually apply to a specific business view of the graph. These are defined in the Perspective designer as well, and stored with the rest of the Perspective definition. See Search phrases for advanced queries for how to define Search phrases.

5.3. Perspective storage and sharing

When the Bloom client is used without the Bloom server plugin, Perspectives are stored locally on the user’s machine. This location depends on whether Bloom is running in Neo4j Desktop or in a web browser. In this setup, Perspectives cannot be shared between different users.

When the Bloom server plugin is used, Perspectives are stored in persistent storage (i.e. Neo4j database) provided by the server plugin. Therefore, they can be easily shared between different users who are accessing the same Neo4j server.

Perspective sharing can be explicitly controlled from the Sharing tab in the Perspective definition drawer. The best practice for assigning Perspectives is to create a custom role for each Perspective, and add that role to each user who should have access to the Perspective in question.

perspective sharing

5.3.1. Perspective actions by database privileges

The following table maps various Perspective actions available to a user according to the database privileges granted to the user. Note that this table is applicable for the Bloom plugin setup only, when storage is provided by the plugin and Perspectives may be shared across users. For setups without the plugin, Perspectives are stored locally on the user’s machine and thus the user can perform all relevant actions.

When using Bloom with Neo4j 4.1, Bloom is not able to recognize the fine-grained write permissions available in that version of the database. Granting WRITE to the perspective label specifically, will not enable perspective storage if WRITE to the DB is not granted. Further, granting WRITE to the DB but denying it specifically to the perspective label, means that Bloom will still think perspective sharing is possible. Consequently, it will fail with an error when trying to store a perspective. Therefore, make sure to grant the user WRITE privilege on the DB and don’t deny any of CREATE, SET LABEL, or SET PROPERTY on the Bloom_Perspective label.

Table 5.1. Database privileges (with plugin)
Actions Read only Write Write + list roles Write + list and create roles

Open Gallery

Yes

Yes

Yes

Yes

Select Perspective from Gallery

Yes

Yes

Yes

Yes

Allow local Perspective edits

Yes

Yes

Yes

Yes

Save edits to store

No

Yes

Yes

Yes

Delete Perspective

No

Yes

Yes

Yes

Create new/Generate Perspective

No

Yes

Yes

Yes

Sharing tab

No

No

Yes

Yes

See already mapped roles

No access

No access

Yes

Yes

See list of roles

No access

No access

Yes

Yes

Map to a role

No access

No access

Yes

Yes

Delete role mapping

No access

No access

Yes

Yes

Create new role

No access

No access

No

Yes

Export

No

Yes

Yes

Yes

Import

No

Yes

Yes

Yes

Users that have write access to the database, i.e. users that can create Perspectives, also have the ability to export and import Perspectives.

Starting in Bloom 1.3.2, there is an experimental feature to export all Perspectives. It can be accessed from the Experimental drawer.

export all perspectives