Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Data dictionary

Former Member
0 Likes
1,004

what r different types of foreign key relations?

1 ACCEPTED SOLUTION
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
839

Hi,

Cardinality is the factor that classifies the Foriegn key relation ship.

And its as follows.

The cardinality (n : m) describes the foreign key relationship with regard to the number of possible dependent records involved (records of the foreign key table) or referred records (records of the check table).

n = 1

For each dependent record there is exactly one record of the check table.

n = C

There can be records in the foreign key talbe which do not reference any record of the check table.

and

m = 1

For each record of the check table there is exactly one dependent record.

m = C

For each record of the check table there is at most one dependent record.

m = N

For each record of the check table there is at least one dependent record.

m = CN

For each record of the check table there are any number of dependent records.

Best Regards,

Sesh

5 REPLIES 5
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
840

Hi,

Cardinality is the factor that classifies the Foriegn key relation ship.

And its as follows.

The cardinality (n : m) describes the foreign key relationship with regard to the number of possible dependent records involved (records of the foreign key table) or referred records (records of the check table).

n = 1

For each dependent record there is exactly one record of the check table.

n = C

There can be records in the foreign key talbe which do not reference any record of the check table.

and

m = 1

For each record of the check table there is exactly one dependent record.

m = C

For each record of the check table there is at most one dependent record.

m = N

For each record of the check table there is at least one dependent record.

m = CN

For each record of the check table there are any number of dependent records.

Best Regards,

Sesh

Read only

Former Member
0 Likes
839

2 types of foreign keys are there.

1)generic foreign key

2)constant foreign key

Read only

Former Member
0 Likes
839

The SAP environment's relational data model can contain many tables, views, structures, and linked tables. Foreign keys, it can be said, define these relationships between multiple tables. The functions that foreign keys perform include providing help data and creating dictionary objects, but the one that you will focus on will be in the data validation area. After all, maintaining data integrity is one of the main goals when defining selection screens and the most important use of foreign keys.

A foreign key field is, by definition, restricted to values that correspond to those of the primary key of the input field's check table. This is how the link between the two tables is made. One table, FORKEY1, can be thought of as the foreign key (or dependent) table mainly because it includes foreign key fields that are assigned to primary key fields in CHECK1, which is referred to as the check (or reference) table.

The foreign key field and the primary key of a parent table must share the same domain and a value table for that domain must also be specified. This extends, in a way, the data integrity check usually provided by the value table alone.

Some check tables can have multiple primary key fields. In such cases, assignments must be made for each field when initiating a foreign key relationship. Three options are as follows:

Use a partial foreign key. In this case, some fields will not be a factor when validating acceptable values for entries in the foreign key field. Certain fields are flagged as generic in this case and thus ignored by the system on validation.

Use a constant foreign key. In order for the field input to be valid, the value must match that of the constant in the check table.

Create a field-to-field assignment. This is the most thorough of the three choices. Every primary key field in the check table is matched with a field in the foreign key table and all key fields are then used to determine valid entries in the foreign key table.

Basically, the way a foreign key works resembles that of a direct select statement against the check table of the field with the foreign key. More specifically, when a foreign key check field is populated, the select statement that was generated by the SAP system when it defined the foreign key is sent by the program. If the table returns a value from that selection, the entry is valid. If the record is not found, the field input is invalid.

The following code shows the syntax for a system-generated select statement:

select * from table_1 where table_1-exam1 = fk_exam1

and table_1-exam2 = fk_exam2.

This bit of code shows an example of a system-generated select statement that is called when data is entered into the field with the foreign key definition. In this scenario, an entry in this screen field is permitted only if the select statement produces valid data from the check table using the data entries made in fields fk_exam1 and fk_exam2 as keys.

One thing that you must keep in mind while creating foreign key relation-ships is the cardinality. The cardinality of a foreign key, together with its type, is referred to as the semantic attributes of the foreign key. Each cardinality of a foreign key of these entries is optional. The cardinality should not be overlooked, however, because the entry is good practice and becomes necessary when you want to create certain types of aggregates such as help views, for example.

Cardinality is a description of the relationship between one or more data elements to one or more of another data element. If a foreign key linking two tables has been defined, the record of the foreign key table refers to a record of the check table. This reference is constructed by assigning fields of one table, the foreign key table, to the primary key fields of the other table, the check table.

The relationship exists only if the foreign key fields are of the same data type and length as the corresponding primary key fields. A check or parent table is the table that is referenced by the foreign key itself. This is usually a value table, but it can also be a table consisting of a subset of the contents of a value table. A value table dictates the valid values that are assigned to the data element's domain.

In some cases, a constant foreign key might best suit your needs. This is the case when all valid entries in the input field contain a specific value in the key field of the cited check table. Upon the select statement's query, the constant field is checked against the primary key field that contains the fixed value.

Read only

Former Member
0 Likes
839

Hi,

Check this URL.

Hope it helps you.

http://searchsap.techtarget.com/search/1,293876,sid21,00.html?query=definedifferenttypesofforeignkeyrelations&bucket=ALL

Reward if it useful

Thanks.

Read only

Former Member
0 Likes
839

hi roja

Candidate foreign keys are keys that were inferred during analysis. There are five types of foreign key analysis reports

<u>Defined foreign key summary report</u>

Shows a summary of the defined foreign keys in your data.

<u>Referential integrity exceptions report</u>

Shows a summary of the foreign keys in your data that do not match the values of an associated primary key.

<u>Defined, candidate, and chosen foreign keys report</u>

Shows a summary of the defined, candidate, and chosen foreign keys in your data.

<u>Referential integrity detail report</u>

Shows a summary of the referential integrity between the foreign keys and associated primary keys in your data.

<u>Primary keys without children detail report</u>

Shows a summary of the primary keys that do not have associated records with the foreign keys in your data.

REWARD IT PLEASE...!!