Auto-generating a graph model from an existing schema

You can auto-generate a graph model from one or more schemas that are associated with a Db2 database connection.

Before you begin

Attention: With the release of Db2 11.5.9, Db2 Graph is discontinued. You can still run Db2 Graph as a standalone application with Db2 11.5.6 through 11.5.8.

About this task

A graph is a collection of vertices and edges. Vertices represent domain objects, such as a person or a place, while edges represent relationships between two vertices.

In order to run graph queries against Db2, you need to create a graph model that tells Db2 Graph which tables in your database should be considered as sources for vertices and how the relationship between the tables are defined. Each table used as a source for a vertex by the graph modeler contains a primary key, and the foreign key relationships between these tables are presented as edges by the graph modeler. In other words, any table with a primary key is created as a vertex table while any table with two or more foreign keys is created as an edge table.

The graph modeler allows you to auto-generate graphs, based on primary and foreign key constraints in the database.

Procedure

  1. From the Filter Schemas panel, click the check box of each schema that you want to include in your model, and then click Add. You can also drag selected schemas onto the canvas area to add them to your model. To search for specific schemas, enter a string into the search box at the top of the panel and the panel will filter the list of schemas that match the input.
    Note: If any tables from your selected schemas do not have primary and foreign key relationships, then the tables are excluded from your model. A message box appears on the right side of the graph modeler to provide details of any exclusions.
    Note: After adding a schema to auto generate a graph model, the schemas list will automatically close. To bring it back, click the Expand schema list button from the top right of the header bar.
    Note: The schema list will show a check mark next to any schema already in use by the graph model.

    The graph modeler processes your selections and generates a graph of vertices and edges.

  2. Click a vertex or an edge in the canvas to bring up the Edit Vertex Table or Edit Edge Table panel.
    The panel displays the definition of the selected vertex table or edge table. When auto-generation occurs, prefix and label values are created with the table definition. Prefix values default to SCHEMA.TABLENAME and label values default to TABLENAME.
  3. From the toolbar, click the Find recommendations button for suggestions on how to refine the performance and appearance of your graph.
  4. When you are happy with the state of your graph, click the Save graph button. Your graph is saved to a metadata table created by Db2 Graph.
    Important: About saving graphs - The Save graph form opens in one of two states:
    • If you are saving a new graph, then the graph name field is empty.
    • If you are saving changes to an existing graph, then the graph name field will is populated
      Note: If you are editing an existing graph, you are also warned that saving the graph will cancel any running graph queries.
    Like connection names, graph names must be unique within a connection, must contain only valid letters, numbers or underscores, and must start with a valid letter.
    Valid letters include:
    • 'a' to 'z' (lowercase ascii letter)
    • 'A' to 'Z' (uppercase ascii letter)
    • '\u00C0' to '\u00D6'
    • '\u00D8' to '\u00F6'
    • '\u00F8' to '\u00FF'
    • '\u0100' to '\uFFFE'