001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id:$
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.common.helper;
025:
026: /**
027: * Creates all sql queries used to create and delete all college database tables.
028: * @author Gisele Pinheiro Souza
029: * @author Eduardo Studzinski Estima de Castro
030: */
031: public final class CreateDBCollegeHelper {
032:
033: /**
034: * Default constructor.
035: */
036: private CreateDBCollegeHelper() {
037:
038: }
039:
040: /**
041: * Returns the query that creates the table people as follow.<br>
042: * People(CodePeople, NamePeople,CodeUniversity) Primary key: CodePeople
043: * @return the query used to create the table
044: */
045: public static String createTablePeople() {
046: String sql = "CREATE TABLE People ("
047: + "CodePeople integer, "
048: + "NamePeople varchar(30), "
049: + "CodeUniversity integer, "
050: + "PRIMARY KEY (CodePeople), "
051: + "FOREIGN KEY (codeUniversity) REFERENCES University(CodeUniversity))";
052: return sql;
053: }
054:
055: /**
056: * Returns the query that creates the table course as follow.<br>
057: * Course (CodeCourse, NameCourse,CodeProf) Primary key: CodeCourse
058: * @return the query used to create the table
059: */
060: public static String createTableCourse() {
061: String sql = "CREATE TABLE Course ( "
062: + "CodeCourse integer, "
063: + "NameCourse varchar(30), "
064: + "CodeProf integer, "
065: + "PRIMARY KEY (CodeCourse), FOREIGN KEY (codeProf) REFERENCES People(CodePeople))";
066: return sql;
067: }
068:
069: /**
070: * Returns the query that creates the table courseallocation as follow.<br>
071: * CourseAllocation(CodeCourse,CodeStudent, Year) Primary key:
072: * CodeCourse,CodeStudent
073: * @return the query used to create the table
074: */
075: public static String createTableCourseAllocation() {
076: String sql = "CREATE TABLE CourseAllocation ( "
077: + "CodeCourse integer, "
078: + "CodeStudent integer, "
079: + "Year varchar(10), "
080: + "PRIMARY KEY (CodeCourse,CodeStudent), "
081: + "FOREIGN KEY (CodeCourse) REFERENCES Course(CodeCourse), "
082: + "FOREIGN KEY (CodeStudent) REFERENCES People(CodePeople))";
083: return sql;
084: }
085:
086: /**
087: * Returns the query that creates the table university as follow.<br>
088: * University (CodeUniversity,NameUniversity) Primary key: CodeUniversity
089: * @return the query used to create the table
090: */
091: public static String createTableUniversity() {
092: String sql = "CREATE TABLE University ( "
093: + "CodeUniversity integer, "
094: + "NameUniversity varchar(30), " + "year varchar(10), "
095: + "PRIMARY KEY (CodeUniversity) )";
096: return sql;
097:
098: }
099:
100: /**
101: * Returns the query that deletes the table people.
102: * @return the query used to delete the table
103: */
104: public static String dropTablePeople() {
105: return "DROP TABLE People CASCADE";
106: }
107:
108: /**
109: * Returns the query that deletes the table university.
110: * @return the query used to delete the table
111: */
112: public static String dropTableUniversity() {
113: return "DROP TABLE University CASCADE";
114: }
115:
116: /**
117: * Returns the query that deletes the table course.
118: * @return the query used to delete the table
119: */
120: public static String dropTableCourse() {
121: return "DROP TABLE Course CASCADE";
122: }
123:
124: /**
125: * Returns the query that deletes the table courseAllocation.
126: * @return the query used to delete the table
127: */
128: public static String dropTableCourseAllocation() {
129: return "DROP TABLE CourseAllocation CASCADE";
130: }
131:
132: }
|