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
@@ -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
125
+
data_graph {
119
126
entity "account-entity" {
120
127
name = "account"
121
128
table_ref = "PRODUCTION.CUST.ACCOUNT"
122
129
primary_key = "id"
123
130
enrichment_enabled = true
124
131
}
125
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
126
140
profile {
127
-
# Relationships are nested under the profile
141
+
profile_folder = "PRODUCTION.segment"
142
+
type = segment:materialized
143
+
128
144
}
129
145
}
146
+
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
@@ -152,10 +170,24 @@ Example:
152
170
153
171
```python
154
172
data_graph {
155
-
#define entities
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.
@@ -177,8 +211,11 @@ Example:
177
211
data_graph {
178
212
#define entities
179
213
214
+
#define profile
180
215
profile {
181
-
#define profile
216
+
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,57 @@ 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 +296,8 @@ If you're relating entities with a junction table:
231
296
|`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
297
|`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
298
|`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]`. |
299
+
|`left_join_on`| Defines the relationship between the two entity tables: `[left entity slug].[column name] = [junction table column name]`. |
300
+
|`right_join_on`| Defines the relationship between the two entity tables: `[junction table column name] = [right entity slug].[column name]`. |
236
301
237
302
**Note:**`schema.table` is implied within the junction table column name and doesn't need to be provided.
238
303
@@ -356,3 +421,4 @@ Editing the Data Graph may lead to errors with data consumers. If there’s a br
356
421
## Next steps
357
422
358
423
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