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
816

Hi...

1. What is foreign Key , how do u identify ?

5 REPLIES 5
Read only

Former Member
0 Likes
762

hi,

A relationship which can be defined between tables and must be explicitly defined at field level. <b>Foreign keys are used to ensure the consistency of data</b>. Data entered should be checked against existing data to ensure that there are now contradiction. While defining foreign key relationship cardinality has to be specified. Cardinality mentions how many dependent records or how referenced records are possible.

regards,

Sudheer.

Read only

amit_khare
Active Contributor
0 Likes
762

Check the link -

Regards,

Amit

Reward all helpful replies.

Read only

Former Member
0 Likes
762

Hi,

A foreign key is an attribute that completes a relationship by identifying the parent entity. Foreign keys provide a method for maintaining integrity in the data (called referential integrity) and for navigating between different instances of an entity. Every relationship in the model must be supported by a foreign key.

Identifying Foreign Keys

Every dependent and category (subtype) entity in the model must have a foreign key for each relationship in which it participates. Foreign keys are formed in dependent and subtype entities by migrating the entire primary key from the parent or generic entity. If the primary key is composite, it may not be split.

Foreign Key Ownership

Foreign key attributes are not considered to be owned by the entities to which they migrate, because they are reflections of attributes in the parent entities. Thus, each attribute in an entity is either owned by that entity or belongs to a foreign key in that entity.

If the primary key of a child entity contains all the attributes in a foreign key, the child entity is said to be "identifier dependent" on the parent entity, and the relationship is called an "identifying relationship." If any attributes in a foreign key do not belong to the child's primary key, the child is not identifier dependent on the parent, and the relationship is called "non identifying."

Regards,

Priyanka.

Read only

Former Member
0 Likes
762

Hi,,

Check if the following info is useful

You can define the relationships between tables in the ABAP Dictionary by creating foreign keys.Using foreign keys, you can easily create value checks for input fields. Foreign keys can also be used to link several tables in a view or a lock object.

A foreign key links two tables T1 and T2 by assigning fields of table T1 to the primary key fields of table T2.Table T1 is called the foreign key table (dependent table) and table T2 the check table (referenced table). The pair of fields for the two tables must have the same data type and length. One field of the foreign key table therefore corresponds to each key field of the check table. This field is called the foreign key field.

A foreign key permits you to assign data records in the foreign key table and check table. One record of the foreign key table uniquely identifies one record of the check table using the entries in the foreign key fields.

Check Field and Value Check

One of the foreign key fields is marked as the check field. This means that the foreign key relationship is maintained for this field.

When an entry is made in the check field, there is a check whether the check table contains a record with the key defined by the values in the foreign key fields. If this is so, the entry is valid. Otherwise the system rejects the entry.

<b>please reward if useful</b>

Regards Dinesh

Read only

Former Member
0 Likes
762

Hi,

Semantic Attributes of Foreign Keys

A foreign key describes a relationship between two tables. You can define this relationship more precisely by specifying the cardinality and type of foreign key fields.

This information is optional and is primarily for documentary purposes. In particular, the definitions of the cardinality and type of the foreign key fields are not used in the value check for the foreign key.

The definition of the semantic attributes is only used in the following cases:

If Key fields of a text table is selected as the type of the foreign key fields, the foreign key table is considered to be the text table for the check table. If a screen field is checked against a table, the key entries of the check table are normally displayed in the input help (F4 help) for this field. If there is a text table for the check table, each key entry displayed is enhanced with an explanatory text (contents of the first character-like field of the text table) in the user’s logon language.

Tables can only be included in a help view or maintenance view if they are linked with a foreign key. It only makes sense to create such a help or maintenance view if for each record in the primary table of the view there is no more than one corresponding record in each secondary table of the view. The system therefore checks if the foreign key with which the tables were linked in the view have suitable cardinalities when it creates a maintenance or help view.

The foreign key between tables SBOOK and SCOUNTER ensures that only existing counters can be entered in field COUNTER (counter at which the flight was booked). See the example in Foreign Keys .

A booking can be made at either a travel agency or at the carrier’s sales counter. If the booking is made at a travel agency, the field COUNTER of table SBOOK remains empty. The foreign key fields do not have to be filled, that is the left side of the cardinality is C. Any number of bookings may be made at each counter. There may therefore be any number of entries (bookings) in foreign key table SBOOK for each record of the check table SCOUNTER. The right side of the cardinality is therefore CN.

Of course several bookings can be made for the same carrier at a counter. These bookings do not differ in their foreign key fields (MANDT, CARRID, COUNTER). The entries in the foreign key fields therefore do not uniquely identify an entry in the foreign key table SBOOK (a booking). The foreign key fields therefore have the type No key fields/candidates.

Hope this helps u..

>>>>reward points if useful<<<<<<<