Foreign Key Repository (Magic xpa 3.x)
Foreign keys are pointers in an SQL database that allow you to maintain referential integrity between primary table records and records in other tables.
Each record with a foreign key points to a record with a primary key and the Foreign Key repository lets you define the relationships between these records.
Maintaining the relationship between primary keys and foreign keys is known as referential integrity. Databases support constraints through their table declarations or their declarative referential integrity.
The Foreign Key repository is a composite of two tables: the Foreign Key Definition table and the Foreign Key Segment table.
The following is a description of the Foreign Key Definition properties:
|
|
#
|
An internal automatically generated number that represents the order of the Foreign Key in Magic xpa.
|
Foreign Key Name
|
The name of the Foreign Key in Magic xpa. This name is used to define the Foreign Key in the database. A foreign key is a column or group of columns that relates a row in one table to a unique row in another table, usually by the other table’s primary key.
|
Referenced Table
|
The table to which the Foreign Key should refer to.
|
Primary Key
|
The Primary Key name for the referenced table. The Primary Key is a column or a group of columns that has a unique key, and considered the main access route to the row. There can be one or more unique keys to a table, but there can be only one Primary Key.
|
Create in DB
|
This check box lets you specify if the Foreign Key is limited to Magic xpa or also relates to the database. Create in DB is checked by default if the referenced table is in an SQL table from the same DB as the Main source. Otherwise, this check box is disabled and unchecked.
|
The limits listed above restrict the values of columns in the table either absolutely or in certain columns of the specific table. The current ANSI standard requires that the definition of these constraints be declared as part of the table creation or modification.
The following is a description of the Foreign Key Segment properties:
|
|
#
|
A generated number that represents the order of the table segment.
|
Current Table's Columns
|
These segments can be selected from the current table by zooming in the Column list. Each segment in the current table must have a matching segment in the referenced table.
|
Referenced Table's Columns
|
These segments can be automatically inserted when selecting the index defined for the referenced table. Exchanging one index for another overwrites the segments with the new index segments.
|
Note:
|
-
You can only define a foreign key to a table where a primary key exists. A primary key is defined for a record in the Index repository.
-
XML sources can be selected as referenced tables in foreign keys of other tables.
-
Foreign keys are not supported for the Web Service database at runtime. If they are defined, they will be ignored. Foreign keys can still be defined in the Studio.
|
Program Generator's Foreign Key Selection Repository