Advertisement
junh1024

Some Uni

Nov 18th, 2015
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.81 KB | None | 0 0
  1.  
  2.  
  3. DROP TABLE course ;
  4. CREATE TABLE course
  5. (
  6. CourseID            INT                     NOT NULL AUTO_INCREMENT ,
  7. Title       VARCHAR(64)                             NOT NULL,
  8. Credits         INT                         NOT NULL,
  9. PRIMARY KEY (CourseID)
  10. );
  11.  
  12.  
  13. INSERT INTO course VALUES (1050, 'Chemistry',  3 );
  14. INSERT INTO course VALUES (4022, 'Microeconomics',  3 );
  15. INSERT INTO course VALUES (4041, 'Macroeconomics',  3 );
  16. INSERT INTO course VALUES (1045, 'Calculus',  4 );
  17. INSERT INTO course VALUES (3141, 'Trigonometry',  4 );
  18. INSERT INTO course VALUES (2021, 'Composition',  3 );
  19. INSERT INTO course VALUES (2042, 'Literature',  4 );
  20.  
  21. SELECT * FROM course;
  22.  
  23. DROP TABLE student ;
  24. CREATE TABLE student
  25. (
  26. ID          INT                         NOT NULL AUTO_INCREMENT ,
  27. FirstMidName        VARCHAR(64)                             NOT NULL,
  28. LastName        VARCHAR(64)                         NOT NULL,
  29. EnrolmentDate       datetime                        NOT NULL        ,
  30. PRIMARY KEY(ID)
  31. );
  32.  
  33.  
  34.  
  35. INSERT INTO student VALUES (DEFAULT, 'Carson', 'Alexander', '2010-12-31 23:59:59' );
  36. INSERT INTO student VALUES (DEFAULT, 'Meredith', 'Alonso', '2010-12-31 23:59:59' );
  37. INSERT INTO student VALUES (DEFAULT, 'Arturo', 'Anand', '2010-12-31 23:59:59' );
  38. INSERT INTO student VALUES (DEFAULT, 'Gytis', 'Barzdukas', '2010-12-31 23:59:59' );
  39. INSERT INTO student VALUES (DEFAULT, 'Yan', 'Li', '2010-12-31 23:59:59' );
  40. INSERT INTO student VALUES (DEFAULT, 'Peggy', 'Justice', '2010-12-31 23:59:59' );
  41. INSERT INTO student VALUES (DEFAULT, 'Laura', 'Norman', '2010-12-31 23:59:59' );
  42. INSERT INTO student VALUES (DEFAULT, 'Nino', 'Olivetto', '2010-12-31 23:59:59' );
  43.  
  44. DROP TABLE enrolment;
  45. CREATE TABLE enrolment
  46. (
  47.  
  48. EnrolmentID INT         NOT NULL AUTO_INCREMENT ,
  49. CourseID INT            NOT NULL ,
  50. ID INT          NOT NULL ,
  51. Grade CHAR          NOT NULL,
  52. CONSTRAINT PK1 PRIMARY KEY(EnrolmentID),
  53. CONSTRAINT FK1 FOREIGN KEY(CourseID) REFERENCES course(CourseID),
  54. CONSTRAINT FK2 FOREIGN KEY(ID) REFERENCES student(ID)
  55. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement