Hi, I'm trying to do an exercise and have just been introduced to the very basics of SQL. I've made 3 different tables and now I want to add relations between them.
My question is how to make a foreign key? I have a Table "Person" and a table "Phone number". In Table "Person" my primary key is ID and in Table "Phone" my primary key is Phone number. I want key to also be a foreign key that points on ID in Table "Person".
In order to do so I added ID as a column in table "Phone number" as well, right clicked on it and chose relationships. Then I choose Person as the "primary key table" and refered to ID as the primary key and on the right side of the screen I picked ID as the foreign key in "Phone" table.
So no I have a ID in Phone table that is a foreign key to an ID in Person table... that's not what I want :S Any suggestions?
Related Posts
How do i execute different query using loop
How do i execute different query using loop I'm trying to retrieve the number of count[...]
How To make .exe to project using C#
How To make .exe to projectusing C# in MS Visual Studio.Just compile and build your application, the[...]
Installing dot net framework 3.5
i'm having problem with installing dot net framework 3.5, my internet connection is not working cons[...]
PHP Include code
I searched Google, it didn't find what I needed.Back when I was into programming a lot, (high school[...]
Subscribe to:
Post Comments (Atom)
Powered by Blogger.
FOREIGN KEY (column name) REFERENCES other table name(other column)
ReplyDeletei hope this helped
ugh I'm not really good with MS SQL
ReplyDeletebut check this site :
http://www.w3schools.com/sql/sql_foreignkey.asp
I think I know how to do it... my problem is just that... a foreign key must always point at a primary key, but the types and names have to match, so I'm a bit confused
ReplyDelete