MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL 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:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 21st, 2004, 11:52 PM
iso iso is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2003
Posts: 506 iso User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 10 h 14 m 25 sec
Reputation Power: 5
odd relationship error

I can't figure this one out. I have a feeling there is a simple solution, but I just can't see it. Below is the code for the two tables that are causing the problems.

Here is the error that I get
----
There are no primary or candidate keys in the referenced table 'PlayerPools' that match the referencing column list in the foreign key 'playerPicks_poolID_fk'.
----

on the attached pic part of the ERD is shown for the tables that are involved with the table that I am having trouble inserting.

Thanks for any help that anyone can offer.

Code:
 
------------------------------------------------------------------------------------------------------
--PlayerPools 
------------------------------------------------------------------------------------------------------
--Drop Table PlayerPools
Create Table PlayerPools
(
	playerID	int	not null
	,poolID		int not null
	,Constraint playerPools_PlayerID_PoolID_pk
		Primary Key(playerID, poolID)
	,Constraint playerPools_playerID_fk
		Foreign Key(playerID) 
			references poolPlayers(playerID)
	,Constraint playerPools_poolID_fk 
		foreign key(poolID) 
			references pools(poolID)
)
Go
------------------------------------------------------------------------------------------------------
--playerPicks  -->can't insert this table
------------------------------------------------------------------------------------------------------
--Drop Table playerPicks

Create Table playerPicks
(
	poolID				int	not null
	,poolPlayerID		int	not null
	,hockeyPlayerID		int	not null
	,billID				int	not null
	,CONSTRAINT playerPicks_poolID_pk
		PRIMARY KEY (poolID, poolPlayerID, hockeyPlayerID)
	,CONSTRAINT playerPicks_poolID_fk
		FOREIGN KEY (poolID)
			REFERENCES PlayerPools(poolID)
	,CONSTRAINT playerPicks_poolPlayerID_fk
		FOREIGN KEY (poolPlayerID)
			REFERENCES playerPools(playerID)
	,CONSTRAINT playerPicks_hockeyPlayerID_fk
		FOREIGN KEY (hockeyPlayerID)
			REFERENCES hockeyPlayers(playerID)
)
Attached Images
File Type: jpg Clipboard01.jpg (23.7 KB, 118 views)

Reply With Quote
  #2  
Old March 22nd, 2004, 02:47 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,766 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 6 h 24 m 8 sec
Reputation Power: 37
Code:
CONSTRAINT playerPicks_fk
		FOREIGN KEY (poolID,poolPlayerID)
			REFERENCES PlayerPools(poolID,poolPlayerID)

Reply With Quote
  #3  
Old March 24th, 2004, 07:33 PM
sypher sypher is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Montreal
Posts: 92 sypher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 10 sec
Reputation Power: 5
you need to create the table poolPlayers first them run the code above

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > odd relationship error


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 4 hosted by Hostway