DROP TABLE IF EXISTS `tz_ai_sample`;
CREATE TABLE `tz_ai_sample`
(
    `id`               bigint       NOT NULL AUTO_INCREMENT COMMENT '主键',
    `sample_file_id`   bigint       NOT NULL COMMENT '样本文件id',
    `sample_name`      varchar(64)  NULL     DEFAULT '' COMMENT '样本名称',
    `sample_time`      varchar(16)  NULL     DEFAULT '' COMMENT '样本时长',
    `sample_mine_type` varchar(16)  NULL     DEFAULT '' COMMENT '样本格式',
    `sample_size`      varchar(16)  NULL     DEFAULT '' COMMENT '样本大小',
    `remark`           varchar(255) NULL     DEFAULT '' COMMENT '样本注释',
    `creator`          varchar(64)  NULL     DEFAULT '' COMMENT '创建者',
    `create_time`      datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`          varchar(64)  NULL     DEFAULT '' COMMENT '更新者',
    `update_time`      datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`          bit(1)       NOT NULL DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`        bigint       NOT NULL DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_create_time` (`create_time` ASC) USING BTREE
) ENGINE = InnoDB COMMENT = '样本库';


DROP TABLE IF EXISTS `tz_ai_sample_tag_relate`;
CREATE TABLE `tz_ai_sample_tag_relate`
(
    `id`            bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
    `sample_id`     bigint NOT NULL COMMENT '样本id',
    `sample_tag_id` bigint NOT NULL COMMENT '样本标签id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT = '样本-标签关联表';



DROP TABLE IF EXISTS `tz_ai_sample_tag`;
CREATE TABLE `tz_ai_sample_tag`
(
    `id`          bigint      NOT NULL AUTO_INCREMENT COMMENT '主键',
    `tag_name`    varchar(64) NULL     DEFAULT '' COMMENT '标签名称',
    `creator`     varchar(64) NULL     DEFAULT '' COMMENT '创建者',
    `create_time` datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`     varchar(64) NULL     DEFAULT '' COMMENT '更新者',
    `update_time` datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`     bit(1)      NOT NULL DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`   bigint      NOT NULL DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_create_time` (`create_time` ASC) USING BTREE
) ENGINE = InnoDB COMMENT = '样本标签库';

DROP TABLE IF EXISTS `tz_ai_sample_tag_group`;
CREATE TABLE `tz_ai_sample_tag_group`
(
    `id`          bigint      NOT NULL AUTO_INCREMENT COMMENT '主键',
    `group_name`  varchar(64) NULL     DEFAULT '' COMMENT '分组名称',
    `creator`     varchar(64) NULL     DEFAULT '' COMMENT '创建者',
    `create_time` datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`     varchar(64) NULL     DEFAULT '' COMMENT '更新者',
    `update_time` datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`     bit(1)      NOT NULL DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`   bigint      NOT NULL DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_create_time` (`create_time` ASC) USING BTREE
) ENGINE = InnoDB COMMENT = '样本标签分组库';



DROP TABLE IF EXISTS `tz_ai_sample_tag_group_relate`;
CREATE TABLE `tz_ai_sample_tag_group_relate`
(
    `id`                  bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
    `sample_tag_id`       bigint NOT NULL COMMENT '样本标签id',
    `sample_tag_group_id` bigint NOT NULL COMMENT '样本标签分组id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT = '样本标签-分组关联表';
