zoukankan      html  css  js  c++  java
  • Python全栈之路-MySQL(二)

    MySQL实践

    create table class (              
    cid int not null auto_increment primary key,              
    caption char(20) not null
    )engine=innodb default charset=utf8;
    
    
    create table student (              
    sid int not null auto_increment primary key,              
    sname char(20) not null,
    gender char(1) not null,
    class_id int not null,
    constraint fk_student_class foreign key (class_id) references class(cid)
    )engine=innodb default charset=utf8;
    
    create table teacher (              
    tid int not null auto_increment primary key,              
    tname char(20) not null
    )engine=innodb default charset=utf8;
    
    create table course (              
    cid int not null auto_increment primary key,              
    cname char(20) not null,
    teacher_id int not null,
    constraint fk_course_teacher foreign key (teacher_id) references teacher(tid)
    )engine=innodb default charset=utf8;
    
    create table score (              
    sid int not null auto_increment primary key,              
    student_id int not null,
    course_id int not null,
    number int not null,
    constraint fk_score_student foreign key (student_id) references student(sid),
    constraint fk_score_course foreign key (course_id) references course(cid)
    )engine=innodb default charset=utf8;
    
    
    
    
    insert into class(caption) values('三年二班'),('一年三班'),('三年一班');
    
    insert into student(sname,gender,class_id) values('钢蛋','女',1),('铁锤','铁锤',1),('山炮','男',2);
    
    
    insert into teacher(tname) values('波多'),('苍空'),('饭岛');
    
    insert into course(cname,teacher_id) values('生物',1),('体育',1),('物理',2);
    
    insert into score(student_id,course_id,number) values(1,1,60),(1,2,59),(2,2,100);
    
    
  • 相关阅读:
    Ruby
    WebGL的第二个小程序
    wegGL的第一个小程序
    Node.js介绍
    接口隔离原则(Interface Sepreation Principle)
    参数
    字段/属性
    接口和抽象类
    javascript中的事件
    线性回归算法-4.多元线性回归算法
  • 原文地址:https://www.cnblogs.com/wanyuetian/p/6946009.html
Copyright © 2011-2022 走看看