G |
Entity Beans |
|
Get |
Get |
The Rock Survey Database |
Now it's time to take a look at the database and tables that will store the Rock Survey data. For the tutorial, we'll use the Cloudscape database engine, which is included with the J2EE RI. To use a database within the J2EE environment, the following steps are necessary:
gsejbDB.
DataSource entry must be added to J2EE resources. The DataSource entry for gsejbDB will be jdbc/gsejbDB.
Steps 1 and 3 are accomplished with the J2EE Administration Tool, j2eeadmin, which is discussed in the J2EE documentation under "J2EE SDK Tools" (see Resources). There is no standard for database creation, which is DBMS specific. For Cloudscape, step 1 is included in the J2EE RI as installed. Cloudscape database creation — step 2 — is an option (create=true) in the JDBC URL for the connection, so it will be handled in step 3. To perform step 3, start J2EE, then run j2eeadmin from the command line as follows:
j2eeadmin -addJdbcDatasource jdbc/gsejbDB jdbc:cloudscape:rmi:gsejbDB;create=true
To ensure that the DataSource was added, use this command to see a list of the current DataSources:
j2eeadmin -listJdbcDatasource
The Rock Survey tables are minimal, with no analytical decomposition or normalization, to avoid distraction from the main focus of the tutorial, which is EJB technology. You should note that the "design" is not very flexible and should not be used as a model for production tables.
| Table Name: "SurveyBeanTable" | |||
|---|---|---|---|
| PK |
Name |
Type |
Description |
| Yes |
Type |
VARCHAR |
Survey type = "ROCK" |
| SF | INTEGER | Single female count | |
| MF | INTEGER | Married female count | |
| SM | INTEGER | Single male count | |
| MM | INTEGER | Married male count | |
| USF | INTEGER | US female count | |
| NUSF | INTEGER | Non-US female count | |
| USM | INTEGER | US male count | |
| NUSM | INTEGER | Non-US male count | |
| Igneous | INTEGER | Igneous count | |
| Metamorphic | INTEGER | Metamorphic count | |
| Meteorite | INTEGER | Meteorite count | |
| Sedimentary | INTEGER | Sedimentary count | |
| InCountry | INTEGER | My Country count | |
| ExCountry | INTEGER | Another Country count | |
| Island | INTEGER | Island count | |
| OS | INTEGER | Outer Space count | |
| Total | INTEGER | Total rocks | |
| Pounds | FLOAT | Total rock weight | |
The "SurveyBeanTable" table holds all survey results except for last name entries, and will contain exactly one row. The initial set of columns may appear confusing at first, but they just contain the breakdowns by gender, marital status, and residence. The other columns should be self-explanatory. For the Rock Survey example, the "SurveyBeanTable" table will be managed by an entity bean using CMP.
| Table Name: SurveyNames | |||
|---|---|---|---|
| PK |
Name |
Type |
Description |
| Yes |
Type |
VARCHAR |
Survey type = "ROCK" |
| Yes |
LastName |
VARCHAR |
Last name given for survey |
| |
Total |
INTEGER |
Count |
Last name data is kept in a separate table that contains a row with a count for each distinct last name. As we'll see in The Survey Results Application, the three most frequent last names are displayed along with the other results, so we need a way to track them. For the Rock Survey example, the SurveyNames table will be managed by an entity bean using BMP.
|
|