Normalized Database Storage
  with extensible Java classes

To store response data in a Normalized format, the DatabaseExtension class can be extended. The DatabaseExtension class is provided, with source code, as a guide. Some database administrators prefer this method rather than creating one table per survey. Similar classes are provided for all supported databases. The correct classes are enabled by default.

User Interface

The Save page includes the following check box:
Save in Normalized Database

When checked, each vote or survey response will be stored as a series of records in table VWFDATA. For example:

RECORD_ORDINAL TIME_STAMP SPOTNAME POLLNAME VOTE_ORDINAL AUTHENTICATEDUSERID QUESTIONNAME ANSWER
194 25-Jun-01 DBTest DBTest1 193 Carlos1998 radio 2
195 25-Jun-01 DBTest DBTest1 193 Carlos1998 boxes a
196 25-Jun-01 DBTest DBTest1 193 Carlos1998 boxes b
197 25-Jun-01 DBTest DBTest1 193 Carlos1998 boxes c

Note that neither the RECORD_ORDINAL or VOTE_ORDINAL numbers are sequential. Each response has a unique, ascending VOTE_ORDINAL. Each record in the table has a unique, ascending RECORD_ORDINAL. AUTHENTICATEDUSERID will be blank if not available.

Installation

1. Begin by studying the source code for DatabaseExtension.java. If you plan to modify it, copy it under a different name.

2. Compile your code and move the .class file to the .../ViewsFlash/WEB-INF/com/cogix/vwf directory, and restart your application server. For complete instructions, click here.

3. Add the following servlet parameter to viewsflash.properties and restart the application server:
databaseextension=OracleDatabaseExtension

4. If you have not created other ViewsFlash database tables, let ViewsFlash do it (either with ?Diagnose or a ?dbcmd=dbmigrate). Otherwise, create the needed table, index, and sequence with the following SQL statements:

CREATE TABLE VWFDATA ( RECORD_ORDINAL INTEGER NOT NULL PRIMARY KEY,
TIME_STAMP DATE, SPOTNAME CHAR (32), POLLNAME CHAR (32),
VOTE_ORDINAL INTEGER, AUTHENTICATEDUSERID CHAR (32), QUESTIONNAME CHAR (32), ANSWER VARCHAR2 (4000) )

CREATE INDEX VWFDATAINDEX on VWFDATA ( SPOTNAME, POLLNAME, VOTE_ORDINAL )

CREATE INDEX VWFDATAINDEX2 on VWFDATA ( VOTE_ORDINAL )

CREATE SEQUENCE VWFDATASEQUENCE ORDER MAXVALUE 9999999999999999

5. Restart the application server. If creating tables, make sure that the tables have been created. Check the settings for the Save page on the Default poll in the Default place. The Save in Normalized Database check box should appear.

DatabaseExtension class

Only the following methods are customized normally. Refer to the source code for further documentation.

String getSavePageMessage ()
This function determines the text visible on the Save page that activates saving data for that particular poll. If this extension is not used, nothing appears. The default text is "Save in Normalized Database".

boolean bDisableNativeDatabaseSave ()
If you return true, the menus on the Poll Save page that allow for storing data in a database by creating tables, etc., will all disappear. By using this option, you are effectively replacing the built-in database saving code in ViewsFlash with this class completely. The default is false.

String getVersion()
At initialization, the name of your class and this version number will be written to the ViewsFlash log. The default is 1.0.

Refer to the source code for further information. Changes that you make may alter the application's behavior.

Next: Style Templates