1 25 package org.objectweb.easybeans.tests.common.helper; 26 27 32 public final class CreateDBCollegeHelper { 33 34 37 private CreateDBCollegeHelper(){ 38 39 } 40 41 46 public static String createTablePeople() { 47 String sql = "CREATE TABLE People (" + "CodePeople integer, " + "NamePeople varchar(30), " 48 + "CodeUniversity integer, " + "PRIMARY KEY (CodePeople), " 49 + "FOREIGN KEY (codeUniversity) REFERENCES University(CodeUniversity))"; 50 return sql; 51 } 52 53 58 public static String createTableCourse() { 59 String sql = "CREATE TABLE Course ( " + "CodeCourse integer, " + "NameCourse varchar(30), " + "CodeProf integer, " 60 + "PRIMARY KEY (CodeCourse), FOREIGN KEY (codeProf) REFERENCES People(CodePeople))"; 61 return sql; 62 } 63 64 70 public static String createTableCourseAllocation() { 71 String sql = "CREATE TABLE CourseAllocation ( " + "CodeCourse integer, " + "CodeStudent integer, " 72 + "Year varchar(10), " + "PRIMARY KEY (CodeCourse,CodeStudent), " 73 + "FOREIGN KEY (CodeCourse) REFERENCES Course(CodeCourse), " 74 + "FOREIGN KEY (CodeStudent) REFERENCES People(CodePeople))"; 75 return sql; 76 } 77 78 83 public static String createTableUniversity(){ 84 String sql = "CREATE TABLE University ( " + "CodeUniversity integer, " + "NameUniversity varchar(30), " 85 + "year varchar(10), " + "PRIMARY KEY (CodeUniversity) )"; 86 return sql; 87 88 } 89 90 94 public static String dropTablePeople(){ 95 return "DROP TABLE People CASCADE"; 96 } 97 98 102 public static String dropTableUniversity(){ 103 return "DROP TABLE University CASCADE"; 104 } 105 106 110 public static String dropTableCourse(){ 111 return "DROP TABLE Course CASCADE"; 112 } 113 114 118 public static String dropTableCourseAllocation(){ 119 return "DROP TABLE CourseAllocation CASCADE"; 120 } 121 122 } 123 | Popular Tags |