Home > Sample chapters > Programming > SQL Server

Creating Your First Table in Microsoft SQL Server

Creating database diagrams

One of the most unused features of SSMS is the diagramming tool. Sure, it may not be as robust as some third-party diagramming tools, but on the other hand, it is a very intuitive product. It has all the features needed to provide a visual representation of a database.

Create a database diagram using SSMS

  1. To create a database diagram, expand the AdventureWorks2012 database.

  2. Expand the Database Diagram folder.

  3. You are prompted to create support objects for diagramming if this is the first time you have created a diagram in this database. Click Yes.

  4. Right-click the Database Diagrams folder and select New Database Diagram. Select the tables that are shown in the following image by holding down the Shift key as you click the tables.

  5. Click Add.

    You will see a database diagram that includes a complete list of columns for each table and, most important, the foreign key relations between the tables.

Summary

This chapter has taken you on a journey through several new concepts, technologies, and tools. You created tables that contain columns of varying data types. In addition, you learned how to add constraints to the tables and columns that assist in ensuring the consistency and validity of the inserted or modified data. As you progress through this book, all the knowledge you gained in the chapter will continue to be helpful as you build on what you have learned here—the ride has just begun.