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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:00:10+00:00 2026-05-20T01:00:10+00:00

I have a problem in updating records to a derby db table with foreign

  • 0

I have a problem in updating records to a derby db table with foreign key. Consider the two tables QUESTIONCHOICE and QUESTIONANSWER below. The records in table QUESTIONANSWER is a subset of QUESTIONCHOICE and has a foreign key constraint to make sure QUESTIONANSWER table is always subset of QUESTIONCHOICE table.

Now i am trying to update a record in QUESTIONCHOICE table using the query below and the update is stopped by foreign key constraint.

update “USER”.”QUESTIONCHOICE” set “CHOICE”=’GET1′ where “QID”=10001 and “CHOICE”=’GET’;

UPDATE on table ‘QUESTIONCHOICE’ caused a violation of foreign key constraint ‘QUESTIONANSWER_FK’ for key (10001,GET). The statement has been rolled back.

How am i supposed to update the records in the table QUESTIONCHOICE?
i can delete the record in QUESTIONANSWER table update my record in QUESTIONCHOICE table and then insert the record in QUESTIONANSWER. but it doesnt sounds good to me.

Also can i create QUESTIONANSWER as a VIEW instead a TABLE, If so how will i make a subset of QUESTIONCHOICE table?

please suggest.

Thanks,

-Vijay Selvaraj

----------
CREATE TABLE USER.QUESTIONCHOICE(
QID INT NOT NULL,
Choice VARCHAR(100) NOT NULL,
CONSTRAINT QUESTIONCHOICE_PK PRIMARY KEY (QID, Choice),
CONSTRAINT QUESTIONCHOICE_FK FOREIGN KEY (QID)
    REFERENCES user.questionbank (QuestionID)
);

----------
create table USER.QUESTIONANSWER(
QID INT NOT NULL,
Answer VARCHAR(100) NOT NULL,
CONSTRAINT QUESTIONANSWER_PK PRIMARY KEY (QID, Answer),
CONSTRAINT QUESTIONANSWER_FK FOREIGN KEY (QID, Answer)
    REFERENCES USER.QUESTIONCHOICE (QID, Choice)
);
  • 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-20T01:00:11+00:00Added an answer on May 20, 2026 at 1:00 am

    Why dont you add a additional column to the QUESTIONCHOICE table to mark a row as the answer row, this way, the view also can be created by applying a constraint on the answer column.

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

Sidebar

Related Questions

I am having a problem updating several rows of a mysql table using a
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with return statment >.< I want to store all magazine names
I have problem with starting processes in impersonated context in ASP.NET 2.0. I am
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem with ActionLink. I'd like to pass to my ActionLink parameter for
I have problem when I try insert some data to Informix TEXT column via
I do not have problem as such but I am quite new to Ruby.
I have a problem using the Java search function in Eclipse on a particular
I have a problem with a little .Net web application which uses the Amazon

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.