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

  • Home
  • SEARCH
  • 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 217157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:37:52+00:00 2026-05-11T18:37:52+00:00

I have some table: table ASK with idask table PREFERENCES with idpref , fk_idask

  • 0

I have some table:

  • table ASK with idask
  • table PREFERENCES with idpref, fk_idask, fk_idstructure
  • table STRUCTURE with idstructure

With all the constraint between the id and the fk_id and a unique index on the table PREFERENCES (fk_idask, fk_idstructure).

The problem is when I have two row in PREFERENCES.

`IDPREF`   `FK_IDASK`   `FK_IDSTRUCTURE`  
 1          1            1  
 2          1            2

If I want to invert(switch?) the two structure between the preferences

`IDPREF`   `FK_IDASK`   `FK_IDSTRUCTURE`  
 1          1            **2**
 2          1            **1**

The unique index between FK_IDASK and FK_IDSTRUCTURE break up, because with the first update result in two preferences for the same ask with the same structure.

For prevent this, I make a function deleteAndResave and this solve the problem for the moment.

But now the arrive the ASSIGNATION table with idassignation and fk_idpref.

Now if I delete a Preference linked by an ASSIGNATION the constraint break.

I already find a workaround, but is ugly. There is some sane solution for this problem?

Thanks for the answer!

ps. Sorry for my bad english 🙁

  • 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-11T18:37:53+00:00Added an answer on May 11, 2026 at 6:37 pm

    You could try this:

    UPDATE
        PREFERENCES
    SET
        FK_IDSTRUCTURE = 3 - FK_IDSTRUCTURE
    

    Now, because it runs in one go, the “C” (Consistency) in “ACID” means that foreign keys and uniqueness are handled “during” but will be OK before and after.

    You can pimp the statement with CASE statements for more complex stuff

    UPDATE
        PREFERENCES
    SET
        FK_IDSTRUCTURE = CASE FK_IDSTRUCTURE 
            WHEN 2 THEN 1 WHEN 1 THEN 2 ELSE FK_IDSTRUCTURE END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 105k
  • Answers 105k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer IE is notorious for its aggressive caching of Ajax responses.… May 11, 2026 at 8:45 pm
  • Editorial Team
    Editorial Team added an answer I think the problem might be on the first line:… May 11, 2026 at 8:45 pm
  • Editorial Team
    Editorial Team added an answer Why don't you just copy the files to the drive… May 11, 2026 at 8:45 pm

Related Questions

I have a Postgresql database on which I want to do a few cascading
I want to ask a question about how you would approach a simple object-oriented
Folks, I'd like to create some T4 templates for generating class files (about 7
Say that I have two tables like those: Employers (id, name, .... , deptId).
I want to ask how other programmers are producing Dynamic SQL strings for execution

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.