Solved

Setting FK in SQL server management studio

Posted on 2009-05-08
7
666 Views
Last Modified: 2012-05-06
I am not an experienced programmer and am setting a small sports team DB using SQL Management Studio for our web site.  I have two tables.  One is TeamType.  It has a PK of TeamTypeID, then TeamName.  That will hold team types like baseball, soccer, basketball, etc.  Then I have a Team table.  PK is TeamID. I would like a FK of TeamTypeID.  But without coding, I don't see how to set this as a FK in the Team table.  Thanks for helpl
0
Comment
Question by:hconant
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Expert Comment

by:nybelle
ID: 24338212
Within Management Studio, open the keys/indexes properties on the Team table. There you can create the FK.
0
 

Author Comment

by:hconant
ID: 24338381
I did that, tried that.  I established the relationship but there is no FK next to the field in the database design view.
0
 

Assisted Solution

by:sridharkamala
sridharkamala earned 100 total points
ID: 24338412
Expand TEAM table -- > Keys and you should see the Foreign key.
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:hconant
ID: 24338434
Maybe I am doing that wrong.  When I go to Team table and go to Add in the Indexes/Keys it defaults to adding IX_Team*, which is I assume an index, not a key?  If I go to Foreign Key Relationships it seems to be where I can establish the relationship.  In this case I have a FK_Team_TeamTypeID.  Foreign Key Base Table=Team.  Foreign Key Columns=TeamTypeID. Primary/Unique Key Base=TeamType. Primary/Unique Key Column=TeamTypeID.  This looks correct to me, but there is no FK next to the TeamTypeID column in Team table, like there is a key symbol next to TeamID.  Have I successfully created the relationship and don't know it?
0
 

Author Comment

by:hconant
ID: 24338458
In VWD, Database Explorer there is no Keys in the Team table ladder.  All i have are the columns.
0
 

Author Comment

by:hconant
ID: 24338476
I opened the DB with SQL Management Studio and I see the keys.  But that doesn't show in VWD.  Maybe it just that way?
0
 
LVL 43

Accepted Solution

by:
Eugene Z earned 400 total points
ID: 24339032
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question