-- Script zum Überprüfen der echten INDEX-Namen
USE trainingsdiary;

-- Alle vorhandenen Tabellen anzeigen
SELECT '=== VORHANDENE TABELLEN ===' as info;
SHOW TABLES;

-- Alle vorhandenen INDEX und Keys anzeigen (mit echten Namen)
SELECT '=== ALLE INDEX UND KEYS ===' as info;
SELECT 
    TABLE_NAME,
    INDEX_NAME,
    COLUMN_NAME,
    NON_UNIQUE,
    SEQ_IN_INDEX
FROM INFORMATION_SCHEMA.STATISTICS 
WHERE TABLE_SCHEMA = 'trainingsdiary' 
ORDER BY TABLE_NAME, INDEX_NAME, SEQ_IN_INDEX;

-- Anzahl der Keys pro Tabelle
SELECT '=== KEYS PRO TABELLE ===' as info;
SELECT 
    TABLE_NAME,
    COUNT(*) as key_count
FROM INFORMATION_SCHEMA.STATISTICS 
WHERE TABLE_SCHEMA = 'trainingsdiary' 
GROUP BY TABLE_NAME
ORDER BY key_count DESC;

-- Gesamtanzahl der Keys
SELECT '=== GESAMTANZAHL KEYS ===' as info;
SELECT 
    COUNT(*) as total_keys
FROM INFORMATION_SCHEMA.STATISTICS 
WHERE TABLE_SCHEMA = 'trainingsdiary';

-- Nur die Tabellen mit den meisten Keys anzeigen (Problem-Tabellen)
SELECT '=== PROBLEM-TABELLEN (MEHR ALS 10 KEYS) ===' as info;
SELECT 
    TABLE_NAME,
    COUNT(*) as key_count
FROM INFORMATION_SCHEMA.STATISTICS 
WHERE TABLE_SCHEMA = 'trainingsdiary' 
GROUP BY TABLE_NAME
HAVING COUNT(*) > 10
ORDER BY key_count DESC;
