A MySQL server has been created on the CS department computing system for use b COS425 students. The server is named studentdb. For each student in COS 425 a database has been created on the server; this database is named using the student's user name. For example, since my username in the CS department is zhifengc my database name is zhifengc and the username for the database is also zhifengc. The password for your database has been set to be the same as your username. (This should be changed right away as discussed below.) You can access studentdb only if logged onto a CS department computer. Each COS 425 student who did not already have a CS account has bee given one for COS425 work. The login for the account is your Princeton user ID and th password has been set to your CIT password. You can access a CS machine by usin a workstation in one of the public areas in the CS department or by ssh'ing to "portal.cs.princeton.edu".
Please note that your work on studentdb will NOT be backed-up; this databas server is only for COS 425 exercises studentdb is through client programs "mysql", "mysqldump", and "mysqladmin" run on one of the CS machines. The following instructions assume you are logged onto the CS machine named bolle an show the bolle prompt (Other SPARC machines like rayban, oakley, also work.)
create table professors(name char(40) not null, department char(3), primary key(name));
create table courses(cname char(40) not null, prof char(40), primary key(cname), foreign key prof_ref(prof) references professors(name));
show tables;
describe courses;
insert into professors values ('A', 'COS');
insert into professors values ('B', 'MAT');
insert into courses values ('C1', 'A');
insert into courses values ('C2', 'B');
insert into courses values ('C3', 'A');
The following command will let mysql to execute all the commands in
batch mode:Reference: