数据仓库是企业数据分析的基础设施。 ## 数据仓库架构 数据源 -> ETL -> ODS -> DWD -> DWS -> ADS -> BI ## 维度建模 ```sql CREATE TABLE fact_orders ( order_id BIGINT, customer_key INT, product_key INT, amount DECIMAL(10,2) ); CREATE TABLE dim_customer ( customer_key INT, customer_id VARCHAR(20), name VARCHAR(100), city VARCHAR(50) ); ``` ## ETL with Apache Airflow ```python with DAG('etl_pipeline', schedule='@daily') as dag: t1 = PythonOperator(task_id='extract', python_callable=extract) t2 = PythonOperator(task_id='transform', python_callable=transform) t3 = PythonOperator(task_id='load', python_callable=load) t1 >> t2 >> t3 ``` 数据仓库设计的核心:以业务需求为导向,确保数据质量和时效性。