KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > scenario > tools > databases > RUBiSDatabase


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Emmanuel Cecchet.
22  * Contributor(s): Mathieu Peltier.
23  */

24
25 package org.objectweb.cjdbc.scenario.tools.databases;
26
27 import java.sql.Types JavaDoc;
28
29 import org.objectweb.cjdbc.common.sql.schema.DatabaseColumn;
30 import org.objectweb.cjdbc.common.sql.schema.DatabaseTable;
31
32 /**
33  * Represents the RUBiS benchmark database (see http://rubis.objectweb.org/).
34  *
35  * @author <a HREF="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier</a>
36  */

37 public class RUBiSDatabase extends AbstractDatabase
38 {
39   /**
40    * Creates a new <code>RUBiSDatabase</code> instance.
41    */

42   public RUBiSDatabase()
43   {
44     super();
45     DatabaseTable t;
46     
47     t = new DatabaseTable("selections",2);
48     schema.addTable(t);
49
50     //CREATE TABLE categories (
51
// id INTEGER UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT,
52
// name VARCHAR(50),
53
// PRIMARY KEY(id)
54
//);
55

56     t = new DatabaseTable("categories", 2);
57     t.addColumn(new DatabaseColumn("id", true, Types.INTEGER));
58     t.addColumn(new DatabaseColumn("name", false, Types.VARCHAR));
59     schema.addTable(t);
60
61     // CREATE TABLE regions(
62
// id INTEGER UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT,
63
// name VARCHAR(25),
64
// PRIMARY KEY(id));
65

66     t = new DatabaseTable("regions", 2);
67     t.addColumn(new DatabaseColumn("id", true, Types.INTEGER));
68     t.addColumn(new DatabaseColumn("name", false, Types.VARCHAR));
69     schema.addTable(t);
70
71     // CREATE TABLE users(
72
// id INTEGER UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT,
73
// firstname VARCHAR(20),
74
// lastname VARCHAR(20),
75
// nickname VARCHAR(20) NOT NULL UNIQUE,
76
// password VARCHAR(20) NOT NULL,
77
// email VARCHAR(50) NOT NULL,
78
// rating INTEGER,
79
// balance FLOAT,
80
// creation_date DATETIME,
81
// region INTEGER UNSIGNED NOT NULL,
82
// PRIMARY KEY(id),
83
// INDEX auth(nickname, password),
84
// INDEX region_id(region));
85

86     t = new DatabaseTable("users", 10);
87     t.addColumn(new DatabaseColumn("id", true, Types.INTEGER));
88     t.addColumn(new DatabaseColumn("firstname", false, Types.VARCHAR));
89     t.addColumn(new DatabaseColumn("lastname", false, Types.VARCHAR));
90     t.addColumn(new DatabaseColumn("nickname", false, Types.VARCHAR));
91     t.addColumn(new DatabaseColumn("password", false, Types.VARCHAR));
92     t.addColumn(new DatabaseColumn("email", false, Types.VARCHAR));
93     t.addColumn(new DatabaseColumn("rating", false, Types.INTEGER));
94     t.addColumn(new DatabaseColumn("balance", false, Types.FLOAT));
95     t.addColumn(new DatabaseColumn("creation_date", false, Types.TIMESTAMP));
96     t.addColumn(new DatabaseColumn("region", false, Types.INTEGER));
97     schema.addTable(t);
98
99     // CREATE TABLE items(
100
// id INTEGER UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT,
101
// name VARCHAR(100),
102
// description TEXT,
103
// initial_price FLOAT UNSIGNED NOT NULL,
104
// quantity INTEGER UNSIGNED NOT NULL,
105
// reserve_price FLOAT UNSIGNED DEFAULT 0,
106
// buy_now FLOAT UNSIGNED DEFAULT 0,
107
// nb_of_bids INTEGER UNSIGNED DEFAULT 0,
108
// max_bid FLOAT UNSIGNED DEFAULT 0,
109
// start_date DATETIME,
110
// end_date DATETIME,
111
// seller INTEGER UNSIGNED NOT NULL,
112
// category INTEGER UNSIGNED NOT NULL,
113
// PRIMARY KEY(id),
114
// INDEX seller_id(seller),
115
// INDEX category_id(category));
116

117     t = new DatabaseTable("items", 12);
118     t.addColumn(new DatabaseColumn("id", true, Types.INTEGER));
119     t.addColumn(new DatabaseColumn("name", false, Types.VARCHAR));
120     t.addColumn(new DatabaseColumn("description", false, Types.VARCHAR));
121     t.addColumn(new DatabaseColumn("initial_price", false, Types.FLOAT));
122     t.addColumn(new DatabaseColumn("quantity", false, Types.INTEGER));
123     t.addColumn(new DatabaseColumn("reserve_price", false, Types.FLOAT));
124     t.addColumn(new DatabaseColumn("buy_now", false, Types.FLOAT));
125     t.addColumn(new DatabaseColumn("nb_of_bids", false, Types.INTEGER));
126     t.addColumn(new DatabaseColumn("max_bid", false, Types.FLOAT));
127     t.addColumn(new DatabaseColumn("start_date", false, Types.TIMESTAMP));
128     t.addColumn(new DatabaseColumn("end_date", false, Types.TIMESTAMP));
129     t.addColumn(new DatabaseColumn("seller", false, Types.INTEGER));
130     t.addColumn(new DatabaseColumn("category", false, Types.INTEGER));
131     schema.addTable(t);
132
133     // CREATE TABLE old_items(
134
// id INTEGER UNSIGNED NOT NULL UNIQUE,
135
// name VARCHAR(100),
136
// description TEXT,
137
// initial_price FLOAT UNSIGNED NOT NULL,
138
// quantity INTEGER UNSIGNED NOT NULL,
139
// reserve_price FLOAT UNSIGNED DEFAULT 0,
140
// buy_now FLOAT UNSIGNED DEFAULT 0,
141
// nb_of_bids INTEGER UNSIGNED DEFAULT 0,
142
// max_bid FLOAT UNSIGNED DEFAULT 0,
143
// start_date DATETIME,
144
// end_date DATETIME,
145
// seller INTEGER UNSIGNED NOT NULL,
146
// category INTEGER UNSIGNED NOT NULL,
147
// PRIMARY KEY(id),
148
// INDEX seller_id(seller),
149
// INDEX category_id(category));
150

151     t = new DatabaseTable("old_items", 12);
152     t.addColumn(new DatabaseColumn("id", true, Types.INTEGER));
153     t.addColumn(new DatabaseColumn("name", false, Types.VARCHAR));
154     t.addColumn(new DatabaseColumn("description", false, Types.VARCHAR));
155     t.addColumn(new DatabaseColumn("initial_price", false, Types.FLOAT));
156     t.addColumn(new DatabaseColumn("quantity", false, Types.INTEGER));
157     t.addColumn(new DatabaseColumn("reserve_price", false, Types.FLOAT));
158     t.addColumn(new DatabaseColumn("buy_now", false, Types.FLOAT));
159     t.addColumn(new DatabaseColumn("nb_of_bids", false, Types.INTEGER));
160     t.addColumn(new DatabaseColumn("max_bid", false, Types.FLOAT));
161     t.addColumn(new DatabaseColumn("start_date", false, Types.TIMESTAMP));
162     t.addColumn(new DatabaseColumn("end_date", false, Types.TIMESTAMP));
163     t.addColumn(new DatabaseColumn("seller", false, Types.INTEGER));
164     t.addColumn(new DatabaseColumn("category", false, Types.INTEGER));
165     schema.addTable(t);
166
167     // CREATE TABLE bids(
168
// id INTEGER UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT,
169
// user_id INTEGER UNSIGNED NOT NULL,
170
// item_id INTEGER UNSIGNED NOT NULL,
171
// qty INTEGER UNSIGNED NOT NULL,
172
// bid FLOAT UNSIGNED NOT NULL,
173
// max_bid FLOAT UNSIGNED NOT NULL,
174
// date DATETIME,
175
// PRIMARY KEY(id),
176
// INDEX item(item_id),
177
// INDEX user(user_id));
178

179     t = new DatabaseTable("bids", 7);
180     t.addColumn(new DatabaseColumn("id", true, Types.INTEGER));
181     t.addColumn(new DatabaseColumn("user_id", false, Types.INTEGER));
182     t.addColumn(new DatabaseColumn("item_id", false, Types.INTEGER));
183     t.addColumn(new DatabaseColumn("qty", false, Types.INTEGER));
184     t.addColumn(new DatabaseColumn("bid", false, Types.FLOAT));
185     t.addColumn(new DatabaseColumn("max_bid", false, Types.FLOAT));
186     t.addColumn(new DatabaseColumn("date", false, Types.TIMESTAMP));
187     schema.addTable(t);
188
189     // CREATE TABLE comments(
190
// id INTEGER UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT,
191
// from_user_id INTEGER UNSIGNED NOT NULL,
192
// to_user_id INTEGER UNSIGNED NOT NULL,
193
// item_id INTEGER UNSIGNED NOT NULL,
194
// rating INTEGER,
195
// date DATETIME,
196
// comment TEXT,
197
// PRIMARY KEY(id),
198
// INDEX from_user(from_user_id),
199
// INDEX to_user(to_user_id),
200
// INDEX item(item_id));
201

202     t = new DatabaseTable("comments", 7);
203     t.addColumn(new DatabaseColumn("id", true, Types.INTEGER));
204     t.addColumn(new DatabaseColumn("from_user_id", false, Types.INTEGER));
205     t.addColumn(new DatabaseColumn("to_user_id", false, Types.INTEGER));
206     t.addColumn(new DatabaseColumn("item_id", false, Types.INTEGER));
207     t.addColumn(new DatabaseColumn("rating", false, Types.INTEGER));
208     t.addColumn(new DatabaseColumn("date", false, Types.TIMESTAMP));
209     t.addColumn(new DatabaseColumn("comment", false, Types.VARCHAR));
210     schema.addTable(t);
211
212     // CREATE TABLE buy_now(
213
// id INTEGER UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT,
214
// buyer_id INTEGER UNSIGNED NOT NULL,
215
// item_id INTEGER UNSIGNED NOT NULL,
216
// qty INTEGER UNSIGNED NOT NULL,
217
// date DATETIME,
218
// PRIMARY KEY(id),
219
// INDEX buyer(buyer_id),
220
// INDEX item(item_id));
221

222     t = new DatabaseTable("buy_now", 5);
223     t.addColumn(new DatabaseColumn("id", true, Types.INTEGER));
224     t.addColumn(new DatabaseColumn("buyer_id", false, Types.INTEGER));
225     t.addColumn(new DatabaseColumn("item_id", false, Types.INTEGER));
226     t.addColumn(new DatabaseColumn("qty", false, Types.INTEGER));
227     t.addColumn(new DatabaseColumn("date", false, Types.TIMESTAMP));
228     schema.addTable(t);
229
230     // CREATE TABLE ids(
231
// id INTEGER UNSIGNED NOT NULL UNIQUE,
232
// category INTEGER UNSIGNED NOT NULL,
233
// region INTEGER UNSIGNED NOT NULL,
234
// users INTEGER UNSIGNED NOT NULL,
235
// item INTEGER UNSIGNED NOT NULL,
236
// comment INTEGER UNSIGNED NOT NULL,
237
// bid INTEGER UNSIGNED NOT NULL,
238
// buyNow INTEGER UNSIGNED NOT NULL,
239
// PRIMARY KEY(id));
240

241     t = new DatabaseTable("ids", 8);
242     t.addColumn(new DatabaseColumn("id", true, Types.INTEGER));
243     t.addColumn(new DatabaseColumn("category", false, Types.INTEGER));
244     t.addColumn(new DatabaseColumn("region", false, Types.INTEGER));
245     t.addColumn(new DatabaseColumn("users", false, Types.INTEGER));
246     t.addColumn(new DatabaseColumn("item", false, Types.INTEGER));
247     t.addColumn(new DatabaseColumn("comment", false, Types.INTEGER));
248     t.addColumn(new DatabaseColumn("bid", false, Types.INTEGER));
249     t.addColumn(new DatabaseColumn("buyNow", false, Types.INTEGER));
250     schema.addTable(t);
251   }
252 }
253
Popular Tags