SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DROP TABLE STUDENT CASCADE CONSTRAINTS;
  2. DROP TABLE DORM_ROOM CASCADE CONSTRAINTS;
  3.  
  4. CREATE TABLE STUDENT
  5. (STUDENT_ID         number(8) PRIMARY KEY,
  6. STUDENT_FIRST_NAME  varchar(25) NOT NULL,
  7. STUDENT_LAST_NAME   varchar(50) NOT NULL,
  8. STUDENT_TYPE    varchar(1) NOT NULL,
  9. FK_DORM_ROOM_ID varchar(8));
  10.  
  11. CREATE TABLE DORM_ROOM
  12. (DORM_ROOM_ID   varchar(8) PRIMARY KEY,
  13. BUILDING_ID varchar(8) NOT NULL,
  14. COST    decimal(8,2));
  15.  
  16. ALTER TABLE STUDENT
  17. ADD CONSTRAINT FK_DORM_ROOM
  18. FOREIGN KEY(FK_DORM_ROOM_ID)
  19. REFERENCES DORM_ROOM(DORM_ROOM_ID);
  20.  
  21. INSERT INTO DORM_ROOM
  22. (DORM_ROOM_ID, BUILDING_ID, COST)
  23. VALUES
  24. ('ABC123','Searcy',125.25);
  25.  
  26. INSERT INTO DORM_ROOM
  27. (DORM_ROOM_ID, BUILDING_ID, COST)
  28. VALUES
  29. ('DEF234','Wood',75.89);
  30.  
  31. INSERT INTO DORM_ROOM
  32. (DORM_ROOM_ID, BUILDING_ID, COST)
  33. VALUES
  34. ('GHI567','Columbia',145.15);
  35.  
  36. INSERT INTO STUDENT
  37. (STUDENT_ID, STUDENT_FIRST_NAME, STUDENT_LAST_NAME, STUDENT_TYPE, FK_DORM_ROOM_ID)
  38. VALUES
  39. (12345678,'James','Joyce','F','ABC123');
  40.  
  41. INSERT INTO STUDENT
  42. (STUDENT_ID, STUDENT_FIRST_NAME, STUDENT_LAST_NAME, STUDENT_TYPE, FK_DORM_ROOM_ID)
  43. VALUES
  44. (23456789,'Ernest','Hemingway','S','DEF234');
  45.  
  46. INSERT INTO STUDENT
  47. (STUDENT_ID, STUDENT_FIRST_NAME, STUDENT_LAST_NAME, STUDENT_TYPE, FK_DORM_ROOM_ID)
  48. VALUES
  49. (34567890,'Zelda','Fitzgerald','J',NULL);
  50.  
  51. DROP TABLE TEXTBOOK CASCADE CONSTRAINTS;
  52.  
  53.  
  54. CREATE TABLE TEXTBOOK
  55. (TEXTBOOK_ID    varchar(18) PRIMARY KEY,
  56. TEXTBOOK_TITLE  varchar(50) NOT NULL,
  57. FK_STUDENT_ID   number(8));
  58.  
  59. ALTER TABLE TEXTBOOK
  60. ADD CONSTRAINT FK_STUDENT
  61. FOREIGN KEY(FK_STUDENT_ID)
  62. REFERENCES STUDENT(STUDENT_ID);
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