-- RDS_STUDIO_PROJECT_CLIP table for storing clip-project relationships from RDS
-- This table is populated by the Glue job which dumps data from RDS to S3 
-- and then loads it into Snowflake
-- Clustered by partition date and hour for optimal query performance
CREATE TRANSIENT TABLE IF NOT EXISTS {studio_project_clip_table_name} CLUSTER BY (p_date, p_hour) (
    -- Primary identifier
    ID NUMBER(38,0),                                    -- Unique clip-project relationship identifier
    
    -- Relationship metadata
    CLIP_ID VARCHAR(255),                               -- ID of the clip
    STUDIO_PROJECT_ID VARCHAR(255),                     -- ID of the studio project
    
    -- Timestamps
    CREATED_AT TIMESTAMP_TZ(9),                         -- When the relationship was created
    UPDATED_AT TIMESTAMP_TZ(9),                         -- Last update timestamp
    
    -- Partitioning columns for optimization
    P_DATE DATE,                                        -- Partition date based on created_at
    P_HOUR NUMBER(38,0)                                 -- Partition hour (0-23) based on created_at
);

