What is foreign key table in SAP?

You use foreign keys to define relationships between tables in the ABAP Dictionary, create value checks for input fields and link several tables in a view or a lock object . Table T1 is called the foreign key table (dependent table) and table T2 the check table (referenced table).

Which table should have the foreign key?

child table
The table that contains the foreign key is considered the child table, and the table that the foreign key references is the parent table. The foreign key restricts what data can be stored in the foreign key columns in the child table, based on the data in the referenced columns in the parent table.

What is cardinality ABAP?

Cardinality is a property of a join that describes how many rows in one table match rows in another table. and it’s expressed as the minimum and maximum number of rows in a column at one end of a join that have matching rows in the column at the other end of the join.

What is a foreign key in ABAP Dictionary?

You use foreign keys to define relationships between tables in the ABAP Dictionary, create value checks for input fields and link several tables in a view or a lock object . This field is called the foreign key field. A foreign key allows you to assign data records in the foreign key table and check table.

Can foreign key be primary key of same table?

If you mean “can foreign key ‘refer’ to a primary key in the same table?”, the answer is a firm yes as some replied.

How are foreign keys used in SAP ABAP?

Foreign keys describe the relationship between the tables in the ABAP Data Dictionary. Foreign keys can also be used to create value checks for the input fields, and when a foreign key relationship is maintained for particular field To create foreign keys you can use SE11 SAP Transaction code.

What are the fields in the foreign key table?

As we can see in the above diagram, there are two tables, T1 (Foreign key table) and T2 (Check Table). The T2 table contains two primary key fields Field5 and field 6, and the T1 table includes the two foreign key fields, Field 2 and Field 4, with one primary key Field 1.

How are value checks done with foreign keys?

We can create value checks for input fields using the foreign keys. Value checks are required to validate the values of some fields in a table with the values of other fields of different tables. The table that contains the foreign key is called a foreign key table and another table that contains valid fields, known as the value table.

How is a SELECT statement generated in SAP ABAP?

A SELECT statement is generated from the definition of the foreign key. If you make an entry in the check field, the system submits this SELECT statement. If the system finds a suitable record of the check table, the entry is valid. Otherwise the system rejects the entry.