Skip to content

Commit 8080efe

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

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

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

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,25 @@ data_graph {
326326
primary_key = "ID"
327327
enrichment_enabled = true
328328
}
329+
330+
entity "household-entity" {
331+
name = "household"
332+
table_ref = "PRODUCTION.CUST.HOUSEHOLD"
333+
primary_key = "HOUSEHOLD_ID"
334+
}
335+
336+
entity "subscription-entity" {
337+
name = "subscription"
338+
table_ref = "PRODUCTION.CUST.SUBSCRIPTION"
339+
primary_key = "SUB_ID"
340+
}
329341

330342
# Define the profile entity
331343
profile {
332344
profile_folder = "PRODUCTION.SEGMENT"
333345
type = "segment: materialized"
334346

335-
# Relate entity table to the profile by joining with an external ID block
347+
# First branch - relate accounts table to the profile by joining with an external ID block
336348
relationship "user-accounts" {
337349
name = "Premium Accounts"
338350
related_entity = "account-entity"
@@ -341,13 +353,13 @@ data_graph {
341353
join_key = "EMAIL_ID"
342354
}
343355

344-
# Define 1:many relationship by joining left and right entity tables
356+
# Define 1:many relationship between accounts and carts
345357
relationship "user-carts" {
346358
name = "Shopping Carts"
347359
related_entity = "cart-entity"
348360
join_on = "ACCOUNT.ID = CART.ACCOUNT_ID"
349361

350-
# Define many:many relationship by joining left and right entity tables with a junction table
362+
# Define many:many relationship between carts and products
351363
relationship "products" {
352364
name = "Purchased Products"
353365
related_entity = "product-entity"
@@ -360,6 +372,21 @@ data_graph {
360372
}
361373
}
362374
}
375+
376+
# Second branch - relate households table to the profile by joining with an external ID block
377+
relationship "user-households" {
378+
name = "Households"
379+
related_entity = "household-entity"
380+
external_id {
381+
type = "email"
382+
join_key = "EMAIL_ID"
383+
}
384+
385+
# Define 1:many relationship between households and subscriptions
386+
relationship "user-subscriptions" {
387+
name = "Subscriptions"
388+
related_entity = "subscription-entity"
389+
join_on = "HOUSEHOLD.SUB_ID = SUBSCRIPTION.HOUSEHOLD_ID"
363390
}
364391
}
365392

0 commit comments

Comments
 (0)