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/data-graph/data-graph.md
+129-64
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
---
1
+
[---
2
2
title: Data Graph
3
3
plan: unify
4
4
beta: true
@@ -7,9 +7,9 @@ redirect_from:
7
7
- '/unify/linked-profiles/data-graph'
8
8
---
9
9
10
-
You can build a Data Graph that defines relationships between any entity data set in the warehouse and the Segment Profiles you send with Profiles Sync. Make this relational data accessible to marketers and business stakeholders to empower them with the data they need to create targeted and personalized customer engagements.
10
+
You can build a Data Graph that defines relationships between any entity data set in the warehouse and the Segment Profiles you send with [Profiles Sync](/docs/unify/profiles-sync/overview/). Make this relational data accessible to marketers and business stakeholders to empower them with the data they need to create targeted and personalized customer engagements.
11
11
12
-
Using the Data Graph, you can reflect your business in your data model. The Data Graph enables businesses to map and understand the relationships between different datasets about their customers (accounts, subscriptions, households, products), and tie rich entity context back to the profile.
12
+
Using the Data Graph, you can reflect your business in your data model. The Data Graph enables businesses to map and understand the relationships between different datasets about their customers (accounts, subscriptions, households, products), and tie rich entity context back to the profile.
13
13
14
14
> info ""
15
15
> Data Graph currently only supports workspaces in the United States.
@@ -62,76 +62,94 @@ This should be a Unify space with Profiles Sync already set up.
62
62
63
63
## Step 3: Build your Data Graph
64
64
65
-
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. Use the configuration language spec below to add models to build your Data Graph. The Data Graph currently supports 4 layers of depth, including the Profile entity. Warehouse schemas are case sensitive, so you'll need to reflect the schema, table, and column names based on how you case them in the warehouse.
65
+
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. Use the configuration language spec below to add models to build your Data Graph. The Data Graph currently supports 6 layers of depth, including the Profile entity. Warehouse schemas are case sensitive, so you'll need to reflect the schema, table, and column names based on how you case them in the warehouse.
66
66
67
67
To leverage the Data Graph auto-complete feature, begin typing or use the following keyboard shortcuts to autocomplete the profile_folder and table_ref properties.
68
68
69
-
- Mac: CtrlSpace
70
-
- Windows: AltEsc
69
+
- Mac: Ctrl + Space
70
+
- Windows: Alt + Esc
71
71
72
72
### Define entities
73
73
74
74
Use the parameters, definitions, and examples below to help you define entities.
75
75
76
-
#### Profile
77
-
78
-
The profile is a special class of entity that 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, such as profile traits.
76
+
#### Entity
79
77
80
-
The parameters are:
78
+
The first step in creating a Data Graph is to define your Entities. An entity is a stateful representation of a business object. The entity corresponds to a table in the warehouse.
|`profile_folder`| This is the fully qualified path of the folder or schema location for the profile tables. |
85
-
|`type`| Identifies the materialization methods of the profile tables (`segment:unmaterialized`, `segment:materialized`, `segment:dbt`). **Note:** Leveraging materialized profile tables optimizes warehouse compute costs. |
82
+
|`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`). |
83
+
|`name`| A unique label that displays throughout your Segment space. |
84
+
|`table_ref`| Defines 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]`. |
85
+
|`primary_key`| The unique identifier for the given table. Should be a column with unique values per row. |
86
+
| (Optional) `enrichment_enabled = true`| Indicates if you plan to also reference the entity table for [Linked Events](/docs/unify/data-graph/linked-events/). |
86
87
87
88
Example:
88
89
89
90
```python
90
-
# Define a profile entity
91
+
# Define an entity and optionally indicate if the entity will be referenced for Linked Events (event enrichment)
91
92
92
-
profile {
93
-
profile_folder = "PRODUCTION.segment"
94
-
type = segment:materialized
95
-
93
+
data_graph {
94
+
# Entities are nested under the data_graph
95
+
entity "account-entity" {
96
+
name = "account"
97
+
table_ref = "PRODUCTION.CUST.ACCOUNT"
98
+
primary_key = "id"
99
+
enrichment_enabled = true
100
+
}
101
+
102
+
entity "cart-entity" {
103
+
name = "cart"
104
+
table_ref = "PRODUCTION.CUST.CART"
105
+
primary_key = "id"
106
+
}
96
107
}
97
108
```
98
109
99
-
#### Entity
110
+
#### Profile
100
111
101
-
An entity is a stateful representation of a business object. The entity corresponds to a table in the warehouse that represents the entity.
112
+
Next, we define a Profile block, a special class of Entity that represents Segment Profiles. There can only be one profile for a Data Graph. The profile entity corresponds to the Profiles Sync tables and models, such as profile traits.
|`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`). |
107
-
|`name`| A unique label that displays throughout your Segment space. |
108
-
|`table_ref`| Defines 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]`. |
109
-
|`primary_key`| The unique identifier for the given table. Should be a column with unique values per row. |
110
-
| (Optional) `enrichment_enabled = true`| Indicates if you plan to also reference the entity table for [Linked Events](/docs/unify/data-graph/linked-events/). |
118
+
|`profile_folder`| This is the fully qualified path of the folder or schema location for the profile tables. |
119
+
|`type`| Identifies the materialization methods of the profile tables (segment:unmaterialized, segment:materialized) as defined in your Profiles Sync configuration. E.g. utilize segment:materialized if you are synching Profiles Materialized Tables. Note: Leveraging materialized profile tables optimizes warehouse compute costs. |
111
120
112
121
Example:
113
122
114
123
```python
115
-
# Define an entity and optionally indicate if the entity will be referenced for Linked Events (event enrichment)
116
124
117
-
data_graph {
118
-
# Entities are nested under the data_graph
119
-
entity "account-entity" {
120
-
name = "account"
121
-
table_ref = "PRODUCTION.CUST.ACCOUNT"
122
-
primary_key = "id"
123
-
enrichment_enabled = true
125
+
data_graph {
126
+
entity "account-entity" {
127
+
name = "account"
128
+
table_ref = "PRODUCTION.CUST.ACCOUNT"
129
+
primary_key = "id"
130
+
enrichment_enabled = true
131
+
}
132
+
133
+
entity "cart-entity" {
134
+
name = "cart"
135
+
table_ref = "PRODUCTION.CUST.CART"
136
+
primary_key = "id"
137
+
}
138
+
139
+
# Define a profile entity
140
+
profile {
141
+
profile_folder = "PRODUCTION.segment"
142
+
type = segment:materialized
143
+
144
+
}
124
145
}
125
146
126
-
profile {
127
-
# Relationships are nested under the profile
128
-
}
129
-
}
147
+
130
148
```
131
149
132
150
### Relate entities
133
151
134
-
Use the following relationship, parameters, and examples to help you relate entities.
152
+
Next, relate Profiles to Entities to model relationships between your Profiles and business datasets. Use the following relationship, parameters, and examples to help you relate entities.
135
153
136
154
#### Relate Entity to Profile
137
155
@@ -153,9 +171,23 @@ Example:
153
171
```python
154
172
data_graph {
155
173
#define entities
174
+
entity "account-entity" {
175
+
name = "account"
176
+
table_ref = "PRODUCTION.CUST.ACCOUNT"
177
+
primary_key = "id"
178
+
enrichment_enabled = true
179
+
}
180
+
181
+
entity "cart-entity" {
182
+
name = "cart"
183
+
table_ref = "PRODUCTION.CUST.CART"
184
+
primary_key = "id"
185
+
}
156
186
187
+
#define profile
157
188
profile {
158
-
#define profile
189
+
profile_folder = "PRODUCTION.segment"
190
+
type = segment:materialized
159
191
160
192
#Option 1: Relate account to profile with an external ID
161
193
relationship "user-accounts" {
@@ -166,6 +198,8 @@ data_graph {
166
198
join_key = "email_id"
167
199
}
168
200
}
201
+
}
202
+
}
169
203
```
170
204
**2. With a `trait`**: Define a profile trait that will be used to join the profile with your entity.
171
205
-`name`: The trait name that corresponds to a column name in your `profile_traits_updates` table.
@@ -176,9 +210,12 @@ Example:
176
210
177
211
data_graph {
178
212
#define entities
213
+
....
179
214
215
+
#define profile
180
216
profile {
181
-
#define profile
217
+
profile_folder = "PRODUCTION.segment"
218
+
type = segment:materialized
182
219
183
220
#Option 2: relate account to profile with a trait`
184
221
relationship: "user-accounts" {
@@ -194,29 +231,55 @@ data_graph {
194
231
```
195
232
196
233
#### Relate between entities
234
+
Finally, define relationships between Entities nested within the Profiles block.
|`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`). |
201
239
|`name`| A unique label that displays throughout your Segment space. |
202
240
|`related_entity`| References your already defined entity. |
203
-
|`join_on`| Defines relationships between two entity tables `[lefty entity name].[column name] = [right entity name].[column name]`. Note that the entity nameis a reference to the alias provided in the config and doesn't need to be the fully qualified table name. |
241
+
|`join_on`| Defines relationships between two entity tables `[lefty entity slug].[column name] = [right entity slug].[column name]`. Note that the entity slug is a reference to the alias provided in the config and doesn't need to be the fully qualified table name. |
@@ -231,8 +294,8 @@ If you're relating entities with a junction table:
231
294
|`junction_table`| Defines 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]`. |
232
295
|`table_ref`| Defines 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]`. |
233
296
|`primary_key`| The unique identifier on the join table, and should be a column with unique values per row. |
234
-
|`left_join_on`| Defines the relationship between the two entity tables: `[left entity name].[column name] = [junction table column name]`. |
235
-
|`right_join_on`| Defines the relationship between the two entity tables: `[junction table column name] = [right entity name].[column name]`. |
297
+
|`left_join_on`| Defines the relationship between the two entity tables: `[left entity slug].[column name] = [junction table column name]`. |
298
+
|`right_join_on`| Defines the relationship between the two entity tables: `[junction table column name] = [right entity slug].[column name]`. |
236
299
237
300
**Note:**`schema.table` is implied within the junction table column name and doesn't need to be provided.
238
301
@@ -245,6 +308,7 @@ Example:
245
308
246
309
data_graph {
247
310
#define entities
311
+
248
312
profile {
249
313
#define profile
250
314
...
@@ -291,26 +355,26 @@ data_graph {
291
355
join_key = "email_id"
292
356
}
293
357
294
-
#relate carts to account
295
-
relationship "user-carts" {
296
-
name = "Shopping Carts"
297
-
related_entity = "cart-entity"
298
-
join_on = "ACCOUNT.ID = CART.ACCOUNT_ID"
299
-
300
-
#relate carts to products with a junction table
301
-
relationship "products" {
302
-
name = "Purchased Products"
303
-
related_entity = "product-entity"
304
-
junction_table {
305
-
primary_key = "id"
306
-
table_ref = "PRODUCTION.CUSTOMER.CART_PRODUCT"
307
-
left_join_on = "CART.ID = CART_ID"
308
-
#schema.table is implied within the cart_id key
309
-
right_join_on = "PRODUCT_ID = PRODUCT.SKU"
310
-
}
358
+
#relate carts to account
359
+
relationship "user-carts" {
360
+
name = "Shopping Carts"
361
+
related_entity = "cart-entity"
362
+
join_on = "ACCOUNT.ID = CART.ACCOUNT_ID"
363
+
364
+
#relate carts to products with a junction table
365
+
relationship "products" {
366
+
name = "Purchased Products"
367
+
related_entity = "product-entity"
368
+
junction_table {
369
+
primary_key = "id"
370
+
table_ref = "PRODUCTION.CUSTOMER.CART_PRODUCT"
371
+
left_join_on = "CART.ID = CART_ID"
372
+
#schema.table is implied within the cart_id key
373
+
right_join_on = "PRODUCT_ID = PRODUCT.SKU"
311
374
}
312
375
}
313
376
}
377
+
}
314
378
}
315
379
316
380
#define account, product, and cart entities
@@ -356,3 +420,4 @@ Editing the Data Graph may lead to errors with data consumers. If there’s a br
356
420
## Next steps
357
421
358
422
After you've set up your Data Graph, get started with [Linked Events](/docs/unify/data-graph/linked-events/) and [Linked Audiences](/docs/engage/audiences/linked-audiences/).
0 commit comments