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 144313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:14:01+00:00 2026-05-11T08:14:01+00:00

Performance is key: Is it better to cascade deletes/updates inside of the Database or

  • 0

Performance is key: Is it better to cascade deletes/updates inside of the Database or let Hibernate/JPA take care of it?

Will this effect the ability to query for the data if cascades are inside of the DBMS?

I am using HSQLDB if that matters.

  • 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. 2026-05-11T08:14:02+00:00Added an answer on May 11, 2026 at 8:14 am

    In the case of cascading updates, you simply cannot do it in application space if you have foreign key constraints in the database.

    Example: say you have a lookup table for US states, with a primary key of the two-letter abbreviation. Then you have a table for mailing addresses that references it. Someone tells you that you mistakenly gave Montana the abbreviation ‘MO’ instead of ‘MT’ so you need to change it in the lookup table.

    CREATE TABLE States (st CHAR(2) PRIMARY KEY, state VARCHAR(20) NOT NULL); INSERT INTO States VALUES ('MO', 'Montana');  CREATE TABLE Addresses (addr VARCHAR(20), city VARCHAR(20), st CHAR(2), zip CHAR(6),   FOREIGN KEY (st) REFERENCES States(st)); INSERT INTO Addresses VALUES ('1301 East Sixth Ave.', 'Helena', 'MO', '59620'); 

    Now you go to fix the mistake, without the aid of database-side cascading updates. Below is a test using MySQL 5.0 (assume no records exist for Missouri, which actually does use the abbreviation ‘MO’).

    UPDATE States SET st = 'MT' WHERE st = 'MO';  ERROR 1451 (23000): Cannot delete or update a parent row:   a foreign key constraint fails (`test/addresses`,   CONSTRAINT `addresses_ibfk_1` FOREIGN KEY (`st`) REFERENCES `states` (`st`))  UPDATE Addresses SET st = 'MT' WHERE st = 'MO';  ERROR 1452 (23000): Cannot add or update a child row:   a foreign key constraint fails (`test/addresses`,   CONSTRAINT `addresses_ibfk_1` FOREIGN KEY (`st`) REFERENCES `states` (`st`))  UPDATE Addresses JOIN States USING (st) SET Addresses.st = 'MT', States.st = 'MT' WHERE States.st = 'MO';  ERROR 1451 (23000): Cannot delete or update a parent row:   a foreign key constraint fails (`test/addresses`,   CONSTRAINT `addresses_ibfk_1` FOREIGN KEY (`st`) REFERENCES `states` (`st`)) 

    No application-side query can solve this situation. You need cascading updates in the database in order to perform the update in both tables atomically, before the referential integrity constraint is enforced.

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

Sidebar

Related Questions

Which one of the C# <Key, Value> structure implementations has better performance and higher
I write web based applications. Performance is obviously a key factor. Whilst database load
Which one is more reliable and has better performance? Setting MySQL unique key and
performance ? architecture ? the system in question will always be a MS SQL
Strange performance outcome, I have a LINQ to SQL query which uses several let
I am interested to know the performance impacts of using MySQL as a key-value
I'm wondering which of the following is going to result in better performance for
Not sure if this question makes for some poor performance down the track, but
I am trying to get a better understanding about insertion speed and performance patterns
Is it better to store an integer UserID or store Username as the key.

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.