SHARE
TWEET

Untitled

a guest Aug 25th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. drop table if exists students;
  2. create table students (                                          
  3.    first varchar not null,                                                          
  4.    last varchar not null,                                                          
  5.    id int not null,                                                                
  6.    primary key (id));
  7.  
  8. drop table if exists courses;
  9. create table courses (                                          
  10.    coursenum varchar not null,                                                    
  11.    title varchar not null,                                                        
  12.    description varchar not null,                                                  
  13.    primary key (coursenum));    
  14.  
  15. drop table if exists enrollments;
  16. create table enrollments (                                      
  17.    id int not null,                                                                
  18.    coursenum varchar not null,                                                    
  19.    semester varchar not null,                                                      
  20.    year int not null,                                                              
  21.    primary key (id,coursenum,semester,year),                                      
  22.    foreign key (id) references students(id),                                      
  23.    foreign key (coursenum) references courses(coursenum));
  24.  
  25. insert into students values ('Harry', 'Potter', 1);
  26. insert into students values ('Hermione', 'Granger', 2);
  27. insert into students values ('Ron', 'Weasley', 3);
  28.  
  29. insert into courses values ('P140', 'Intro to Potions', 'A course in potions.');
  30. insert into courses values ('DA101', 'Intro to Dark Arts', 'A course in Dark Arts.');
  31. insert into courses values ('HB100', 'Intro to Herbology', 'A course in Herbology.');
  32.  
  33. insert into enrollments values (1, 'DA101', 'Fall', 2010);
  34. insert into enrollments values (1, 'P140', 'Fall', 2010);
  35. insert into enrollments values (2, 'P140', 'Fall', 2011);
  36. insert into enrollments values (3, 'P140', 'Fall', 2011);
  37. insert into enrollments values (3, 'P140', 'Fall', 2012);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top