SQL server relationships.

There are three types of relationships and MS SQL server:

  • One-to-one relationships
  • One-to-many relationships
  • Many-to-many relationships

One-to-one

In one-to-one relationship , a key will appear only once in a related table. It is the most common type of relationship. For example, one employee has one computer:

03fig03

One-to-many

In one-to-many relationship, keys from one table will appear multiple times in a related table. For example, one department has many employees:

03fig01

Many-to-many

In many-to-many relationship, we create an intermediate table, that maps fields from two tables. For example, we have multiple students that attend multiple classes:

03fig07

 

Share this post:Tweet about this on TwitterShare on Facebook0Share on LinkedIn0Share on Google+0Share on Reddit0Email this to someoneDigg this