Steps in Creating a Join Index

In order to create a join index you must perform all of the following steps.

  1. Create the tables involved in the join index, using the CREATE TABLE command, or using Sybase Central. These must be permanent tables; you cannot use a temporary table to create a join index.

  2. Identify the join condition that relates specific pairs of columns in the underlying tables involved in any one join.

    It is important to define a schema for your database, to clarify join conditions and other assumptions about the structure of your data. The schema should represent foreign key-primary key relationships, and follow other best practices of schema design. Columns related by foreign key must have matching data types, precision, and scale.

    Where the relationship is based on a key join, you must define join conditions as referential integrity constraints—primary and foreign key declarations—in the CREATE TABLE commands in step 1 or in ALTER TABLE commands.

  3. Create a primary key for each column involved in a join.

  4. Create column indexes for the tables being joined.

    When Sybase IQ creates a join index between tables, the IQ column index types and data types already defined on the single tables are used in the join index. Multicolumn indexes on base tables are not replicated in join indexes created using those base tables.

  5. Load the data into the tables, using the LOAD TABLE command. You also can add data to existing tables using the INSERT INTO command.

    Note: You must insert into each table in the join index as a single-table insert, rather than into the join index itself. This approach conforms to ANSI rules for indexed data.
  6. Create the join index by issuing the CREATE JOIN INDEX command, or in Sybase Central with the Create Join Index wizard. You specify the join hierarchy as part of this step.

  7. Depending on the order in which you perform these steps, you may need to synchronize the tables in the join index, as described below. If data exists in the join tables, synchronization occurs automatically.

The index remains unavailable until all steps are complete. However, you can adjust the order of some steps, depending on the needs of your site:
Related concepts
Join Hierarchy Overview
Relationships in Join Indexes
The Join Hierarchy in Query Resolution