-- ============================================
-- 유량제어 그룹 테이블 DDL
-- ============================================

-- ============================================
-- Oracle
-- ============================================

-- 유량제어 그룹 테이블
CREATE TABLE inflow_control_group (
    group_id              VARCHAR2(36)   NOT NULL,  -- UUID
    group_name            VARCHAR2(100),
    threshold             NUMBER(10),
    threshold_per_second  NUMBER(10),
    threshold_time_unit   VARCHAR2(12),
    use_yn                VARCHAR2(1)    DEFAULT '1',
    modified_by           VARCHAR2(50),
    modified_at           TIMESTAMP,
    CONSTRAINT pk_inflow_control_group PRIMARY KEY (group_id)
);

COMMENT ON TABLE inflow_control_group IS '유량제어 그룹';
COMMENT ON COLUMN inflow_control_group.group_id IS '그룹 ID (UUID)';
COMMENT ON COLUMN inflow_control_group.group_name IS '그룹명';
COMMENT ON COLUMN inflow_control_group.threshold IS '임계치';
COMMENT ON COLUMN inflow_control_group.threshold_per_second IS '초당 임계치';
COMMENT ON COLUMN inflow_control_group.threshold_time_unit IS '임계치 TimeUnit (SEC, MIN, HOU, DAY, MON)';
COMMENT ON COLUMN inflow_control_group.use_yn IS '사용여부 (1:사용, 0:미사용)';
COMMENT ON COLUMN inflow_control_group.modified_by IS '수정자';
COMMENT ON COLUMN inflow_control_group.modified_at IS '수정일시';

-- 그룹-인터페이스 매핑 테이블
CREATE TABLE inflow_control_group_mapping (
    interface_id          VARCHAR2(100)  NOT NULL,
    group_id              VARCHAR2(36)   NOT NULL,
    use_yn                VARCHAR2(1)    DEFAULT '1',
    modified_by           VARCHAR2(50),
    modified_at           TIMESTAMP,
    CONSTRAINT pk_inflow_ctrl_grp_mapping PRIMARY KEY (interface_id)
);

COMMENT ON TABLE inflow_control_group_mapping IS '유량제어 그룹 매핑';
COMMENT ON COLUMN inflow_control_group_mapping.interface_id IS '인터페이스 ID';
COMMENT ON COLUMN inflow_control_group_mapping.group_id IS '그룹 ID';
COMMENT ON COLUMN inflow_control_group_mapping.use_yn IS '사용여부 (1:사용, 0:미사용)';
COMMENT ON COLUMN inflow_control_group_mapping.modified_by IS '수정자';
COMMENT ON COLUMN inflow_control_group_mapping.modified_at IS '수정일시';

-- 인덱스
CREATE INDEX idx_inflow_ctrl_grp_map_grp ON inflow_control_group_mapping (group_id);

