Skip to content

Commit 65da6ce

Browse files
committed
Add additional context to Data Graph
1 parent 4a884b7 commit 65da6ce

File tree

1 file changed

+61
-21
lines changed

1 file changed

+61
-21
lines changed

src/unify/linked-profiles/data-graph.md

Lines changed: 61 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ hidden: true
66

77
With Linked Profiles, you can build a Data Graph that defines relationships between any data set in the warehouse and the Segment Profiles you send with Profiles Sync.
88

9-
Use the Data Graph to define relationships between data sets and give marketers access to data to target, personalize, and analyze customer experiences.
9+
10+
Define relationships between data from your warehouse to give marketers access to data to target, personalize, and analyze customer experiences.
1011

1112
> success ""
12-
> Segment's Data Graph powers [Linked Events](#) and [Linked Audiences](#).
13+
> Segment's Data Graph powers [Linked Events](/docs/unify/linked-profiles/linked-events/) and [Linked Audiences](/docs/unify/linked-profiles/linked-audiences/).
1314
1415
## Prerequisites
1516

@@ -27,8 +28,22 @@ To use the Data Graph, you'll need the following:
2728
> warning ""
2829
> Don't send any personal health information (PHI) with the Data Graph.
2930
31+
## Step 1: Set up your data warehouse
32+
33+
Before setting up the Data Graph, you'll need to set up your data warehouse. Use the setup guides below to get started:
34+
35+
- [Snowflake Setup](/docs/unify/linked-profiles/setup-guides/snowflake-setup/)
36+
- [Redshift Setup]((/docs/unify/linked-profiles/setup-guides/redshift-setup/))
37+
- [BigQuery Setup]((/docs/unify/linked-profiles/setup-guides/bigquery-setup/))
38+
39+
Linked Profiles uses [Segment's Reverse ETL](#) infrastructure to pull data from your warehouse.
3040

31-
## Connect your warehouse to the Data Graph
41+
To track what data has been sent to Segment on previous syncs, Segment stores delta/diffs in tables within a single schema called `_segment_reverse_etl` within your data warehouse.
42+
43+
You can choose which database/project within your warehouse this data lives in.
44+
45+
46+
## Step 2: Connect your warehouse to the Data Graph
3247

3348
> success ""
3449
> Before getting started with the Data Graph, be sure to [set up your Snowflake permissions](/unify/linked-profiles/setup-guides/snowflake-setup/).
@@ -39,11 +54,12 @@ To connect your warehouse to the data graph:
3954
- This should be the Unify space with Profiles Sync already set up.
4055
2. Click **Connect warehouse**.
4156
3. Select your warehouse type.
42-
4. Enter your warehouse credentials. Then, test your connection and click **Save**.
57+
4. Enter your warehouse credentials.
58+
5. Test your connection, then click **Save**.
4359

4460
Depending on the size of your warehouse, it may take anywhere from a few minutes to an hour for Segment to sync your warehouse metadata to cache before you're able to set up your Data Graph.
4561

46-
## Build your Data Graph
62+
## Step 3: Build your Data Graph
4763

4864
The Data Graph is a semantic layer that represents a subset of relevant business data that you'll use for audience targeting and personalization in downstream tools.
4965

@@ -62,6 +78,9 @@ While you can delete relationships or entities from the Data Graph, these relati
6278

6379
Use the parameters, defintions, and examples below to help you define entities.
6480

81+
> warning ""
82+
> Snowflake schemas are case sensitive. You'll need to use the uppercase schema, table, and column names if that's how you have it in Snowflake.
83+
6584
#### Profile
6685

6786
The profile is a special class of entity. The profile is always defined at the top of the Data Graph, and there can only be one profile for a Data Graph. The profile entity corresponds to the Profiles Sync tables and models. The parameters are:
@@ -75,18 +94,19 @@ The profile is a special class of entity. The profile is always defined at the t
7594
profile {
7695
profile_folder = "segment"
7796
materialization = "none"
78-
# for the pilot, use "none" for materialization
97+
7998
}
8099
```
81100

82101
#### Entity
83102

84103
An entity is a stateful representation of a business object. The entity corresponds to a table in the warehouse that represents that entity. The parameters are:
85104

86-
- `entity`: This should be a unique name for the entity.
87-
- `table_ref`: Define the table reference.
105+
- `entity`: A unique slug for the entity, which is immutable and treated as a delete if you make changes. The slug must be in all lowercase, and supports dashes or underscores (for example, `account-entity` or `account_entity`).
106+
- `name`: A unique label which will display across the app.
107+
- `table_ref`: Define the table reference. In order to specify a connection to your table in snowflake, a fully qualified table reference is required `[database name].[schema name].[table name]`.
88108
- `primary_key`: This is the unique identifier for the given table and should be a column with unique values per row.
89-
- (Optional) `enrichment_enabled` = true: Indicate if you plan to also reference the entity table for Linked Events.
109+
- (Optional) `enrichment_enabled = true`: Indicate if you plan to also reference the entity table for [Linked Events](/docs/unify/linked-profiles/linked-events/).
90110

91111

92112
```python
@@ -108,12 +128,19 @@ Use the following relationship, parameters, and examples to help you relate enti
108128
109129
#### Relate Entity to Profile
110130

111-
- `relationship`: A unique name to be referenced by the Audience builder.
131+
- `relationship`: A unique slug for the relationship, which is immutable and treated as a delete if you make changes. The slug must be in all lowercase and will support dashes or underscores (for example, `user-account` or `user_account`).
132+
- `name`: This should be a unique label that displays throughout your Segment space.
112133
- `related_entity`: Reference your already defined entity.
113-
- `external_id`: Define the external ID that will be used to join the profile with your entity.
114-
- `type`: Identify the external ID type (`email`, `phone`, `user id`).
115-
- This corresponds to the `external_id_type` column in your `external_id_mapping` table.
116-
- `join_key`: This is the column on the entity table that you are matching to the external identifier.
134+
135+
A profile can be related to an entity in two ways:
136+
1. With an `external_id`: Define the external ID that will be used to join the profile with your entity.
137+
- `type`: Identify the external ID type (`email`, `phone`, `user id`).
138+
- This corresponds to the `external_id_type` column in your `external_id_mapping` table.
139+
- `join_key`: This is the column on the entity table that you are matching to the external identifier.
140+
2. With a `trait`: Define a profile trait that will be used to join the profile with your entity.
141+
- `name`: The trait name that corresponds to a column name in your `profile_traits_updates` table.
142+
- `join_key`: This is the column on the entity table that you are matching to the trait.
143+
117144

118145
```python
119146
data_graph {
@@ -122,22 +149,34 @@ data_graph {
122149
profile {
123150
#define profile
124151

125-
#relate profile to account
126-
relationship "Accounts" {
127-
related_entity = "account"
152+
# Option 1: relate profile to account with an `external_id`
153+
relationship "user-accounts" {
154+
name = "Premium Accounts"
155+
related_entity = "account-entity"
128156
external_id {
129157
type = "email"
130158
join_key = "email_id"
131159
}
132160
}
161+
162+
# Option 2: relate profile to account with a `trait`
163+
relationship: "user-accounts" {
164+
name = "Premium Accounts"
165+
related_entity = "account-entity"
166+
trait {
167+
name = "cust_id"
168+
join_key = "id"
169+
}
170+
}
133171
}
134172
}
135173
```
136174

137175
#### Relate between entities
138176

139-
- `relationship`: A unique name that will be referenced in the Audience builder.
140-
- `related_entity`: Your already defined entity.
177+
- `relationship`: A unique slug for the relationship, which is immutable and treated as a delete if you make changes. The slug must be in all lowercase and will support dashes or underscores (for example, `user-account` or `user_account`).
178+
- `name`: A unique label that displays athroughout your Segment space.
179+
- `related_entity`: Reference the slug of your already defined entity.
141180
- `join_on`: Define relationships between two entity tables `[lefty entity name].[column name] = [right entity name].[column name]`.
142181
- Note that the entity name is a reference to the alias provided in the config and doesn't need to be the fully qualified table name.
143182

@@ -149,7 +188,8 @@ data_graph {
149188
...
150189
#relate account to carts
151190
relationship "Carts" {
152-
related_entity = "cart"
191+
name = "Shopping Carts"
192+
related_entity = "cart-entity"
153193
join_on = "account.id = cart.account_id"
154194
}
155195
}
@@ -160,7 +200,7 @@ data_graph {
160200

161201
If you're relating entities with a junction table:
162202
- `Junction_table`: Define relationships between two entities tables joined by a junction table.
163-
- `table_ref`: Define the table reference to the join table.
203+
- `table_ref`: Define the table reference to the join table. In order to specify a connection to your table in Snowflake, a fully qualified table reference is required `[database name].[schema name].[table name]`
164204
- `primary_key`: The unique identifier on the join table and should be a column with unique values per row.
165205
- `left_join_on`: Define relationship between the two entity tables `[left entity name].[column name] = [junction table column name]`.
166206
- `right_join_on`: Define relationship between the two entity tables `[junction table column name] = [right entity name].[column name]`.

0 commit comments

Comments
 (0)