This is an old revision of the document!


Integration: Relational Databases

Oracle

Oracle Constraints and Indexes

Oracle table constraints and indexes should be declared in the Omnidex Environment File. Omnidex will consider constraints and indexes when optimizing queries, and these are critical to some of the advanced optimization techniques in Omnidex.

Declaring Constraints

The table declarations in the Omnidex Environment File should include primary and foreign key constraints that establish parent-child relationships between the tables. While Omnidex does not validate or enforce these constraints; they are heavily used when optimizing queries.

In most situations, the constraints declared in Omnidex should match those declared in the Oracle database; however, administrators may alter these if they wish. At times, a parent-child relationship may exist between tables in Oracle even though a constraint is not formally declared. These can be declared in Omnidex, allowing more advanced optimization of multi-table queries.

Omnidex is tolerant of violations of foreign key constraints, such as foreign keys for which there are no primary keys in the corresponding tables. Omnidex is not tolerant of violations of primary key constraints, as these can lead to incorrect results returned from queries.

create table          "STATES"
 physical             "SIMPLE.STATES"
 (
  "STATE"             CHARACTER(2)   physical "STATE_CD",
  "DESCRIPTION"       STRING(31),
  "STATE_CODE"        CHARACTER(2)   physical "STATE_NUM",
  "REGION"            CHARACTER(2)   physical "REGION_CD",
  "COUNTRY"           CHARACTER(2)   physical "COUNTRY_CD",
  "TAX_RATE"          FLOAT,
  constraint STATES_STATE_PK primary ("STATE"),
  constraint STATES_COUNTRY_FK foreign ("COUNTRY") references "COUNTRIES"
 )
 in                   "simple.xml";

Declaring Indexes

Oracle indexes that exist on primary and foreign key constraints should be declared as NATIVE indexes in the Omnidex Environment File. This is true whether the Oracle index was created using Oracle's CREATE INDEX statement or whether the Oracle constraint was created using the “USING INDEX” clause. It can also be beneficial to declare other Oracle indexes as well.

The Omnidex SQL Engine will evaluate the presence of native Oracle indexes when deciding how to process a statement. At times, it may be faster to rely on the native Oracle indexes than to use Omnidex indexes. This is especially true for searches on unique values, such as primary keys.

Oracle indexes are declared using the CREATE TABLE or CREATE INDEX statements. The following example shows native indexes being declared for a table.

create table          "STATES"
 physical             "SIMPLE.STATES"
 (
  "STATE"             CHARACTER(2)   physical "STATE_CD",
  "DESCRIPTION"       STRING(31),
  "STATE_CODE"        CHARACTER(2)   physical "STATE_NUM",
  "REGION"            CHARACTER(2)   physical "REGION_CD",
  "COUNTRY"           CHARACTER(2)   physical "COUNTRY_CD",
  "TAX_RATE"          FLOAT,
  constraint STATES_STATE_PK primary ("STATE"),
  constraint STATES_COUNTRY_FK foreign ("COUNTRY") references "COUNTRIES",
  native index STATE_IDX ("STATE"),
  native index COUNTRY_IDX ("COUINTRY")
 )
 in                   "simple.xml";

Additional Resources

See also:

 
Back to top
integration/rdbms/oracle/constraints.1301886704.txt.gz · Last modified: 2016/06/28 22:38 (external edit)