-- Stonks Oracle - Trend evidence mappings -- Links trend_windows to the documents that contributed as evidence, -- storing the evidence type (supporting/opposing), rank score, and -- weight breakdown for explainability and drill-down queries. -- Requirements: 6.5, 10.4 CREATE TABLE trend_evidence ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), trend_window_id UUID NOT NULL REFERENCES trend_windows(id) ON DELETE CASCADE, document_id UUID NOT NULL, evidence_type VARCHAR(20) NOT NULL DEFAULT 'supporting', -- supporting | opposing rank_score FLOAT DEFAULT 0.0, weight_component FLOAT DEFAULT 0.0, impact_component FLOAT DEFAULT 0.0, recency_component FLOAT DEFAULT 0.0, confidence_component FLOAT DEFAULT 0.0, sentiment_value FLOAT DEFAULT 0.0, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() ); CREATE INDEX idx_trend_evidence_trend ON trend_evidence(trend_window_id); CREATE INDEX idx_trend_evidence_doc ON trend_evidence(document_id); CREATE INDEX idx_trend_evidence_type ON trend_evidence(trend_window_id, evidence_type);