Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3285816
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:18:33+00:00 2026-05-17T20:18:33+00:00

So you have a relational database and you define some foreign keys for reference

  • 0

So you have a relational database and you define some foreign keys for reference integrity. But now, what’s the better way to leverage them? Assume we are going to delete a row in a table with foreign keys to other tables.

  1. Use them as a garbage collector – Set all constraints to cascade. So in your application, you first check if the target row has any “children” and present the user the option to abort the delete operation if it is undesirable to have the dependent rows deleted as well.

  2. Use them as actual constraints – In your application, just attempt to delete the target row. If the operation failed, then check if it has children and present the options to the user; If the user wants to proceed with the operation, manually delete the depending rows first.

The second option makes deleting circular references rather arduous – You have to set the foreign keys to null before you can even delete anything.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:18:34+00:00Added an answer on May 17, 2026 at 8:18 pm

    There are 2 typical foreign key scenarios:

    • Association: link 2 entities that can exist on their own
    • Composition: link a child entity to its parent entity (the child entity does it exist without a parent, for instance: order and order item)

    I’d cascade only in the case of composition and treat each association case individually.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I heard that decision tables in relational database have been researched a lot in
I have been working with relational databases for sometime, but it only recently occurred
All of us who work with relational databases have learned (or are learning) that
Does anyone have any good scenarios for teaching relational databases and SQL? All the
i have in the database typical tables like user, usergroup, and they have relations.
Object-relational mapping has been well discussed, including on here. I have experience with a
I have a relation mapping table like this: attributeid bigint productid bigint To clean
I have m2m field, lets say it have name 'relations', so i want to
I understand that these methods are for pickling/unpickling and have no relation to the
I have two models: Person and Relation. The second one stores information about relations

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.