DB2 Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDB2 Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old March 19th, 2007, 06:58 PM
Force Flow Force Flow is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 76 Force Flow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 58 m 16 sec
Reputation Power: 4
DB2 foreign keys

I have 3 tables. Table one (CERTDSCP) acts as the source for a primary key. Table two (Cert_Drafts) references those primary keys (a standard Primary key-foreign key relationship).

Now, with table three (Cert_Tests), I'm trying to reference the foreign key in table two (Cert_Drafts), and use it as a primary key in table three (Cert_Tests).

Is that permitted in DB2?

Code:
SQL0538N  FOREIGN KEY "FKCERT_DRAFTS_MPS" does not conform to the description 
of the parent key of table or nickname "TEAM.CERT_DRAFTS".  SQLSTATE=42830


Code:
CREATE TABLE CERTDSCP
( 
 MPS_NUMBER VARCHAR(10) NOT NULL, 
CONSTRAINT PK_MPS PRIMARY KEY (MPS_NUMBER),
);


CREATE TABLE Cert_Drafts 
( 
  CertID BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY,
  MPS_NUMBER VARCHAR(10) NOT NULL, 
CONSTRAINT PKCert_Drafts PRIMARY KEY (CertID), 
CONSTRAINT FKCert_Numbers FOREIGN KEY (MPS_NUMBER) REFERENCES CERTDSCP 
); 
 
CREATE TABLE Cert_Tests 
( 
  CertID BIGINT NOT NULL, 
  MPS_NUMBER VARCHAR(10) NOT NULL, 
  TestNumber INTEGER NOT NULL, 
  VersionNumber INTEGER NOT NULL, 
CONSTRAINT PKCert_Tests PRIMARY KEY (CertID), 
CONSTRAINT FKCert_Drafts_CID FOREIGN KEY (CertID) REFERENCES Cert_Drafts, 
CONSTRAINT FKCert_Drafts_MPS FOREIGN KEY (MPS_NUMBER) REFERENCES Cert_Drafts, 
CONSTRAINT UCert_Tests UNIQUE (MPS_NUMBER, TestNumber, VersionNumber) 
); 

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDB2 Development > DB2 foreign keys


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway