mysql计算学生总成绩

MySQL是一种可靠的关系型数据库管理系统,广泛应用于许多领域,包括学生成绩管理。下面我们将介绍如何使用MySQL计算学生总成绩。

CREATE TABLE `student` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `score` ( `id` int(11) NOT NULL AUTO_INCREMENT, `student_id` int(11) NOT NULL, `course_name` varchar(255) NOT NULL, `score` float NOT NULL, PRIMARY KEY (`id`), KEY `fk_student_id` (`student_id`), CONSTRAINT `fk_student_id` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8;