Skip to content

Commit a9bc281

Browse files
authored
Update data-graph.md
1 parent 8080efe commit a9bc281

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

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

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -145,24 +145,26 @@ data_graph {
145145

146146
Now define your relationships across your entities. The Data Graph supports three types of relationships:
147147
- Profile-to-entity relationship. This is the first level of relationships
148-
- 1:many relationships
149-
- Many:many relationships
148+
- 1:many relationship
149+
- Many:many relationship
150150

151-
All relationship types require you to define the `relationship` slug,`name`, and `related_entity`. Each type of relationship has unique `join_on` conditions.
151+
All relationship types require you to define the relationship slug, label, and related entity. Each type of relationship has unique join on conditions.
152152

153153
#### Relationship #1: Define profile-to-entity relationship
154-
This is the first level of relationships and a unique type of relationship between an entity and the Segment profile entity.
154+
This is the first level of relationships and a unique type of relationship between Segment profile entity and a related entity.
155155

156156
| Parameters | Definition |
157157
| ----------- | --------------------------------------------------------------------- |
158158
| `relationship` | An immutable slug for the relationship, and will be treated as a delete if you make changes. The slug must be in all lowercase, and supports dashes or underscores (e.g. `user-account` or `user_account`) |
159159
| `name` | A label displayed throughout your Segment space for Linked Events, Linked Audiences, etc. This name can be modified at any time |
160160
| `related_entity` | References your already defined entity |
161161

162-
To define a profile-to-entity relationship, choose to join on one of the following:
163-
**Option 1:** Use the `external_id` block to join the profile entity with `user_id`, `email`, or `phone` as the identifier on the entity table
162+
To define a profile-to-entity relationship, choose to join on one of the following:
163+
164+
**Option 1 (Most common):** Use the `external_id` block to join the profile entity with `user_id`, `email`, or `phone` as the identifier on the entity table
164165
- `type`: Identify the external ID type (`email`, `phone`, `user id`). This corresponds to the `external_id_type` column in your Profiles Sync `external_id_mapping` table
165166
- `join_key`: This is the column on the entity table that you are matching to the external identifier
167+
166168
**Option 2:** Use the `traits` block to join with a profile trait on the entity table
167169
- `name`: The trait name that corresponds to a column name in your Profiles Sync `profile_traits_updates` table
168170
- `join_key`: This is the column on the entity table that you are matching to the trait
@@ -177,23 +179,24 @@ data_graph {
177179
}
178180

179181
# Define additional entities...
180-
182+
183+
# Note: Relationships are nested
181184
profile {
182185
profile_folder = "PRODUCTION.SEGMENT"
183186
type = "segment:materialized"
184187

185-
# Relationships are nested
188+
# Relate accounts table to the profile
186189
relationship "user-accounts" {
187190
name = "Premium Accounts"
188191
related_entity = "account-entity"
189192

190-
# Option 1: Relate account to profile with an external ID
193+
# Option 1: Join with an external ID block
191194
external_id {
192195
type = "email"
193196
join_key = "EMAIL_ID"
194197
}
195198

196-
# Option 2: Relate account to profile with a trait
199+
# Option 2: Join with a trait block
197200
trait {
198201
name = "cust_id"
199202
join_key = "ID"
@@ -204,7 +207,7 @@ data_graph {
204207
```
205208

206209
#### Relationship #2: Define a 1:many relationship
207-
To define a 1:many relationship, define the join on between the two entity tables.
210+
For 1:many relationships, define the join on between the two entity tables using the spec below.
208211

209212
| Parameters | Definition |
210213
| ----------- | --------------------------------------------------------------------- |
@@ -224,16 +227,16 @@ data_graph {
224227
}
225228

226229
# Define additional entities...
227-
230+
231+
# Note: Relationships are nested
228232
profile {
229233
profile_folder = "PRODUCTION.SEGMENT"
230234
type = "segment:materialized"
231-
232-
# Relationships are nested
235+
233236
relationship "user-accounts" {
234237
...
235238

236-
# Define 1:many relationship by joining on right and left entity tables
239+
# Define 1:many relationship between accounts and carts
237240
relationship "user-carts" {
238241
name = "Shopping Carts"
239242
related_entity = "carts-entity"
@@ -245,18 +248,20 @@ data_graph {
245248
```
246249

247250
#### Relationship #3: Define many:many relationship
251+
For many:many relationships, define the join on between the two entity tables with the `junction_table`.
252+
253+
> warning ""
254+
> Attributes from a junction table are not referenceable via the Linked Audience Builder. If a marketer would like to filter upon a column on the junction table, you must define the junction as an entity and define a relationship.
248255
249256
| Parameters | Definition |
250257
| ----------- | --------------------------------------------------------------------- |
251258
| `relationship` | An immutable slug for the relationship, and will be treated as a delete if you make changes. The slug must be in all lowercase, and supports dashes or underscores (e.g. `user-account` or `user_account`) |
252259
| `name` | A label displayed throughout your Segment space for Linked Events, Linked Audiences, etc. This name can be modified at any time |
253260
| `related_entity` | References your already defined entity |
254261

255-
To define a many:many relationship, define the join on between the two entity tables with the `junction_table`.
256-
> warning ""
257-
> Attributes from a junction table are not referenceable via the Linked Audience Builder. If a marketer would like to filter upon a column on the junction table, you must define the junction as an entity and define a relationship.
258-
262+
**Junction table spec**
259263
| Parameters | Definition |
264+
| ----------- | --------------------------------------------------------------------- |
260265
| `table_ref` | Defines the fully qualified table reference to the join table.: `[database name].[schema name].[table name]` Segment flexibly supports tables, views and materialized views |
261266
| `primary_key` | The unique identifier for the given table. Must be a column with unique values per row |
262267
| `left_join_on` | Define the relationship between the left entity table and the junction table: `[left entity slug].[column name] = [junction table column name]`. `[schema].[table]` is implied within the junction table column name, so you do not need to define it again |
@@ -268,18 +273,18 @@ To define a many:many relationship, define the join on between the two entity ta
268273

269274
data_graph {
270275
# Define entities
271-
276+
277+
# Note: Relationships are nested
272278
profile {
273279
# Define profile
274-
275-
# Relationships are nested
280+
276281
relationship "user-accounts" {
277282
...
278283

279284
relationship "user-carts" {
280285
...
281286

282-
# Define many:many relationship by joining entity tables with junction table
287+
# Define many:many relationship between carts and products
283288
relationship "products" {
284289
name = "Purchased Products"
285290
related_entity = "product-entity"
@@ -292,7 +297,7 @@ data_graph {
292297
}
293298
}
294299
}
295-
}
300+
}
296301
}
297302

298303
```
@@ -404,12 +409,12 @@ A data consumer refers to a Segment feature (e.g. Linked Events, Linked Audience
404409
- Under **Unify > Data Graph**, click the **Data consumers** tab
405410
- Click into a node on the Data Graph preview and a side sheet will pop up with the list of data consumers for the respective relationship
406411

407-
### Edits that may cause breaking and potential breaking changes
412+
### Understand changes that may cause breaking and potential breaking changes
408413

409414
Upon saving changes to your Data Graph, a modal will pop up to warn of breaking and/or potential breaking changes to your data consumers. You must acknowledge and click **Confirm and save** in order to proceed.
410415
- **Definite breaking change**: Occurs when deleting an entity or relationship that is being referenced by a data consumer. Data consumers affected by breaking changes will fail on the next run. Note: The entity and relationship `slug` are immutable and treated as a delete if you make changes. You can modify the `label`.
411416
-**Potential breaking change**: Editing the Data Graph may lead to errors with data consumers. If there’s a breaking change, the data consumer will fail on the next run. Unaffected data consumers will continue to work.
412417

413-
### Warehouse breaking changes
418+
### Detect warehouse breaking changes
414419

415420
Segment has a service that regularly scans and monitors the Data Graph for changes that occur in your warehouse that may break components of the Data Graph and/or data consumers, such as when the table being referenced gets deleted from your warehouse, the primary key column no longer exists, etc. An alert banner will be displayed on the Data Graph landing page. The banner will be removed once the issues are resolved in your warehouse and/or the Data Graph.

0 commit comments

Comments
 (0)