Oracle Application Express Item

265 pts.
Tags:
Database
Foreign keys
Oracle
Primary keys
I have two tables with parent-child relationship. Is there a way to automatically populate the foreign key field of the child table with the exact data from the primary key of the parent table?

Answer Wiki

Thanks. We'll let you know when a new response is added.

This depends upon the primary key of the child table. If a record already exists in the child table with the given foreign key value and the parent record is updated, then a “post update trigger” on the parent table can be written to update the foreign key value of the child table. All key values of the child table must be available to ensure you update the correct row.

If a new record is inserted into the parent table with a new key value, then it would be necessary to have a “post insert trigger” on the parent table to create a new record in the child with the new value. But, this would not work properly unless all non-null and primary key column values were available to insert a new record into the child table.

So, the short answer to your question is “yes, if you have the right information available.”

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following