Create a Logical Data Model Manually

Creating the LDM manually is suitable for the following situations:

  • Your database contains the complex analytical scenarios.
  • Your database stores only a part of the metadata (for example, relations are handled by application logic and not by foreign keys in the database).
  • You want to first create the LDM and then define your analytic use cases based on it.
  • You want to build your analytic experience iteratively, customize, and evolve your LDM. In this case, consider the following:
    • If you make custom changes to the LDM and then automatically generate the LDM later, the custom changes will be overwritten.
    • If you regularly update the relational model of your database, maintaining the LDM manually can be very costly and even not possible in some cases.

To create the LDM manually, follow these steps:

  1. Create datasets.
  2. Set the primary key in datasets.
  3. Create relationships between datasets.
  4. Add Date datasets.
  5. Save the LDM.

Create Datasets

You can create datasets in two ways:

Create Datasets From Pre-generated Datasets

Even if you do not generate the LDM automatically, you can still use the automatically pre-generated datasets in combination with any datasets you may create from scratch. This is the recommended way of creating datasets in your LDM.

Steps:

  1. To add a dataset, drag a table from the left panel and drop it in the blank canvas area.

    The left panel showing a dataset named Campaign channels being dragged from a connected PostgreSQL database schema into the LDM canvas. Fields listed include Campaign channel id, Category, Type, Budget, and Spend.

    This action creates a dataset from your table. It guesses the field types (fact/attribute) based on the database types and it creates mapping between the database table and the LDM.

  2. Repeat the previous step for all the tables you want to use.

  3. Hover over the dataset and click Details.

    Dataset titled Campaign channels with the Details button highlighted at the bottom right.
  4. Review the Fields and Data mapping tabs and ensure the data is mapped correctly according to your needs. Change the field types or reconfigure the data mapping if necessary.

Create Datasets From Scratch

Follow these steps to create a dataset manually.

Steps:

  1. Open your workspace.

  2. Click the Data tab.

    The LDM Modeler opens in view mode.

  3. Click Create model, or if you are editing a preexisting model, click Edit.

    The LDM Modeler is switched to edit mode. You can see the registered data sources in the left panel.

    Empty Logical Data Model canvas displaying schema items on the left and a central prompt suggesting the user drag items to build their model.
  4. To add a dataset, drag Empty dataset from the left panel and drop it in the blank canvas area.

    Panel showing an empty dataset being dragged from the Start from Scratch section into the Logical Data Model canvas, ready to be renamed and filled with attributes or facts.

    Don’t forget to give it an appropriate name.

  5. Select the newly added dataset, click Details.

    Dataset titled Order lines with Details button highlighted at the bottom. The dataset is empty and ready for field addition.
  6. Click Add field to map invididual table columns to the dataset:

    Dataset editing dialog with the Add field button highlighted at the top of the editor panel. Clicking it expands the Add field dropdown. In the dropdown, the Source Column is set to orderid, the Type toggled to attribute, the Name set to Order ID, and the Source Type as STRING. At the bottom, Add and Cancel buttons are displayed.
  7. Click Save changes.

    Dataset editing dialog titled Order lines showing six fully configured fields: Order ID, Order Line ID, Order Status, Price, Quantity, each with defined types, IDs, and labels. The Save changes button is highlighted in the bottom-right corner.

    You have prototyped the dataset, but it still needs to be mapped onto a source table:

    Dataset titled Order lines showing five fields including Order ID, Order Line ID, Order Status, Price, and Quantity.
  8. Repeat these steps to create as many datasets as you need.

    Once you have created one or more datasets in the LDM, the next step will be to map the datasets to the database.

Map the LDM to the Database

Set up mapping for all the datasets in your LDM. Mapping your LDM to the database allows you to use data from your database in GoodData.

Steps:

  1. Select a dataset, click Details.

  2. Click the Data mapping tab.

  3. Map the dataset to a particular table in your database.

    The Dataset details dialog with the Data mapping tab open. In the list of fields below, each field, including Order ID, Order Line ID, Order Status, Price, and Quantity, displays a red icon indicating it is not yet mapped. A dropdown labeled Not mapped is expanded on the right, showing a list of available source tables including campaigns, customers, order_lines, and products. The order_lines option is currently selected.
  4. Map each field in the dataset to a specific column in this table.

    Expanded data mapping view showing Source Column values being assigned for fields in Order lines. The Quantity field's mapping dropdown is open and the Quantity source column is selected from the list.
  5. Click Save changes.

  6. Repeat these steps for every dataset in your LDM.

Set the Primary Key in Datasets

Set the primary key (grain) for datasets in your LDM.

Steps:

  1. Select a dataset, and click (ellipsis) -> Set primary key.

    The Order lines dataset with the ellipsis button highlighted in the bottom-right corner. Clicking it opens a context menu. There, the Set primary key option is highlighted.
  2. Select one or more attributes that should become the primary key, and click Set key.

    Set primary key dialog where Order ID is selected as the primary key and the Set key button is highlighted in the bottom-right corner.

    The dialog closes, and the primary key is set.

  3. Repeat these steps for every dataset in your LDM.

Create Relationships between Datasets

A relationship between two datasets allows you to use information from one dataset to slice the data in the other dataset. Creating relationships allows you to discover new analytical scenarios when creating visualizations.

Steps:

  1. Locate the datasets that you want to create a relationship between.

    Two datasets are displayed side by side to illustrate a relationship setup. On the left, the target dataset Order lines includes fields such as Order ID, Order Line ID, Order Status, Price, and Quantity. On the right, the originating dataset Products contains fields like Product id, Product name, and Category.

    In this example you want to be able to use the information from the Products (originating) dataset in the Order lines (target) dataset.

  2. Select the originating dataset. Click the blue dot on the right border of the originating dataset and drag the arrow to connect it to the target dataset.

    A relationship being created between Order lines and Products. An arrow is dragged from the Products dataset to Order lines.

    The following dialog opens:

    Relationship details dialog showing how to configure a connection between datasets. The Products dataset is on the left and provides the primary key Product ID. The Order lines dataset is on the right and is set as the reference dataset. A dropdown in the reference field section shows Connect as new field selected, indicating that a new foreign key will be created in Order lines to reference Product ID from Products.
  3. Customize the relationship as required.

    In the target dataset, the primary key defines the unique identifier for a row of data from the originating dataset. If the originating dataset does not contain a primary key, select an attribute from the Primary Key drop down list to set it as the primary key.

    We recommend you use the default 1:N relationship type.

    In the Reference Field drop down list you can choose from one of the following options:

    • Connect as new field: Add the primary key of the originating dataset as a new attribute (foreign key) to the target dataset. The foreign key serves as a reference to the originating dataset.

    • Existing dataset fields: Reuse an existing attribute from the target dataset, and make it a reference (foreign key) to the originating dataset.

  4. Click Connect.

    Notice that the target dataset has been extended by the foreign key from the originating dataset.

    Logical Data Model view showing the Order lines and Products datasets. Order lines includes a newly added field named Product ID, marked with a grey key icon indicating it is a foreign key. This field links to the primary key Product ID in the Products dataset. An arrow points from the foreign key in Order lines to the primary key in Products, visually indicating the established relationship.
  5. Repeat these steps for all the datasets in your LDM that you want to connect.

Add Date Datasets

A Date dataset is a dataset that represents DATE / TIMESTAMP columns in your database. The Date dataset helps you manage time-based data and enables aggregation at the day, week, month, quarter, and year level.

Steps:

  1. Drag Date from the left panel and drop it in the blank canvas area.

    Logical Data Model canvas showing a Date dimension dataset being dragged from the Start from Scratch section to the canvas. The Order lines dataset and its relation to Products created in the previous steps are also visible.
  2. Create a relationship between the new Date dataset and a dataset that contains a date/timestamp column.

    In the following image, the dataset with a date/timestamp column is the Order lines dataset.

    Diagram showing a Date dataset connected to the Order lines dataset via a reference field named Date. Products are also shown as connected.

    Notice that the Order lines dataset has been extended by the Date foreign key.

  3. (Optional) Configure the Date dataset.

    1. Select the dataset, and click Edit.

      Close-up view of the Date dataset with the Edit button highlighted in the bottom-left corner.
    2. In the configuration dialog, configure the dataset as needed:

      Date configuration dialog open with editable fields for description, title base, and title pattern. A granularity selection dropdown is expanded, showing options like Quarter and Year, Week and Year, or Year.
      • Add a description to the dataset.

      • Configure how the name of the included date/time granularity levels will be displayed.

        The Title pattern field defines the general format for the titles of all included granularity levels. Use the %titleBase and %granularityTitle placeholders to define the order in which the value from the Title base field and the default granularity title will be used in the title. If Title base is not specified, the default name of the Date dataset (Date) will be used (for example, Date - Year, Date - Hour, and so on).

      • Select the date/time granularity levels that you want to include in the Date dataset.

        Some date granularity levels are selected by default and cannot be excluded from the Date dataset.