Wednesday, 29 May 2013

How to create data base diagram in ms sql

Creating data base diagram is a few step process which are given as below.

Step First :

Open object explorer , click on Databases and  select on one database for which you want to create data base diagram. Now click on database and then right click on Database Diagrams. Now select New Database Diagram.


 Step Second

After selecting New Database Diagram a Add Table window will be appeared. You have to select either existing table or select new table after right clicking on the diagram window.





























Step Three

Now I have create 4 new tables like Office , Department, Employee , Employee_Details



Now we will establish the relationship between tables. First we set primary key using right click on cloumn Office Id of the table Office ,













Now we establish the relationship between tables. This is very simple drag and drop process for table relationship. We will click on a column in a table and drag on another column of the second table.Now a window will be appered on the screen as below















 After Click on ok button you have to set Delete and Update rule in Foreign Key Relationship Window














We will establih relationship among all tables, we can remove realtionship between tabels using right click on connection bar and select Delete Relationship from Database. It will remove relationship from the database.

Now finally all table structure will look like this as below...