SQL Server Management Studio (SSMS) provides a built-in tool to create a visual representation of your database schema, also known as a Database Diagram. Here’s how you can create one:
Step 1: Open SQL Server Management Studio (SSMS)
First, launch SSMS and connect to your SQL Server instance.
Step 2: Open the Database Diagram Designer
In the “Object Explorer” panel on the left side, navigate to your database and expand it. You should see a folder named “Database Diagrams”.
Right-click on the “Database Diagrams” folder and select “New Database Diagram”.
Step 3: Select Tables
A new window will pop up with a list of tables in your database. Select the tables you want to include in the diagram and click “Add”. Once you’ve added all the tables you want, click “Close”.
Step 4: Arrange Tables and Relationships
The diagram will now show the tables you selected, along with their columns, data types, and relationships (if any). The relationships between tables are represented by lines connecting the keys.
You can click and drag the tables to arrange them as you like. If the relationships are not automatically displayed, you can manually create them by clicking and dragging a column from one table (usually the primary key) and dropping it onto the related column in another table (the foreign key).
Step 5: Save the Database Diagram
Once you’re happy with your database diagram, right-click on the design surface and choose “Save Diagram” or just close the diagram window and you will be prompted to save the changes.
The saved diagram will now appear in the “Database Diagrams” folder in the Object Explorer and you can reopen it anytime.
Please note, the user must have the appropriate permissions to create a database diagram. If the “Database Diagrams” folder is not visible, you may not have the necessary permissions, and you’ll need to speak with your database administrator.
Also, be aware that as of October 2020, Microsoft has deprecated the Database Diagram feature in SSMS version 18.0 and onwards. If you’re using these versions, you might need to use a third-party tool or an earlier version of SSMS to create a database diagram.