-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.txt
41 lines (35 loc) · 1.3 KB
/
db.txt
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
create table course (
cid integer not null,
cname varchar(40) not null,
primary key (cid) );
insert into course values ('1', 'math');
insert into course values ('2', 'data structure');
create table student (
sid integer AUTO_INCREMENT,
sname varchar(20) not null,
primary key (sid) );
insert into student values (1000, 'Jones');
insert into student values (1001, 'jack');
insert into student values (1002, 'jason');
insert into student values (1003, 'tom');
insert into student values (1004, 'kevin');
insert into student values (1005, 'jerry');
insert into student values (1006, 'Zack');
create table enrollment (
sid integer not null,
cid integer not null,
primary key (sid, cid)
); // foreign key (sid) references student (sid)
insert into enrollment values (1000, 1);
insert into enrollment values (1002, 1);
insert into enrollment values (1003, 1);
insert into enrollment values (1004, 2);
insert into enrollment values (1001, 1);
insert into enrollment values (1005, 2);
insert into enrollment values (1006, 1);
insert into enrollment values (1006, 2);
////
select student.sid, student.sname, course.cname
from student, course, enrollment
where student.sid = enrollment.sid
and course.cid = enrollment.cid;