Table of contents



Official Content

The Transaction objects generated by GeneXus carry out Referential Integrity controls.

Suppose you define the following Transactions:

Country
{
   CountryId*
   CountryName
}

Customer
{
   CustomerId*
   CustomerName
   CountryId
   CountryName
}

In consequence, the following tables will be created in the database associated with the application:

COUNTRY (CountryId, CountryName)
Primary Key: CountryId

CUSTOMER (CustomerId, CustomerName, CustomerAddress, CustomerGender, CountryId)
Primary Key: CustomerId
Foreign Key: CountryId (COUNTRY)

The fact that the CountryId attribute in the CUSTOMER table is a foreign key concerning the COUNTRY table establishes a relationship between both tables.

You can see this relationship in this diagram:

Diagram

The simple arrow means that in the table the arrow is pointing to there is an instance for every instance in the other table (this means that there is only one country for each customer).

The double arrow means that in the table it is pointing there are several instances for every instance in the other table (this means that there are several customers for each country).

The relation between the COUNTRY table and the CUSTOMER table is said to be 1 to N (1 to many).
Reciprocally, the relation between CUSTOMER and COUNTRY is N to 1 (many to 1).

In GeneXus terminology, we say that there is a subordinate relationship between both tables. We say that:

  • COUNTRY is superordinated to CUSTOMER
  • CUSTOMER is subordinated to COUNTRY

Meaning that:

  • When a record is created or modified in the subordinate table (CUSTOMER), there must be a related record in the superordinated table (COUNTRY).
  • When a record is deleted from the superordinated table (COUNTRY), there must be no related records in the subordinate table (CUSTOMER).

In other words:

  • When a record is inserted or modified in the CUSTOMER table, the value entered in the foreign key attribute (CountryId) must exist as the primary key value in a record of the COUNTRY table.
  • When a record is deleted from the COUNTRY table, there must be no records in the CUSTOMER table whose foreign key values (CountryId) are equal to the primary key value of the record you want to delete.



Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant