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: 

Data dictionary : multiple foreign keys

dhorions
Contributor
0 Kudos
773

Hello,

can anyone tell me how I assign more than 1 foreign key to a table for the same field?

Is that even possible?

I created a diagram of what I want to achieve, I hope this is clear, if not, just ask.

<a href="http://www.quodlibet.be/files/foreign_key.jpg">figure</a>

8 REPLIES 8

Former Member
0 Kudos
270

well you gotta work the other way round. your tables child_a and child_b nood to implement that field and have it marked as foreign key.

0 Kudos
270

I tried that, but then I got an error message when I tried to insert a new record to my 'main' table, saying it didn't exist in the other table.

But I'll check it again just to make sure.

Thnx.

0 Kudos
270

yeah that is the relational data model.

you can not create a record which has a reference to something that doesnt exist.

e.G. in an sales order, we have a field for customer. well you cant create a sales order and fill in a customer that doesnt exist.

thats exactly the thing for which foreigh keys are made.

0 Kudos
270

You get me wrong, what I am saying is that it should be possible to create a customer if a sales order does not exist, but like I said, i'll just double check if I didn't make any mistakes.

Thanks anyway.

0 Kudos
270

I don't seem to get it right,

I have three tables, like in the figure in my initial post.

In table CHILD_A I create a foreign key (with check required) linked to the field ID in the table MAIN.

When I add a new record to the table MAIN, I get the error message that I defined in the foreign key.

What I expected was this error to occur when I added a field to table CHILD_A that didn't have a corresponding record in table MAIN.

0 Kudos
270

hmmm ok, thnen i lost overview, maybe you goto the Tables MARA, MARC, MARD, MARM and check how they have solved the issue there.

0 Kudos
270

After triple-checking my program, I found that the problem only occured when I had a search help linked to that field on my screen.

So it does work like I suspected, and like you guys said it would, but the check was more severe than I thought.

Thank you all.

Former Member
0 Kudos
270

Hi

yes you can creat

for example

MARA, MARC,MARD

these 3 tables having MATNR field as the same

MARD and MARC are the two tables which having FK relation to MARA

try this

reward if usefull