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

problem in foreign key relationship..

Former Member
0 Likes
746

Hi All,

I have created 2 table. First is Ztab1 which is check table and second is Ztab2 as foreign key table.

I have created couple of nonprimary key fields in table Ztab2 as foreign key fields, i want to know can i create primary key field in table Ztab2 as foreign key field.

And after creation of foreign key table, i want to know if i'll delete any record from table Ztab1 then should the same record be deleted automatically from table Ztab2 ?

Thnx.

5 REPLIES 5
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
711

It wont delete automatically.

Try to keep some deletion indicator in your primary table and update it.

Use maintenance view for data manipulation

Read only

0 Likes
711

Thanks for ur reply

Can u please tell me how to set deletion indicator in table ...

can please answer my first questions also

Read only

0 Likes
711

Hi,

Tarun has answered your question.

Just put a new field as like MARA-LVORM.

and when deleting just mark it with a value say 'D' .

so while picking data just ignore where deletion indicator is 'D'.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
711

Hi,

Yes you can keep the primary key fields of ZTAB2 as a part of foreign keys.

And if you delete records from table ZTAB1, then the records from table ZTAB2 won't be deleted automatically.

Instead, you will not be able to delete those records from ZTAB1 because of the foreign key relationship.

For the you need to first delete the records from table ZTAB2 and then delete from ZTAB1.

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
711

Hi,

Yes you can delete the entry from check table but it wont get deleted from foreign key table. I suggest you create maintainence view for both.

Go through below blog, it will clear your doubt:-

[;

Regards

Abhii