-- 检查赛事基础数据是否完整
USE martial_db;

-- 1. 检查赛事信息
SELECT
    '赛事信息' AS '检查项',
    COUNT(*) AS '记录数'
FROM martial_competition
WHERE id = 200;

-- 2. 检查参赛者数据
SELECT
    '参赛者数据' AS '检查项',
    COUNT(*) AS '记录数'
FROM martial_athlete
WHERE competition_id = 200;

-- 3. 检查场地数据
SELECT
    '场地数据' AS '检查项',
    COUNT(*) AS '记录数'
FROM martial_venue
WHERE competition_id = 200;

-- 4. 检查项目数据
SELECT
    '项目数据' AS '检查项',
    COUNT(*) AS '记录数'
FROM martial_project
WHERE id IN (
    SELECT DISTINCT project_id
    FROM martial_athlete
    WHERE competition_id = 200
);

-- 5. 检查赛事时间配置
SELECT
    id AS '赛事ID',
    competition_name AS '赛事名称',
    competition_start_time AS '开始时间',
    competition_end_time AS '结束时间',
    CASE
        WHEN competition_start_time IS NULL THEN '⚠ 未配置'
        WHEN competition_end_time IS NULL THEN '⚠ 未配置'
        ELSE '✓ 已配置'
    END AS '时间配置状态'
FROM martial_competition
WHERE id = 200;

-- 6. 详细检查参赛者项目分布
SELECT
    p.project_name AS '项目名称',
    p.type AS '项目类型(1=个人,2=双人,3=集体)',
    COUNT(*) AS '参赛人数'
FROM martial_athlete a
LEFT JOIN martial_project p ON a.project_id = p.id
WHERE a.competition_id = 200
GROUP BY p.id, p.project_name, p.type
ORDER BY p.type, p.project_name;

-- 7. 检查场地详情
SELECT
    id AS '场地ID',
    venue_name AS '场地名称',
    venue_type AS '场地类型',
    capacity AS '容量'
FROM martial_venue
WHERE competition_id = 200;

-- 总结
SELECT
    '数据检查完成' AS '状态',
    NOW() AS '检查时间';
