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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:57:11+00:00 2026-06-15T03:57:11+00:00

What is the best practice when deleting records from a database? For example, if

  • 0

What is the best practice when deleting records from a database?

For example, if you have got this online booking tours application.

You have a tour table with a record to be removed, but the tour table also links to the booking table and customer table. Now should the record be allowed to be removed, or should there be a field like a flag that say archive, etc.

What’s best practices?

Regards,
Tea.

  • 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-06-15T03:57:12+00:00Added an answer on June 15, 2026 at 3:57 am

    As Branko said, it depends on your requirements (and your database layout).

    If you want to keep a full history, you probably wouldn’t be deleting much. Just setting a cancelled flag would probably be best.

    Just in terms of your example database design, I’d say tour should be linked to booking, but not to customer (booking should provide a many-to-many mapping of tour to customer).

    To build on your example, you probably shouldn’t be allowed to delete a customer that is booked on any tour (or the booking needs to also be deleted). When a tour is deleted, all bookings for that tour needs to be deleted (and you possibly need triggers on deletion of a booking (or a tour) to notify the customers that their bookings have been cancelled, or this trigger can be handled outside of the database).

    As you can probably see from the above, there are no concrete rules, you need to logically think about what should or shouldn’t be allowed for your specific database design and what needs to happen when something is deleted.

    The default is ON DELETE NO ACTION for a foreign key, which is the safest setting. It should go without saying that you should not freely use ON DELETE CASCADE or some non-default setting across the board without specifically having thought about each instance of that setting and whether using that setting is justified.

    You also always ideally need to design your database in such a way that, if someone were to take it over, it would be difficult to accidentally delete the wrong things because this person doesn’t know the exact tricks of using the database (e.g. which things need to be done in what order). A more strict or safer setting for your foreign keys would make this happening more difficult.

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

Sidebar

Related Questions

Best practice for developing .NET programs seems to be this: never reference dlls from
what is the best practice of deleting a parent in a unidirectional hibernate mapping
What is the best practice for generating valid XML with PHP from user submitted
I have a big database (~4GB), with 2 large tables (~3M records) having ~180K
What is the best practice for validating my model for different actions, for example,
This is more a question about what's the best practice in implementing this. I
what is the best practice to avoid SQL injections. I have ran a McAfee
What's the best practice for deleting an ndb entity that contains blob keys? Should
What's the best practice for leveraging s3 I've got a Rails app that's hosted
This is more a best practice question than it is a coding question. In

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.