You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/unify/linked-profiles/data-graph.md
+61-21Lines changed: 61 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,11 @@ hidden: true
6
6
7
7
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.
8
8
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.
10
11
11
12
> 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/).
13
14
14
15
## Prerequisites
15
16
@@ -27,8 +28,22 @@ To use the Data Graph, you'll need the following:
27
28
> warning ""
28
29
> Don't send any personal health information (PHI) with the Data Graph.
29
30
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:
Linked Profiles uses [Segment's Reverse ETL](#) infrastructure to pull data from your warehouse.
30
40
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
32
47
33
48
> success ""
34
49
> 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:
39
54
- This should be the Unify space with Profiles Sync already set up.
40
55
2. Click **Connect warehouse**.
41
56
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**.
43
59
44
60
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.
45
61
46
-
## Build your Data Graph
62
+
## Step 3: Build your Data Graph
47
63
48
64
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.
49
65
@@ -62,6 +78,9 @@ While you can delete relationships or entities from the Data Graph, these relati
62
78
63
79
Use the parameters, defintions, and examples below to help you define entities.
64
80
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
+
65
84
#### Profile
66
85
67
86
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
75
94
profile {
76
95
profile_folder = "segment"
77
96
materialization = "none"
78
-
# for the pilot, use "none" for materialization
97
+
79
98
}
80
99
```
81
100
82
101
#### Entity
83
102
84
103
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:
85
104
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]`.
88
108
-`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/).
90
110
91
111
92
112
```python
@@ -108,12 +128,19 @@ Use the following relationship, parameters, and examples to help you relate enti
108
128
109
129
#### Relate Entity to Profile
110
130
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.
112
133
-`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
+
117
144
118
145
```python
119
146
data_graph {
@@ -122,22 +149,34 @@ data_graph {
122
149
profile {
123
150
#define profile
124
151
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"
128
156
external_id {
129
157
type = "email"
130
158
join_key = "email_id"
131
159
}
132
160
}
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
+
}
133
171
}
134
172
}
135
173
```
136
174
137
175
#### Relate between entities
138
176
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.
141
180
-`join_on`: Define relationships between two entity tables `[lefty entity name].[column name] = [right entity name].[column name]`.
142
181
- 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.
143
182
@@ -149,7 +188,8 @@ data_graph {
149
188
...
150
189
#relate account to carts
151
190
relationship "Carts" {
152
-
related_entity = "cart"
191
+
name = "Shopping Carts"
192
+
related_entity = "cart-entity"
153
193
join_on = "account.id = cart.account_id"
154
194
}
155
195
}
@@ -160,7 +200,7 @@ data_graph {
160
200
161
201
If you're relating entities with a junction table:
162
202
-`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]`
164
204
-`primary_key`: The unique identifier on the join table and should be a column with unique values per row.
165
205
-`left_join_on`: Define relationship between the two entity tables `[left entity name].[column name] = [junction table column name]`.
166
206
-`right_join_on`: Define relationship between the two entity tables `[junction table column name] = [right entity name].[column name]`.
0 commit comments