Administration: Omnidex Features

Rollup Tables

Creating Rollup Tables

A rollup table is quite easy to create. The rollup tables are first created in the Omnidex Environment File, complete with the SQL statement that represents the rollup data. Then the UPDATE ROLLUPS statement is issued in ODXSQL to populate the rollup tables. Here is a simple example of declaring a regular table, followed by the creation of two rollup tables:

create table          "INDIVIDUALS"
 physical             "dat/individuals.dat"
 (
  "INDIVIDUAL"        CHARACTER(12),
  "HOUSEHOLD"         CHARACTER(12),
  "NAME"              CHARACTER(50),
  "GENDER"            CHARACTER(1),
  "BIRTHDATE"         ANSI DATE,
  "PHONE"             CHARACTER(14),
  "EMAIL"             CHARACTER(60),
  constraint INDIVIDUALS_INDIVIDUAL_PK primary ("INDIVIDUAL"),
  constraint INDIVIDUALS_HOUSEHOLD_FK foreign ("HOUSEHOLD") references "HOUSEHOLDS",
  constraint INDIVIDUALS_GENDER_FK foreign ("GENDER") references "GENDERS",
 )
 in                   "simple.xml";

create table          "INDIVIDUALS_BY_HOUSEHOLD"
 physical             "dat/individuals_by_household.dat"
 (
  "HOUSEHOLD"         CHARACTER(12),
  "GENDER"            CHARACTER(1),
  "BIRTHDATE"         ANSI DATE,
  "NUM_INDIVIDUALS"   UNSIGNED INTEGER,
  constraint INDIVIDUALS_HOUSEHOLD_FK foreign ("HOUSEHOLD") references "HOUSEHOLDS",
  constraint INDIVIDUALS_GENDER_FK foreign ("GENDER") references "GENDERS",
 )
 as "select           HOUSEHOLD,
                      GENDER,
                      BIRTHDATE,
                      count(*)  NUM_INDIVIDUALS
       from           INDIVIDUALS
       group by       HOUSEHOLD,
                      GENDER,
                      BIRTHDATE"
 in                   "simple.xml";


create table          "INDIVIDUALS_BY_DEMO"
 physical             "dat/individuals_by_demo.dat"
 (
  "GENDER"            CHARACTER(1),
  "BIRTHDATE"         ANSI DATE,
  "NUM_INDIVIDUALS"   UNSIGNED INTEGER,
  constraint INDIVIDUALS_GENDER_FK foreign ("GENDER") references "GENDERS",
 )
 as "select           GENDER,
                      BIRTHDATE,
                      count(*)  NUM_INDIVIDUALS
       from           INDIVIDUALS
       group by       GENDER,
                      BIRTHDATE"
 in                   "simple.xml";

IMPORTANT: Note that the aggregation has a column alias of NUM_INDIVIDUALS. It is required that all aggregation functions have column aliases as the alias becomes the column name in the table.

In ODXSQL, ODBC or JDBC, the following statement will populate the rollup tables in the Omnidex Environment:

> update rollups
Database
 Table                                       Rows        CPU    Elapsed
----------------------------------------------------------------------------
SIMPLE
 INDIVIDUALS_BY_HOUSEHOLD                   5,000       0:00       0:00
 INDIVIDUALS_BY_DEMO                        4,793       0:00       0:00
----------------------------------------------------------------------------
Total                                                   0:00       0:00

Rollup tables updated

Additional Resources

 
Back to top
admin/features/rollups/create.txt ยท Last modified: 2016/06/28 22:38 (external edit)