Create a Logical Data Model

Before you can start analyzing and visualizing your data, you need to first create a logical data model (LDM) for the said data. Follow the instructions in this article to create a LDM.

To generate the the logical data model (LDM) automatically in the LDM Modeler, follow these steps:

  1. Open the demo workspace and ensure you are in the Data tab.

  2. Click Create model.

    Selecting the Data tab in the navigation bar at the top opens the Logical Data Model editor. A blue Create model button is highlighted in the lower part of the text box below.
  3. Click the Connect button on the left panel to connect your data source to your LDM.

    Left-side panel of the Logical Data Model editor showing options to add an empty dataset or date dataset manually, and to connect a data source. The Connect button below the selected Snowflake data source is highlighted.
  4. Select your tables and click Add selected to add your tables as data sets to the LDM.

    Logical Data Model canvas with no datasets yet placed. On the left, the Snowflake data source is connected and five tables are selected from the schema. The Add selected button at the bottom of the panel is highlighted.

    The LDM is automatically created.

  5. Click the Save button to save your LDM.

    Logical Data Model canvas displaying five connected datasets: Campaigns, Campaign Channels, Customers, Products, and Order Lines. The Date dimension table is added too. Relationships between the datasets are represented by arrows. The Save button in the top right corner is highlighted.

We recommend using the web UI to create the LDM, however it is possible to copy an existing LDM from one workspace to another workspace:

from gooddata_sdk import GoodDataSdk, CatalogWorkspace

# GoodData host in the form of uri eg. "https://*.gooddata.com" (GoodData Cloud), 
# or "http://localhost:3000" (GoodData Cloud Native)
host = "<HOST_URL>"
# GoodData API token
token = "<API_TOKEN>"
source_workspace_id = "<WORKSPACE_ID>"
target_workspace_id = "<DIFFERENT_WORKSPACE_ID>"
sdk = GoodDataSdk.create(host, token)

# Get LDM from GoodData
declarative_ldm = sdk.catalog_workspace_content.get_declarative_ldm(source_workspace_id)

# You can put LDM in a different workspace
sdk.catalog_workspace_content.put_declarative_ldm(target_workspace_id, declarative_ldm)

# Save LDM to file and version in git
sdk.catalog_workspace_content.store_declarative_ldm(source_workspace_id)

We recommend using the web UI to create the LDM, however it is possible to create the LDM using the API as well.

To create the LDM using API you need to:

  1. Generate the LDM
  2. Load the generated LDM definition to the workspace

Follow these steps:

  1. To generate the LDM, submit a POST request to /api/v1/actions/dataSources/<data-source-id>/generateLogicalModel. <data-source-id> is the ID of the data source.

    curl $HOST_URL/api/v1/actions/dataSources/demo-ds/generateLogicalModel \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -H "Authorization: Bearer $API_TOKEN" \
    -X POST \
    -d '{
        "separator": "__", 
        "viewPrefix": "mtt", 
        "grainPrefix": "gr", 
        "secondaryLabelPrefix": "ls", 
        "referencePrefix": "r"
        }' \
    | jq . > ldm.json
    

    As a result, a ldm.json file with a declarative definition of the LDM is generated.

  2. To load the LDM definition to the workspace, submit a PUT request to /api/v1/actions/workspaces/<workspace-id>/logicalModel. <workspace-id> is the ID of the workspace where you want to load the LDM to.

    curl $HOST_URL/api/v1/layout/workspaces/demo/logicalModel \
    -H "Authorization: Bearer $API_TOKEN" \
    -H "Content-Type: application/json" \
    -X PUT -d @ldm.json
    

Once you have created the LDM, you can start building dashboards and visualizations.