Skip to content

Data Model Overview

The SEC-ETL API reads from a PostgreSQL data warehouse built on a star-schema design. Data flows through a 10-phase ETL pipeline that transforms raw SEC EDGAR XBRL filings into clean, standardized financial statements.

Star Schema

The warehouse uses a classic star-schema design:

Dimension Tables

TablePurpose
dim_conceptsXBRL concept metadata (qname, data type, balance, period type)
dim_entitiesCompany information (ticker, CIK, SIC, sector, industry)
dim_filingsFiling metadata (report type, fiscal dates)
dim_periodsFiscal periods (instant, start date, end date)
dim_unitsUnits of measure (USD, shares, etc.)
dim_standard_metric_mapMaps company XBRL QNames to canonical metric names

Fact Tables

TablePurpose
xbrl_factsRaw staging — facts as parsed from XBRL without FK constraints
fact_xbrl_factsNormalized fact table with full foreign keys to all dimension tables
fact_xbrl_derived_factsQuarterly facts with quality flags for flow vs. instant data
fact_calculated_metricsFinancial ratio results with A–F letter grades

TimescaleDB Hypertable

TablePurpose
market_pricesOHLCV price history from Yahoo Finance

Data Quality Pipeline

XBRL Filing → Parse → Stage → Normalize (FK resolution) → Compute Quarters → Map Metrics → Derive → Ratios

Each step includes audit checks and quarantine mechanisms. Facts that fail FK resolution are logged to error_log for review.

Key Design Decisions

  1. Values are stored as text to preserve XBRL’s arbitrary precision. Convert to numeric in your application.
  2. Quarterly data is derived — most XBRL filings report cumulative (YTD) flow data. The pipeline uses window functions to compute Q2–Q4 increments.
  3. Instant facts are deduplicated — when multiple filings report the same point-in-time fact, only the latest filing’s value is retained.
  4. Supersedence is honored — newer filings replace earlier filings for the same period and concept.