-- 检查评价表数据
-- 2026-01-25

-- 1. 检查评价表是否存在
SHOW TABLES LIKE 'review';

-- 2. 检查评价表结构
DESC review;

-- 3. 检查评价数据总数
SELECT COUNT(*) as total FROM review WHERE deleted = 0;

-- 4. 查看最近的评价数据
SELECT 
    r.id,
    r.order_id,
    r.user_id,
    r.teacher_id,
    r.student_id,
    r.service_score,
    r.quality_score,
    r.punctuality_score,
    r.content,
    r.reply_content,
    r.create_time
FROM review r
WHERE r.deleted = 0
ORDER BY r.create_time DESC
LIMIT 10;

-- 5. 检查关联数据完整性
SELECT 
    r.id as review_id,
    r.order_id,
    o.order_no,
    r.user_id,
    u.nickname as parent_name,
    r.teacher_id,
    t.teacher_name,
    r.student_id,
    s.student_name
FROM review r
LEFT JOIN `order` o ON r.order_id = o.id
LEFT JOIN user u ON r.user_id = u.id
LEFT JOIN teacher t ON r.teacher_id = t.id
LEFT JOIN student s ON r.student_id = s.id
WHERE r.deleted = 0
LIMIT 5;
