Application Development 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: 

Foreign Key issue

Former Member
0 Kudos
69

I have a issue with this foreign key.I created two tables like"

zsubmaster:

mandt PK

subid PK

subname

zstudmaster:

mandt PK

studid PK

stud name

stud add

subid FK

First I created zsubmaster,then zstudmaster set subid to FK with zsubmaster.I entered records in zsubmaster 1 english,2 mathematics, 3 social.

I started entering records in zstudmaster and 'check table' push button is visible.When the cursor is in subid,dropdown appeared.When I click it those 1,2 and 3 records are seen.But if i enter 4 in sub id and save it,record is saved.I dont understand how,to my knowledge 4 should exist in zsubmaster or else it should not be saved.Can you please suggest me,how it happened?

Thanks in advance.

4 REPLIES 4

Former Member
0 Kudos
46

Hi

This should not happen really

some where something wrong.

It should not accept the 4 as values if it is not defined in the first table.

Check once again the creation of foreign key and check

Foreign key

A foreign key creates a link between two tables T1 and T2. Every primary key field from T1 (check table) is assigned a field from table T2 (foreign key field). The fields from T2 assigned to primary key fields are marked as foreign key fields.

The most important function of the foreign key is the support of data integrity. The foreign key fields can only accept values which appear in the primary key of the check table. During input the values of the foreign key fields can thus be checked against the entries of the assigned key fields of the check table.

Foreign keys are also the foundation for defining lock objects, maintenance views and help views. These objects contain fields from several tables. All the tables used in such an object must be linked with foreign keys.

Reward if useful

regards

Anji

Former Member
0 Kudos
46

Hi,

While defining Foreign Key, there will be a Check box in the screen with label "CHECK REQUIRED". You have to select the check box if you want the screen to throw error message while entering records.

Reward if answer is useful.

Regards,

Hema

0 Kudos
46

I think 'Check required' will be clicked by default.Hope Iam not wrong.

Former Member
0 Kudos
46

hi Gopi,

Please check whether both the tables are maintained.

Else use the table maintenance generator option in 'Utilities' tab.

reward if useful,

Thanks,

Teja