PageSourceSearch

https://posthog.com/component---src-pages-context-warehouse-data-modeling-tsx-085d42db6c4e15463051.js

js posthog.com collected 2026-09-24 07:59:30 UTC 7,760 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkposthog_com=self.webpackChunkposthog_com||[]).push([[2349],{23369:function(e,s,t){t.r(s),t.d(s,{default:function(){return h}});var o=t(40435),a=t(36501),r=t(33721),n=t(8462),i=t(2212),l=t(56380),d=t(86070);const c=()=>(0,d.jsx)(r.s,{items:a.b.children});function h(){return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(n.Ay,{title:"Data modeling - PostHog context warehouse",description:"Learn how to model your data in PostHog",image:"images/og/cdp.jpg"}),(0,d.jsxs)(o.Ay,{leftSidebar:(0,d.jsx)(c,{}),title:"Data modeling",children:[(0,d.jsx)("p",{children:"PostHog provides powerful tools to clean, enrich, and model your data into the exact shape you need for downstream use."}),(0,d.jsxs)("div",{className:"dark:bg-dark bg-accent border border-input p-4 rounded",children:[(0,d.jsxs)("p",{className:"!mt-0",children:[(0,d.jsx)("strong",{children:"Note:"})," PostHog modeling is in"," ",(0,d.jsx)("span",{className:"rounded-sm bg-highlight py-0.5 ml-2 px-1 text-xs font-bold text-red dark:text-yellow",children:"Beta"}),". It's great for product teams who have light modeling workloads today, with support for advanced use-cases in active development."]}),(0,d.jsxs)("p",{className:"!mb-0",children:["If you have advanced modeling needs, we recommend you connect your favorite modeling tooling such as"," ",(0,d.jsx)(i.A,{to:"https://www.getdbt.com/",external:!0,children:"dbt"})," ","to your PostHog Trino warehouse."]})]}),(0,d.jsx)("h3",{children:"Step 1: Create reusable queries with views"}),(0,d.jsxs)("p",{children:["PostHog's modeling workflow starts with creating ",(0,d.jsx)(i.A,{to:"/docs/data-warehouse/views",children:"views"})," ","for your data. This allows you to define custom transformations, joins, and aggregations using HogQL (PostHog's SQL dialect), which can be used as reliable, structured foundations for data analysis."]}),(0,d.jsx)("h3",{children:"Step 2: Create models for scalability"}),(0,d.jsxs)("p",{children:["Then, save those views into ",(0,d.jsx)(i.A,{to:"/docs/data-warehouse/views/materialize",children:"models"})," (aka materialized views) in the data warehouse for fast querying, cost saving, and integration with BI tools."]}),(0,d.jsx)("p",{children:"Models are refreshed on a schedule, as frequently as every 5 minutes or as long as monthly."}),(0,d.jsx)(l.G,{imageLight:"https://res.cloudinary.com/dmukukwp6/image/upload/w_1600,c_limit,q_auto,f_auto/Clean_Shot_2025_08_26_at_13_48_10_2x_88dc4ae252.png",imageDark:"https://res.cloudinary.com/dmukukwp6/image/upload/w_1600,c_limit,q_auto,f_auto/Clean_Shot_2025_08_26_at_13_48_31_2x_16e9dbe683.png",alt:"Materialize view",classes:"rounded",zoom:!1}),(0,d.jsx)("p",{children:"You can view your models in a DAG, or a visual graph of all model dependencies."}),(0,d.jsx)(l.G,{imageLight:"https://res.cloudinary.com/dmukukwp6/image/upload/w_1600,c_limit,q_auto,f_auto/Post_Hog_modeling_dag_8f59938982.png",imageDark:"https://res.cloudinary.com/dmukukwp6/image/upload/w_1600,c_limit,q_auto,f_auto/Post_Hog_modeling_dag_8f59938982.png",alt:"DAG view",classes:"rounded",zoom:!1}),(0,d.jsx)("h3",{children:"Features"}),(0,d.jsxs)("ul",{children:[(0,d.jsxs)("li",{children:[(0,d.jsx)("strong",{children:"Join multiple sources:"})," Combine data from different tables and sources"]}),(0,d.jsxs)("li",{children:[(0,d.jsx)("strong",{children:"Create calculated fields:"})," Add derived metrics and computed columns"]}),(0,d.jsxs)("li",{children:[(0,d.jsx)("strong",{children:"Build aggregations:"})," Create summary tables and rollups"]}),(0,d.jsxs)("li",{children:[(0,d.jsx)("strong",{children:"Save as models:"})," Store complex queries as reusable views, materialized for speed"]}),(0,d.jsxs)("li",{children:[(0,d.jsx)("strong",{children:"Version control:"})," Track changes to your data models over time"," ",(0,d.jsx)("span",{className:"rounded-sm bg-highlight py-0.5 ml-2 px-1 text-xs font-bold text-red dark:text-yellow",children:"Coming soon"})]}),(0,d.jsxs)("li",{children:[(0,d.jsx)("strong",{children:"Git & vcs integrations:"})," Sync your models with your Git repository for collaboration"," ",(0,d.jsx)("span",{className:"rounded-sm bg-highlight py-0.5 ml-2 px-1 text-xs font-bold text-red dark:text-yellow",children:"Coming soon"})]}),(0,d.jsxs)("li",{children:[(0,d.jsx)("strong",{children:"DAG visualizations:"})," view a graph of all model node relationships, and execute workflows based on lineage"," ",(0,d.jsx)("span",{className:"rounded-sm bg-highlight py-0.5 ml-2 px-1 text-xs font-bold text-red dark:text-yellow",children:"Coming soon"})]})]}),(0,d.jsx)("p",{children:(0,d.jsx)(i.A,{to:"/docs/data-warehouse/views/materialize",state:{newWindow:!0},children:"Learn how to model your data →"})}),(0,d.jsx)("hr",{}),(0,d.jsx)("h2",{children:"Common modeling use cases"}),(0,d.jsx)("h3",{children:"User identity resolution"}),(0,d.jsxs)("ul",{children:[(0,d.jsx)("li",{children:"Merge anonymous and identified user sessions"}),(0,d.jsx)("li",{children:"Link user IDs across different systems"}),(0,d.jsx)("li",{children:"Create a unified customer profile"})]}),(0,d.jsx)("h3",{children:"Revenue attribution"}),(0,d.jsxs)("ul",{children:[(0,d.jsx)("li",{children:"Connect product usage to revenue data from Stripe"}),(0,d.jsx)("li",{children:"Calculate customer lifetime value"}),(0,d.jsx)("li",{children:"Attribute revenue to specific features or campaigns"})]}),(0,d.jsx)("h3",{children:"Data standardization"}),(0,d.jsxs)("ul",{children:[(0,d.jsx)("li",{children:"Normalize event names across different platforms"}),(0,d.jsx)("li",{children:"Standardize timestamp formats and timezones"}),(0,d.jsx)("li",{children:"Map custom properties to a consistent schema"})]}),(0,d.jsx)("h3",{children:"Privacy compliance"}),(0,d.jsxs)("ul",{children:[(0,d.jsx)("li",{children:"Automatically remove or hash PII"}),(0,d.jsx)("li",{children:"Implement data retention policies"}),(0,d.jsx)("li",{children:"Apply GDPR/CCPA compliance rules"})]}),(0,d.jsx)("hr",{}),(0,d.jsx)("h2",{children:"Semantic layer: define metrics once, trust them everywhere"}),(0,d.jsx)("p",{children:"Ask three AI tools \"what's our MRR?\" and you can get three different numbers, because the definition lives in people's heads."}),(0,d.jsx)("p",{children:"The semantic layer fixes this: it's a per-project catalog of governed metrics, table certifications, and reviewed joins that every agent, and human, reads from the same place. Define a metric once, approve it once, and every session returns the same number."}),(0,d.jsx)("p",{children:(0,d.jsx)(i.A,{to:"/docs/semantic-layer",children:"Read the Docs →"})})]})]})}},36501:function(e,s,t){t.d(s,{b:function(){return o}});t(63629);const o={name:"PostHog context warehouse",url:"/context-warehouse",children:[{name:"PostHog context warehouse"},{name:"Overview",url:"/context-warehouse"},{name:"Start here",url:"/context-warehouse/use-cases"},{name:"Is PostHog warehouse native?",url:"/context-warehouse/warehouse-native"},{name:"The context gap report",url:"/the-context-gap-report"},{name:"Data tools"},{name:"Managed Warehouse",url:"/context-warehouse/managed-warehouse"},{name:"PostHog AI",url:"/context-warehouse/posthog-ai"},{name:"Data sources & import (ELT)",url:"/context-warehouse/sources"},{name:"CDP",url:"/cdp"},{name:"Data modeling",url:"/context-warehouse/data-modeling"},{name:"SQL editor",url:"/context-warehouse/sql-editor"},{name:"Business intelligence (BI)",url:"/context-warehouse/business-intelligence"},{name:"Reverse ETL & export",url:"/context-warehouse/reverse-etl-export"},{name:"Integrations"},{name:"Integration library",url:"/context-warehouse/integrations-library"}]}}}]);
2//# sourceMappingURL=component---src-pages-context-warehouse-data-modeling-tsx-085d42db6c4e15463051.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.