-- Table for tracking downloads
CREATE TABLE downloads (
    id INT AUTO_INCREMENT PRIMARY KEY,
    downloaded_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    ip_address VARCHAR(45),
    user_agent TEXT
);

-- Table for tracking page visits
CREATE TABLE page_visits (
    id INT AUTO_INCREMENT PRIMARY KEY,
    page VARCHAR(255) NOT NULL,
    url TEXT NOT NULL,
    referrer TEXT,
    visited_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    ip_address VARCHAR(45),
    user_agent TEXT
);

-- Table for storing reviews
CREATE TABLE reviews (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    rating TINYINT NOT NULL CHECK (rating >= 1 AND rating <= 5),
    review TEXT NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    status ENUM('pending', 'approved') DEFAULT 'approved'
);

-- Insert initial download count (if needed)
INSERT INTO downloads (ip_address, user_agent) VALUES 
('127.0.0.1', 'Initial count'),
('127.0.0.1', 'Initial count'),
('127.0.0.1', 'Initial count');
-- Repeat this 100,000 times for initial count (you might want to do this programmatically)