KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > helper > CreateDBCollegeHelper


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id:$
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.helper;
26
27 /**
28  * Creates all sql queries used to create and delete all college database tables.
29  * @author Gisele Pinheiro Souza
30  * @author Eduardo Studzinski Estima de Castro
31  */

32 public final class CreateDBCollegeHelper {
33
34     /**
35      * Default constructor.
36      */

37     private CreateDBCollegeHelper(){
38
39     }
40
41     /**
42      * Returns the query that creates the table people as follow.<br>
43      * People(CodePeople, NamePeople,CodeUniversity) Primary key: CodePeople
44      * @return the query used to create the table
45      */

46     public static String JavaDoc createTablePeople() {
47         String JavaDoc 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     /**
54      * Returns the query that creates the table course as follow.<br>
55      * Course (CodeCourse, NameCourse,CodeProf) Primary key: CodeCourse
56      * @return the query used to create the table
57      */

58     public static String JavaDoc createTableCourse() {
59         String JavaDoc 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     /**
65      * Returns the query that creates the table courseallocation as follow.<br>
66      * CourseAllocation(CodeCourse,CodeStudent, Year) Primary key:
67      * CodeCourse,CodeStudent
68      * @return the query used to create the table
69      */

70     public static String JavaDoc createTableCourseAllocation() {
71         String JavaDoc 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     /**
79      * Returns the query that creates the table university as follow.<br>
80      * University (CodeUniversity,NameUniversity) Primary key: CodeUniversity
81      * @return the query used to create the table
82      */

83     public static String JavaDoc createTableUniversity(){
84         String JavaDoc sql = "CREATE TABLE University ( " + "CodeUniversity integer, " + "NameUniversity varchar(30), "
85                 + "year varchar(10), " + "PRIMARY KEY (CodeUniversity) )";
86         return sql;
87
88     }
89
90     /**
91      * Returns the query that deletes the table people.
92      * @return the query used to delete the table
93      */

94     public static String JavaDoc dropTablePeople(){
95         return "DROP TABLE People CASCADE";
96     }
97
98     /**
99      * Returns the query that deletes the table university.
100      * @return the query used to delete the table
101      */

102     public static String JavaDoc dropTableUniversity(){
103         return "DROP TABLE University CASCADE";
104     }
105
106     /**
107      * Returns the query that deletes the table course.
108      * @return the query used to delete the table
109      */

110     public static String JavaDoc dropTableCourse(){
111         return "DROP TABLE Course CASCADE";
112     }
113
114     /**
115      * Returns the query that deletes the table courseAllocation.
116      * @return the query used to delete the table
117      */

118     public static String JavaDoc dropTableCourseAllocation(){
119         return "DROP TABLE CourseAllocation CASCADE";
120     }
121
122 }
123
Popular Tags