Related and Events Table
In the e-commerce example, a related table could be an Orders table with columns for:
GMV
: Total amount for the orderorder_id
: Unique id for the orderphone_number
: Phone number for the order for communication purposesaddress
: Shipping address for the ordercustomer_name
: Customer name for the orderplaced_on
: Order created datemodified_at
: Order modified date
For these events, an events model might include columns for:
id
: Unique event idtimestamp
: Timestamp for occurrence of the eventevent_name
: Event nameuser_id
: User id for the customer who did the event. This is the column the events table gets joined on with users table
An events table might include your app events:
account_created
account_updated
page_viewed
login_completed
Relationships
When you create related or event tables, you simultaneously set up their relationships.
In the e-commerce example, let's say you want to create an audience of customers who ordered a specific product or who did a particular event action on your app. You need to define a relationship between your primary table (users) and your related table (orders) and events table (events).
Under the hood, Sortment generates SQL JOINs
between your tables. To make this possible, you must create relationships by selecting the foreign keys between your tables.
Directionality
Relationships are directional. That means you can create and view relationships starting from a parent to a child table.
For example, 1:many relationship can be created from users to events
The schema overview page shows the schema from the perspective of primary table; labels are displayed accordingly.
Last updated