-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabase.sql
More file actions
50 lines (41 loc) · 1.63 KB
/
Copy pathDatabase.sql
File metadata and controls
50 lines (41 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
drop table if exists course_db;
drop table if exists student_course_maping;
drop table if exists student_db;
/*==============================================================*/
/* Table: course_db */
/*==============================================================*/
create table course_db
(
code int not null,
name varchar(64),
is_elective int,
credit int,
primary key (code)
);
alter table course_db comment '课程信息';
/*==============================================================*/
/* Table: student_course_maping */
/*==============================================================*/
create table student_course_maping
(
id int not null,
student_id int,
course_id int,
primary key (id)
);
/*==============================================================*/
/* Table: student_db */
/*==============================================================*/
create table student_db
(
id int not null,
name varchar(64),
class varchar(64),
credit int,
primary key (id)
);
alter table student_db comment '学生信息';
alter table student_course_maping add constraint FK_Reference_1 foreign key (course_id)
references course_db (code) on delete restrict on update restrict;
alter table student_course_maping add constraint FK_Reference_2 foreign key (student_id)
references student_db (id) on delete restrict on update restrict;