Inference Table for Reverse Engineer

The following table lists the criteria that are used to infer primary keys, foreign keys, and relationships during reverse engineering.

Database Item

Inference Rule

Primary Key

If a table includes one index that is defined as unique or primary for that table. Note that the primary key is inferred when the table is imported and created.

If multiple tables have the same primary key, the application searches for other criteria such as the number of primary keys each table has. Suppose that one table has just one primary key, the other one has multiple primary keys, and a primary key is common for the tables. In this case, the table with one primary key is created as the parent table. In general, if there are multiple tables with the same primary key and the application cannot determine the relationship with certainty, then the application does not create the relationship.

Relationship

Infer from Indexes:

If a table includes an index that includes the same index members in the same order as an index identified as a primary key in a different table, and also includes additional columns not found in the primary key.

Infer from Names:

If a table includes an index that has the same name as an index identified as a primary key in a different table.

Parent/Child

After inferring a relationship, it is determined that the larger index (more columns) belongs to the child table and the smaller index (fewer columns) belongs to the parent.

Foreign Key

After inferring a relationship, it is determined that the index members in the child table that match those in the primary key of the parent table comprise the foreign key.

Identifying or Non-Identifying

After inferring a relationship, it is determined that a non-identifying relationship exists if the index columns do not appear in the primary key in the child table and an identifying relationship exists if the index columns do appear in the primary key in the child table.

If you infer primary keys or relationships for a database and they are defined in the database, the application attempts to infer more information. For example, when a schema contains information about a primary key and it is not explicitly defined for a table, then the primary key is inferred automatically.

In general, the criteria that are used for inferring primary key and relationship information leads to correct inferences. However, there is no guarantee that these inferences are always correct.