CREATE TABLE user (
    id INT AUTO_INCREMENT PRIMARY KEY,
    nickname VARCHAR(50) NOT NULL,
    phone_number VARCHAR(15) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    identity ENUM('teacher', 'student') NOT NULL,
    status BOOLEAN NOT NULL
);

INSERT INTO user (nickname, phone_number, password, identity, status) VALUES
('Alice', '1', '$2b$12$okY88GrzlUHb/Ox1ENwtqeBUnE0bgMOCPy.UKmFaTnu3El7EYX8Em', 'student', TRUE);



CREATE TABLE menu_items (
    id INT AUTO_INCREMENT PRIMARY KEY,
    menu_name VARCHAR(100),
    path VARCHAR(255),
    role ENUM('student', 'teacher'),
    `order` INT
);


INSERT INTO menu_items (menu_name, role, path, `order`) VALUES
('课程信息', 'student', '/course-info', 1),
('课程签到', 'student', '/attendance', 2),
('公告信息', 'student', '/announcement', 3),
('签到提醒', 'student', '/attendance-reminder', 4);


INSERT INTO menu_items (menu_name, role, path, `order`) VALUES
('课程类别', 'teacher', '/course-category', 1),
('课程信息', 'teacher', '/course-info', 2),
('课程签到', 'teacher', '/attendance', 3),
('签到提醒', 'teacher', '/attendance-reminder', 4);


CREATE TABLE courses (
    course_id INT AUTO_INCREMENT PRIMARY KEY,
    course_name VARCHAR(255) NOT NULL,
    course_code VARCHAR(50) NOT NULL,
    instructor_name VARCHAR(255) NOT NULL,
    credits INT,
    description TEXT,
    attendance_info TEXT
);

INSERT INTO courses (course_name, course_code, instructor_name, credits, description, attendance_info) VALUES
('高级数学', 'MTH101', 'John Doe', 4, '高级数学是一门研究数学理论的课程，包括微积分、线性代数等', 'JSON或其他格式的签到数据'),
('物理学', 'PHY101', 'Jane Smith', 3, '物理学是自然科学的一部分，涉及物质和能量的性质和现象', 'JSON或其他格式的签到数据'),
('化学', 'CHEM101', 'Emily Davis', 4, '化学是研究物质的组成、结构、性质和变化规律的科学', 'JSON或其他格式的签到数据'),
('英语', 'ENG101', 'Mark Wilson', 3, '英语课程旨在提高学生的语言技能，包括阅读、写作、听力和口语', 'JSON或其他格式的签到数据'),
('生物学', 'BIO101', 'David Johnson', 3, '生物学是自然科学的一部分，研究生命和生物体', 'JSON或其他格式的签到数据'),
('计算机科学', 'CS101', 'Alice Brown', 4, '计算机科学是研究信息和计算机系统的理论基础', 'JSON或其他格式的签到数据'),
('心理学', 'PSY101', 'Chris Green', 3, '心理学是科学研究心理和行为的科学', 'JSON或其他格式的签到数据'),
('历史', 'HIS101', 'Paula Adams', 2, '历史课程涵盖了世界历史的主要事件、人物和发展', 'JSON或其他格式的签到数据'),
('艺术', 'ART101', 'Laura White', 2, '艺术课程探索各种艺术形式和表达方式', 'JSON或其他格式的签到数据'),
('经济学', 'ECO101', 'Peter Parker', 3, '经济学是研究生产、分配和消费资源的社会科学', 'JSON或其他格式的签到数据');


CREATE TABLE attendance_records (
    record_id INT AUTO_INCREMENT PRIMARY KEY,
    course_id INT NOT NULL,
    student_id INT NOT NULL,
    date DATE NOT NULL,
    status ENUM('present', 'absent', 'late', 'excused'),
    FOREIGN KEY (course_id) REFERENCES courses(course_id),
    FOREIGN KEY (student_id) REFERENCES students(student_id)
);

CREATE TABLE class_courses (
    class_course_id INT AUTO_INCREMENT PRIMARY KEY,
    class_id INT NOT NULL,
    course_id INT NOT NULL,
    FOREIGN KEY (class_id) REFERENCES classes(class_id),
    FOREIGN KEY (course_id) REFERENCES courses(course_id)
);

CREATE TABLE classes (
    class_id INT AUTO_INCREMENT PRIMARY KEY,
    class_name VARCHAR(255) NOT NULL,
    major VARCHAR(255)
);

CREATE TABLE students (
    student_id INT AUTO_INCREMENT PRIMARY KEY,
    student_number VARCHAR(20) NOT NULL,
    student_name VARCHAR(255) NOT NULL,
    class_id INT,
    FOREIGN KEY (class_id) REFERENCES classes(class_id)
);

INSERT INTO students (student_name, student_number,class_id) VALUES ('王伟',202300001000, 8);
INSERT INTO students (student_name, student_number,class_id) VALUES ('李娜',202300001001, 6);
INSERT INTO students (student_name, student_number,class_id) VALUES ('张伟', 202300001002, 5);
INSERT INTO students (student_name, student_number,class_id) VALUES ('刘洋', 202300001003, 8);
INSERT INTO students (student_name, student_number,class_id) VALUES ('陈敏', 202300001004, 7);
INSERT INTO students (student_name, student_number,class_id) VALUES ('杨静', 202300001005, 1);
INSERT INTO students (student_name, student_number,class_id) VALUES ('赵媛媛',202300001006, 4);
INSERT INTO students (student_name, student_number,class_id) VALUES ('黄进', 202300001007, 6);
INSERT INTO students (student_name, student_number,class_id) VALUES ('周杰',202300001008, 2);
INSERT INTO students (student_name, student_number,class_id) VALUES ('吴琳',202300001009, 1);
INSERT INTO students (student_name, student_number,class_id) VALUES ('徐涛',202300001010, 5);
INSERT INTO students (student_name, student_number,class_id) VALUES ('孙怡', 202300001011, 3);
INSERT INTO students (student_name, student_number,class_id) VALUES ('朱元璋',202300001012, 2);
INSERT INTO students (student_name, student_number,class_id) VALUES ('马云', 202300001013, 4);
INSERT INTO students (student_name, student_number,class_id) VALUES ('胡雪', 202300001014, 7);
INSERT INTO students (student_name, student_number,class_id) VALUES ('郭敬明', 202300001015, 9);
INSERT INTO students (student_name, student_number,class_id) VALUES ('林芳', 202300001016, 6);
INSERT INTO students (student_name, student_number,class_id) VALUES ('段誉', 202300001017, 4);
INSERT INTO students (student_name, student_number,class_id) VALUES ('曹操', 202300001018, 2);
INSERT INTO students (student_name, student_number,class_id) VALUES ('刘备', 202300001019, 2);