HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ubuntu-8gb-hel1-1 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64
User: www-data (33)
PHP: 8.1.32
Disabled: NONE
Upload Files
File: /var/www/html/obaasimaghana/database/create_course_reviews.sql
USE obaasima_db;

CREATE TABLE IF NOT EXISTS course_reviews (
    id int(11) NOT NULL AUTO_INCREMENT,
    course_id int(11) NOT NULL,
    user_id int(11) NOT NULL,
    rating int(11) NOT NULL CHECK (rating >= 1 AND rating <= 5),
    review text DEFAULT NULL,
    created_at timestamp NOT NULL DEFAULT current_timestamp(),
    updated_at timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
    PRIMARY KEY (id),
    UNIQUE KEY unique_user_course_review (user_id, course_id),
    KEY course_id (course_id),
    CONSTRAINT course_reviews_ibfk_1 FOREIGN KEY (course_id) REFERENCES courses (id) ON DELETE CASCADE,
    CONSTRAINT course_reviews_ibfk_2 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;