Advertisement
DeafCat

create tables

Jan 20th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.01 KB | None | 0 0
  1. void createTables() throws SQLException {
  2.  
  3. /* Create Globals Store Stack */
  4. String createStore = new String(
  5. "CREATE TABLE Globals (" +
  6. "id int NOT NULL,"+
  7. "Basic_Teacher_Wage float(2),"+
  8. "Basic_Admin_Wage float(2),"+
  9. "Teacher_Rise_Percentage float(2),"+
  10. "Admin_Rise_Percentage float(2),"+
  11. "Member_Percentage float(2),"+
  12. "Reasearch_Bonus float(2),"+
  13. "Library_Bonus float(2),"+
  14. "Basic_Temp_Teacher_Wage float(2),"+
  15. "Basic_Temp_Admin_Wage float(2),"+
  16. "DBdate DATE" +
  17. ");");
  18.  
  19. Statement stmt = connection.con.createStatement();
  20. stmt.executeUpdate(createStore);
  21.  
  22. /* Creates Teaching_Stuff table */
  23. String createTeachers = new String(
  24. "CREATE TABLE Teaching_Stuff ("+
  25. "id_Stuff int NOT NULL,"+
  26. "FirstName varchar(100) NOT NULL,"+
  27. "LastName varchar(100) NOT NULL,"+
  28. "FatherName varchar(100) NOT NULL,"+
  29. "Gender char(1) NOT NULL,"+
  30. "DateOfBirth DATE NOT NULL,"+
  31. "AMKA varchar(11) NOT NULL,"+
  32. "AFM varchar(9) NOT NULL,"+
  33. "Department varchar(255) NOT NULL,"+
  34. "Marital_Status char(1) NOT NULL,"+
  35. "Address varchar(255) NOT NULL,"+
  36. "Bank varchar(100) NOT NULL,"+
  37. "IBAN varchar(33) NOT NULL,"+
  38. "Active char(1) NOT NULL,"+
  39. "Prof_Title varchar(100),"+
  40. "Telephone varchar(16),"+
  41. "PRIMARY KEY (id_Stuff)"+
  42. ");");
  43.  
  44. stmt = connection.con.createStatement();
  45. stmt.executeUpdate(createTeachers);
  46.  
  47. /* Creates Admin_Stuff table */
  48. String createAdmin = new String(
  49. "CREATE TABLE Admin_Stuff ("+
  50. "id_Stuff int NOT NULL,"+
  51. "FirstName varchar(100) NOT NULL,"+
  52. "LastName varchar(100) NOT NULL,"+
  53. "FatherName varchar(100) NOT NULL,"+
  54. "Gender char(1) NOT NULL,"+
  55. "DateOfBirth DATE NOT NULL,"+
  56. "AMKA varchar(11) NOT NULL,"+
  57. "AFM varchar(9) NOT NULL,"+
  58. "Department varchar(255) NOT NULL,"+
  59. "Marital_Status char(1) NOT NULL,"+
  60. "Address varchar(255) NOT NULL,"+
  61. "Bank varchar(100) NOT NULL,"+
  62. "IBAN varchar(33) NOT NULL,"+
  63. "Active char(1) NOT NULL,"+
  64. "Admin_Title varchar(100)," +
  65. "Duty varchar(255)," +
  66. "Telephone varchar(16),"+
  67. "PRIMARY KEY (id_Stuff)"+
  68. ");");
  69.  
  70. stmt = connection.con.createStatement();
  71. stmt.executeUpdate(createAdmin);
  72.  
  73. /* Creates Contract_Inf table */
  74. String createInf = new String(
  75. "CREATE TABLE Contract_Inf (" +
  76. "id_Contract int NOT NULL," +
  77. "Date_Begin DATE NOT NULL," +
  78. "Hours_Week int NOT NULL," +
  79. "Days_Leave int NOT NULL," +
  80. "In_Effect char(1) NOT NULL," +
  81. "Termination DATE,"+
  82. "id_Stuff int NOT NULL," +
  83. "PRIMARY KEY (id_Contract)"+
  84. ");");
  85.  
  86. stmt = connection.con.createStatement();
  87. stmt.executeUpdate(createInf);
  88.  
  89. /* Creates Contract_Fin table */
  90. String createFin = new String(
  91. "CREATE TABLE Contract_Fin (" +
  92. "id_Contract int NOT NULL," +
  93. "Date_Begin DATE NOT NULL," +
  94. "Hours_Week int NOT NULL," +
  95. "Days_Leave int NOT NULL," +
  96. "In_Effect char(1) NOT NULL," +
  97. "Date_End DATE NOT NULL,"+
  98. "Termination DATE,"+
  99. "id_Stuff int NOT NULL," +
  100. "PRIMARY KEY (id_Contract)"+
  101. ");");
  102.  
  103. stmt = connection.con.createStatement();
  104. stmt.executeUpdate(createFin);
  105.  
  106. /* Creates Family_Member table */
  107. String createMember = new String(
  108. "CREATE TABLE Family_Member (" +
  109. "id_Member int NOT NULL," +
  110. "FirstName varchar(100) NOT NULL," +
  111. "LastName varchar(100) NOT NULL," +
  112. "Relation char(1) NOT NULL," +
  113. "Gender char(1) NOT NULL," +
  114. "DateOfBirth DATE NOT NULL," +
  115. "AMKA varchar(11) NOT NULL," +
  116. "id_Stuff int NOT NULL," +
  117. "PRIMARY KEY (id_Member)" +
  118. ");");
  119.  
  120. stmt = connection.con.createStatement();
  121. stmt.executeUpdate(createMember);
  122.  
  123. /* Creates Edu_Degree table */
  124. String createDegree = new String(
  125. "CREATE TABLE Edu_Degree (" +
  126. "id_Degree int NOT NULL," +
  127. "Title varchar(255) NOT NULL," +
  128. "Year int NOT NULL," +
  129. "Mark float(2) NOT NULL," +
  130. "University varchar(255) NOT NULL," +
  131. "id_Stuff int NOT NULL," +
  132. "PRIMARY KEY (id_Degree)" +
  133. ");");
  134.  
  135. stmt = connection.con.createStatement();
  136. stmt.executeUpdate(createDegree);
  137.  
  138. /* Creates Payment table */
  139. String createPayment = new String(
  140. "CREATE TABLE Payment (" +
  141. "id_Payment int NOT NULL," +
  142. "id_Stuff int NOT NULL," +
  143. "TypeOfPay varchar(100) NOT NULL," +
  144. "DateOfPay DATE NOT NULL," +
  145. "ValueOfPay float(2) NOT NULL," +
  146. "Basic_Wage float(2) NOT NULL," +
  147. "Family_bonus float(2) NOT NULL," +
  148. "Benefits float(2) NOT NULL," +
  149. "Comment varchar(255)," +
  150. "PRIMARY KEY (id_Payment)" +
  151. ");");
  152.  
  153. stmt = connection.con.createStatement();
  154. stmt.executeUpdate(createPayment);
  155.  
  156. /* Creates Course table */
  157. String createCourse = new String(
  158. "CREATE TABLE Course (" +
  159. "id_Course int NOT NULL," +
  160. "Title varchar(255) NOT NULL," +
  161. "id_Stuff int NOT NULL," +
  162. "PRIMARY KEY (id_Course)" +
  163. ");");
  164.  
  165. stmt = connection.con.createStatement();
  166. stmt.executeUpdate(createCourse);
  167.  
  168. /* Creates Participates_In table */
  169. String createParticipates_In = new String(
  170. "CREATE TABLE Participates_In (" +
  171. "id_Project int NOT NULL," +
  172. "Date_In DATE NOT NULL," +
  173. "Date_Out DATE," + // corrected
  174. "id_Stuff int NOT NULL," +
  175. "PRIMARY KEY (id_Project,id_Stuff)" +
  176. ");");
  177.  
  178. stmt = connection.con.createStatement();
  179. stmt.executeUpdate(createParticipates_In);
  180.  
  181. /* Creates Project table */
  182. String createProject = new String(
  183. "CREATE TABLE Project (" +
  184. "id_Project int NOT NULL," +
  185. "Name varchar(255) NOT NULL," +
  186. "PRIMARY KEY (id_Project)" +
  187. ");");
  188.  
  189. stmt = connection.con.createStatement();
  190. stmt.executeUpdate(createProject);
  191.  
  192.  
  193. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement