Chapter 5. Perspectives

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. 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.

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, Perspectives are stored locally on the user’s machine. The location depends on where Neo4j Desktop is installed on the user’s machine. In this setup, Perspectives cannot be shared between different users.

When the Bloom Server is used, Perspectives are stored in a persistent storage provided by the server plugin. Therefore, they can be easily shared between different users who are accessing the same server. Sharing and security of Perspectives is controlled using database roles and follows the following rules:

  • A Perspective can be shared with any role (native or custom).
  • When a Perspective is shared with a role, all users with that role have access to it.
  • You must have at least read access to the database to use a Perspective that has been shared with you.
  • You can only create, edit and save changes to a Perspective if you have write access to the database. Users who do not have these roles can only temporarily edit a Perspective in the Bloom client but cannot save changes.
  • When a Perspective is created or imported, it is implicitly shared with all users that have the same role(s) as the user who created or imported it.

Perspective sharing can also be explicitly controlled using a Sharing tab in the Perspective definition drawer. The Perspective gallery can be found from the Settings drawer.

perspective gallery access

Only users who have the ability to list database roles have access to this tab and thus control over explicit sharing of Perspectives. 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

An admin user has explicit control over the sharing of Perspectives, even if a particular Perspective was created by a publisher or architect. 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 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

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

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