-- SQL Script for IT Party Code Challenge
-- Run this in your database management tool (e.g., phpMyAdmin)

-- 1. Create table for tracking solved puzzles
CREATE TABLE IF NOT EXISTS `solved_puzzles` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `guest_id` INT NOT NULL,
    `puzzle_id` INT NOT NULL,
    `solved_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    UNIQUE KEY `unique_solve` (`guest_id`, `puzzle_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- 2. Ensure guest table has points column (just in case)
-- ALTER TABLE `guests` ADD COLUMN IF NOT EXISTS `points` INT DEFAULT 0;

-- Optional: If you need to check existing guests
-- SELECT * FROM guests;
