Create or edit views in Database Model diagrams - Visio
Create or edit views in Database Model diagrams
Visio Plan 2 Visio Professional 2019 Visio Professional 2016 More...
You can think of a view as a saved query. Views are particularly useful if you want to access the same information from multiple tables or expose data to users without letting the users change the actual tables.
Note: The Database Model diagram is only available in certain versions of Visio. See Can't find the database modeling features? for more information.
Add a view to a database model diagram
From the Entity Relationship or Object Relational stencil, drag a View shape onto the drawing page.
Assign columns from tables to a view
Open the database model diagram that contains the view you want to add columns to.
Double-click the view, and then in the Database Properties window, in the Categories list, click Columns.
Do one of the following:
Click the Physical Name field of a blank line and type the name of the column. Repeat for each column you want to add to the view.
Click Add. The default name for the new column follows the naming conventions you specified in the Modeling Preferences dialog box. To change the name of the column, click the default column name and type a new name. Repeat for each column you want to add to the view.
Click the name of the column whose properties you want to define, and then click Edit.
In the View Column Properties dialog box, on the Source tab, click Known column in another table or view, and then click Change.
In the Pick A Column dialog box, select a column from the list of tables and views in your database model diagram, and then click OK.
When you are satisfied with your settings, click OK.
Repeat steps 4 through 7 for each column you added in step 3.
Edit the properties of a column in a view
Open the database model diagram.
Double-click the view that contains the columns you want to modify, and then click Columns in the Categories list in the Database Properties window.
Click the name of the column you want to modify, and then click Edit.
In the View Column Properties dialog box, click the tab that contains the information you want to edit, and then make your changes.
When you are satisfied with your settings, click OK.
Edit the properties of a view
Open the database model diagram.
Double-click the view whose properties you want to edit to open the Database Properties window.
In the Database Properties window, click the category that contains the information you want to edit, and then make your changes.
The database model diagram is updated automatically.
Remove a view
Open the database model diagram.
On the drawing page, click the view you want to remove, and then press DELETE.
In the Delete Object dialog box, do one of the following:
Click Yes to remove the view from the drawing page, as well as from the model and the Tables and Views window.
Click No to remove the view from the drawing page, but not from the model or the Tables and Views window.
Note: If you do not see the Delete Object dialog box when you delete an object from the diagram, on the Database menu, point to Options, click Modeling, and then on the Logical Diagram tab in the Database Modeling Preferences dialog box under When removing an object from the diagram, click Ask User What To Do. Alternatively, if you want to remove the view from the model, click the view in the Tables and Views window, and then press the DELETE key.
Reorder views in the Code window
If the Code window is not already open, on the Database menu, point to View, and then click Code to open the window.
Note: This command is available only in the Database Model Diagram template.
Drag the view you want to reorder to a new position in the window.
Define a name space value for an entity or view
Open the database model diagram.
Double-click the entity or view whose name space you want to set to open the Database Properties window.
In the Categories list, click Definition, and then type the distinguishing text in the Name space box.
The database model is updated automatically.
Create code for views
Drag a View shape from either the Entity Relationship or Object Relational stencil.
Double-click the shape to open the Database Properties window.
Under Categories click SQL.
Type your code into the SQL window.
Can't find the database modeling features?
It is most likely that your edition of Visio doesn't include the features you are looking for. To find out which edition of Visio you have, click About Microsoft Office Visio on the Help menu. The name of the edition is in the top line of text in the dialog box.
Visio Standard does not include the Database Model Diagram template.
Visio Professional and Premium editions support the reverse engineering features for the Database Model Diagram template (that is, using an existing database to create a model in Visio) but it does not support forward engineering (that is, using a Visio database model to generate SQL code).
Note: You can find the full suite of database modeling features, including both reverse engineering and forward engineering, in Visio for Enterprise Architects. Visio for Enterprise Architects is included in MSDN Premium Subscription, which is available with Visual Studio Professional and Visual Studio Team System role-based editions.
If you are using Visio Plan 2 and want to learn about how to engineer an existing database into a database model, see the topic, Reverse engineer an existing database.