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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:42:34+00:00 2026-06-14T01:42:34+00:00

I have a simple schema in which soft deletes are used (that’s how it

  • 0

I have a simple schema in which soft deletes are used (that’s how it is designed and that can’t be changed). There are two tables that participate in the schema: Company (id, is_deleted) and Employee (id, company_id, is_deleted) where company_id ofcourse is a FK to the Company table. The rules are:

  • If a Company has is_deleted = true, then all Employee referring to that company should have is_deleted = true.
  • But an Employee may have is_deleted = true even if the parent Company has is_deleted = false.

My two problems are a) how to enforce these constraints? b) how to easiest ensure that is_deleted = true is cascaded when a Company is soft-deleted.

I added the tags postgresql and sql server because those are the databases I’m mostly interested in. If there are other solutions in other rdbms:es I’d like to hear about them too.

  • 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-14T01:42:35+00:00Added an answer on June 14, 2026 at 1:42 am

    Strictly speaking, the only way to cascade values like that is by using ON UPDATE CASCADE. To do that, the column “is_deleted” has to be part of a unique constraint.

    That alone isn’t too hard. If company.id is your primary key, then the pair of columns {id, is_deleted} will also be unique. A unique constraint on that pair of columns would allow you to cascade updates through a foreign key reference.

    But that won’t work in your case, because you need to allow referencing values to be different from the referenced values.

    So in your case, I think you have three options.

    • Triggers
    • Stored procedures
    • Application code

    In all those cases, you need to pay attention to permissions (probably revoking delete permissions) and to cases that can avoid your code. For example, the dbms command-line interface and GUI interface can be used to get around constraints in application code and, depending on permissions, in stored procedures.

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

Sidebar

Related Questions

I have simple ontology called campus.owl.There is a class calledLecturer and which has two
I have a super-simple query in a star schema. One fact, two dimensions. I
I have developed an application which can create Xml files from Xml schema with
So I have a simple SQL script which creates a database schema of a
I have a simple question regarding the dichotomy of joining two tables vs using
I have a simple message schema where a thread ties 2 or more users
I have a simple message schema where a thread ties 2 or more users
I have the following simple shema: var userSchema = new Schema({ name : String,
I have simple class with width and height member fields which define number of
I have a simple doc.xml file which contains a single root element with a

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.