Return-Path: X-Original-To: apmail-db-derby-user-archive@www.apache.org Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8C1729531 for ; Wed, 4 Apr 2012 21:27:30 +0000 (UTC) Received: (qmail 17330 invoked by uid 500); 4 Apr 2012 21:27:30 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 17298 invoked by uid 500); 4 Apr 2012 21:27:30 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 17290 invoked by uid 99); 4 Apr 2012 21:27:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2012 21:27:30 +0000 X-ASF-Spam-Status: No, hits=0.8 required=5.0 tests=SPF_PASS,UPPERCASE_50_75 X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.26 as permitted sender) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2012 21:27:23 +0000 Received: from isper.nabble.com ([192.168.236.156]) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1SFXjK-0004i3-Sl for derby-user@db.apache.org; Wed, 04 Apr 2012 14:27:02 -0700 Message-ID: <33564657.post@talk.nabble.com> Date: Wed, 4 Apr 2012 14:27:02 -0700 (PDT) From: John Steele To: derby-user@db.apache.org Subject: Constraint already exists in Schema 'APP' MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: programjsteele@gmail.com I have three tables Person, Patient, and Employee. Both Patient and Employee have a Foreign Key to Person; however, when creating the constraint for the second time I get the following error: Constraint 'PERSON_FK' already exists in Schema 'APP'. [code] CREATE TABLE PERSON ( PERSON_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) ); CREATE TABLE PATIENT ( PATIENT_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), PERSON_ID INTEGER NOT NULL ); ALTER TABLE PATIENT ADD CONSTRAINT PERSON_FK Foreign Key ( PERSON_ID) REFERENCES PERSON ( PERSON_ID); CREATE TABLE EMPLOYEE ( EMPLOYEE_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), PERSON_ID INTEGER NOT NULL ); ALTER TABLE EMPLOYEE ADD CONSTRAINT PERSON_FK Foreign Key ( PERSON_ID) REFERENCES PERSON ( PERSON_ID); [/code] What do you do in this situation? Do you only create on constraint and then reference it when using it again? If so, how? Thanks, John Steele -- View this message in context: http://old.nabble.com/Constraint-already-exists-in-Schema-%27APP%27-tp33564657p33564657.html Sent from the Apache Derby Users mailing list archive at Nabble.com.