Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 I'm having trouble creating a PK-FK relationship

Author  Topic 

spmchugh82
Starting Member

13 Posts

Posted - 2009-02-17 : 18:20:51
Hi, I am brand new to SQL Server! Looks very good though!

I have tables:

Pizza(Pizza(PK,FK), Description, Price)
UsedIngredients(Pizza(PK), Ingredients(PK))
Ingredients(Ingredient(PK, FK), Description, Price)

okay, so the relationship i want looks like this:

P--1-----M--UI--M-----1--I

I can make the foriegn keys but when I try and establish a relationship I get the error message

"Both sides or a relationship must have the same number of columns"

I don't understand what I'm doing wrong. Could you PLEASE help me?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-17 : 18:24:24
Post your code you use when trying to create the pk-fk constraint.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

spmchugh82
Starting Member

13 Posts

Posted - 2009-02-17 : 18:30:55
I'm doing it with the GUI. Following the instructions on this link http://www.functionx.com/sqlserver/Lesson14.htm

Any relationship at all would make me happy at this point. I can create table1 and table2 each with one column and primary key one and foriegn key the other and then when i try to create the relationship on the foriegn key I get the same error message.
"Both sides or a relationship must have the same number of columns"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-17 : 18:34:47
See point 8.
You must have the same number of columns on left side as right side.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

spmchugh82
Starting Member

13 Posts

Posted - 2009-02-17 : 18:41:44
OKAY COOL! THANKS i just took another look.

The problem was my screen I didn't see where you could select the colum on both tables. Allright, cool, thanks!
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-02-17 : 19:17:09
AND no one has told you to BAIL on this approach and Learn SQL instead?

too bad



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -