Foreign key set up the relationship between two tables in SAP. Let's say, for a table you create a field A and mark it as primary key. And now create a 2nd table, where A is again used as a primary key. So in this case, for 2nd table we can make a foreign key relationship with the first one. Now the 2nd table will be always depend on the first table entries.
This is how foreign key relationship works.
The table that is referenced by the foreign key (in our example, First Table) is called the check table. The check table is also known as the "referenced" or "parent" table.
The table that contains the foreign key fields (in our example, 2nd Table) is called the foreign key table. The foreign key table is also known as the "dependent" or "child" table.
- Foreign keys are used for:
- Maintaining data integrity
- Providing additional texts in the online help system
- Creating other dictionary objects that are defined over multiple tables (such as views)
We can see that sap automatically proposes some check table name for your field to map as foreign key.
Now what is a check table and value table :
Value table: The table contain a set of values at domain level. Which means that field can have values among them only.
Check table: This table is the table to which your field is mapped. This means your field will always check this table for possible values. If there no entry for your entry in that check table, you cannot add that entry to your table.
Cardinality :
When creating foreign key relationships, you have to specify the relationship in between the 2 tables. Means for 1 entry in the main table, how many can be possible in the foreign key table. This is called cardinality. Let's see how many possibilities can be happen in this case.
For the left side:
n = 1 Each record in the foreign key table refers to exactly one record in the check table.
n = C Each record in the foreign key table refers to zero or one records in the check
table.
For the right side:
m = 1 Each record in the check table has exactly one dependent record.
m = C Each record in the check table has a zero or one dependent records.
m = N Each record in the check table has at least one dependent record.
m = CN Each record in the check table has zero, one, or many dependent entities.
0 comments:
Post a Comment