Using the Schema Viewer

About Relationships

A relationship links two tables together. While foreign keys also do this, not all database types supported by MacSQL support foreign keys. Also, foreign keys don't include information about cardinality (to-one or to-many).

Relationships are used throughout MacSQL. For example, when exporting data from a table that has a relationship defined, the related data then becomes available just like the table's columns. The main place where relationships are used, however, is the Query Editor. The Query Editor uses relationships as the basis to JOIN multiple tables together.

Relationships will automatically be created for Oracle, Sybase, SQL Server, and PostgreSQL connections based on any existing foreign keys.

Manipulating Relationships

To add a relationship, navigate to a table with the schema browser and select the Relationships item. Then select Add Relationship... from the Schema menu. To Edit a relationship, select a relationship in the schema browser and select Edit Relationship... from the Schema menu. You can also select Delete Relationship... if you want to remove the relationship.

Adding/Editing a relationships involves the following fields:

Name The name this relationship will be referred by.
Type This defines the cardinality of the relationship. If only one row exists in the destination table for each row in the source table, select To One. If multiple destination rows exist for each source row, select To Many.
Local Column This is the column in the source table that must match a column in the destination table. Currently MacSQL does not support relationships based on multiple keys.
Foreign Column This is the column in the destination table that completes the relationship. Use the schema browser to select a column in the destination table that matches the local column specified above.

Table of Contents