>Sql Server: Quickest Way to Create Tables Relationship


>

Creating relationship between tables is not a big task, but I have noticed that many of us (especially I) want to create these relation in minimum time. We can create relations between tables through T-Sql (most time consuming method) or we can complete this task through graphical design view of table in Sql Server Management Studio. But I like to create these relations with following method.
1.  Create table through design view in SSMS (Quick way to create table). In our example we have created following four tables.

2.       Create a database diagram by following method
a.  Right click on “Database Diagram” and click “New Database Diagram”
b.      Add your desired tables. In our case we will add four tables
3.  Click on primary key column and drag it to related table. Verify columns to join in pop-up window and press OK for both pop-up windows. Repeat the process with all table and you are done.

4.       Cltr + S  or click on save button to save diagram and table relations.

Advertisements

Posted on January 7, 2011, in SSMS, Tables. Bookmark the permalink. 1 Comment.

  1. very informative. Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: