讨论数量:
如果用户的入学年级表是一个单独的表会怎么样?
Schema::create('student_grade', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('student_id')->comment('学生编号');
$table->string('grade')->comment('学生年级');
$table->string('class')->comment('学生班级');
$table->date('year')->comment('报道学年');
$table->tinyInteger('is_finish', '是否修完');
$table->timestamps();
});
- 每一年报道,这个表中多一条记录,记录年级,班级等信息。
- 每次查询学生年级或班级的时候,联查一下这个表,取最新的一条数据。
如果特殊情况呢?
- 留级的话,当年那一条数据 is_finish = 0,然后新的一年生成新的一条数据。
- 退学的话,当年那一条数据 is_finish = 0, 之后就没有数据。
推荐文章: