Skip to content

Instantly share code, notes, and snippets.

@lordhumunguz
Last active June 7, 2023 16:58
Show Gist options
  • Save lordhumunguz/7b04e751c16993f427a621664bd29d12 to your computer and use it in GitHub Desktop.
Save lordhumunguz/7b04e751c16993f427a621664bd29d12 to your computer and use it in GitHub Desktop.

Audience

  • All analytics engineers, data scientists, heads of data in Commerce.
  • BI Ergonomics, SQL Ergonomics

Rules

  • Prefer more human language. Try to say it in a sentence, would someone say that in conversation?
  • Verbs should generally be avoided in column names, unless it's a timestamp in past tense.
  • When a desired column name clashes with an existing Shopify concept, avoid it. Let the Shopify name remain, and create an alternative.
  • Any internal fields should have _{{column}} prefix and should be excluded in the customer facing outputs.
  • ? Avoid of, in, by if possible.
  • ? cost of returns vs. returns cost. fulfillment cost vs. cost of fulfillment
  • We should try to make the data eng's life easier by: saving them a join, saving them a cast that are going to be commonly done.
  • ?: Never put real-world contextual info into column names: order_stripe_id vs. order_platform_id. Or do we do the ther way?
  • Any comma separated columns (eg. discount_codes, order_tags, customer_tags) will be case-unified, and trimmed, and sorted ASC.
  • Do we always do upper or lower case for everything?

IDs

  • object_id_secondary: should probably be renamed to object_platform_id. The id should name should be descriptive.

Dates

  • created_at is always timestamp in UTC (reporting tz will always be provided)
  • created_datetime is timezone casted (miliseconds)

Groupings

  • channel is too broad? Should it be distribution_channel or something else?

{{dimension}}order_index order_index_by{{dimension}} order_index_{{dimension}}

{{modifier}}order_index_by{{dimension}}

What's a fact?

  • Customer is someone who bought from you ever
  • Lead is someone who's never bought from you, but gave you their contact info

What's an opinion?

  • Active Customer: someone who IS a customer AND have some other specific traits

What's best practice? (can be taught as a part of a curriculum)

  • Repeat Customer: their initial order was valid, and their subsequent order was also valid

What's a fact?

  • Order is when a customer exchanges monetary for goods from a brand
  • The order payment must be processed

What's an opinion?

What's best practice? (can be taught as a part of a curriculum)

Core Objects

  • orders
  • subscriptions
  • customers

Modified Core Objects

  • subscription_orders, order group by order_type
  • subscribers vs. subscription_customer vs. customer by subscriber_status
    • subscriber: core object that have a default filter on it == customer where subscriber_status = 'ACTIVE'
    • subscription_customer:
    • customer by subscriber_status:

Does an order always map to one subscription? Or can it have many subscriptions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment