You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
815 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

-- 学生表
CREATE TABLE students (
id INT PRIMARY KEY AUTO_INCREMENT,
student_id VARCHAR(20) UNIQUE NOT NULL, -- 学号
name VARCHAR(50) NOT NULL, -- 姓名
major VARCHAR(100) NOT NULL, -- 专业
score FLOAT DEFAULT 0, -- 积分
random_count INT DEFAULT 0, -- 随机点名次数
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- 点名记录表
CREATE TABLE attendance (
id INT PRIMARY KEY AUTO_INCREMENT,
student_id VARCHAR(20) NOT NULL, -- 关联学生学号
attendance_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- 点名时间
status ENUM('present', 'absent') DEFAULT 'present', -- 出勤状态
answer_score FLOAT DEFAULT 0, -- 回答问题得分0.5~3或-1
mode ENUM('random', 'order') NOT NULL, -- 点名模式
FOREIGN KEY (student_id) REFERENCES students(student_id)
);