学员管理系统

里程碑

    1项目需求

       2大致方案

    3数据库建表

    4开发

会议纪要

    参会人员

    讨论事情

    TODO

项目分析

    1学生

    id name class_id(fk)

    2班级

    id name

    3老师

    id name

    teacher2class(多对多)

    id class_id teacher_id

建表结构

  -班级表:

      create table class(

          id int auto_increment primary key,

          name char(10) not null

      )engine=innodb default charset='utf8';

 

  -老师表

      create table teacher(

          id int anto_increment prinary key,

          name char(10) not null

          )engine=innoodb default charset='utf8';

  -学生表:

      create table student(

        id int auto_increment primary key,

        name char(10) not null,

        class_id int,foreign key(class_id) references

class(id) on delete cascade on update cascade on update cascade

      )engine=innodb default charset='utf8';

    -teacher2class

      create table teacher2class(

         id int auto_increment primary key,

         class_id int, foreign key(class_id)references

 

  )

class(id) on delete cascade on update cascade,
teacher_id int, foreign key(teacher_id) references teacher(id) on delete cascade on update cascade
)engine=innodb default charset="utf8";

班级表的增删改查
查 --> class_list --> "select id, name from class"
增 --> add_class --> "insert into class(name) VALUES (%s)", [class_name, ]
删 --> delete_class --> "delete from class WHERE id = %s", [class_id, ]
改 --> edit_class --> "update class set name=%s WHERE id = %s", [class_name, class_id, ]

GET:

URL: 127.0.0.1:8000/class_list/?name=alex&age=18

request.GET.get("name")
request.GET.get("age")


POST:

<form class="form-horizontal" action="/add_class/" method="post">
<div class="form-group">
<label for="inputclassname" class="col-sm-2 control-label">班级名称</label>
<div class="col-sm-10">
<input name="class_name" type="text" class="form-control" id="inputclassname" placeholder="班级名称">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">提交</button>
</div>
</div>
</form>

posted @ 2017-11-27 16:18  程绩  阅读(129)  评论(0编辑  收藏  举报