Insert Database Object

Top Previous Topic Next Topic  Print this topic

Inserting a Database Object allows you to include database tables, stored procedures, and views.  You can access each of these Object types by selecting Insert in the Side Menu.  In the Insert Dialog you will find the option to insert a Database Object in the Database group of the menu.  In this section, you can find helpful information on what each Database Object is and how you can use them in your Data Diagram.

insert_dbo_intro

Figure 1:  The Database Object option is found in the Insert Dialog.

Usage

To access the available Database Objects within your established Database Connections, select Database Object.  The Insert Database Object dialog will now be displayed and will show all current database connections.  Here, you can expand each connection to reveal available tables, stored procedures, and database views.  You can use the arrow to the left of each item to expand and collapse to find the Objects you would like to include.  Once you have selected the object of your choice, you can choose the Insert button at the bottom of the dialog to include in your Data Diagram.  Below, you can find descriptions of each type of Database Object and review its usage.

insert_dbo_dialog

Figure 2:  The Insert Database Dialog allows easy access to Database Objects.

Tables

A database Table data source represents a table in a conventional relational model database.  When using this type of data source, you can specific fields that you would like to include that are present in the database table.  You will often wish to include some or all fields from a particular table in your database, and here is where you can insert the table to select them. Simply, expand data connection, expand the Tables option, and select the Table you would like to include.  Once selected, choose the Insert button at the bottom of the dialog to add to your Data Diagram.

insert_dbo_table

Figure 3:  The HumarResources.Department Table is added to the Data Diagram.

 

You will notice that in the Insert Database Object dialog, you can preview the available Fields for output inclusion when you expand any given Table.  In Figure 3, the HumanResources.Department table is now present in the Design Surface. Now that the Table is inserted into the diagram, it can be resized, moved, and Data Connections can be used to map data from the Table to the output source or other Diagram Objects.

Stored Procedures

A Stored Procedure data source is used to invoke a stored procedure from a database.  In a database management system, a Stored Procedure is a set of Structured Query Language (SQL) statements with an assigned name that's stored in a database in compiled form so that it can be shared by a number of programs.  When you insert a Stored Procedure diagram object into your Data Diagram, you notice that it will consist of a stored procedure that contains one or more SQL queries, the data to be queried for output, and also one or more named input parameters.

insert_dbo_sp

Figure 4:  A Stored Procedure is used in the Data Diagram.

 

Once you have selected the Stored Procedure you would like to use, you can choose Insert to add this object into your Data Diagram.  You will notice in Figure 4 that this example Stored Procedure requires an input parameter called EmployeeID. This value is present in the HumanResources.Employee table as indicated in light blue.  You will need to use Data Connections to map not only the input parameter, but also to choose and map from the available Fields generated by the inserted Stored Procedure.  In our example, we have included the employeeID, firstname, and lastname fields in the output XML.

Database Views

A Database View is the result set of a previously designed function, map, or query that may produce a subset of any given table located in a relational database.  If your database contains Views, you can easily include them in your Data Diagram as well.  An example of such an object would be if you have created a View that reduces a table of 50 fields to the only 10 applicable fields needed.  You can insert a Database View by expanding the Views option in the Insert Database Object dialog, selecting your View, and choosing the Insert button.

insert_dbo_view

Figure 5:  A Database View is inserted into the Data Diagram.

 

Once inserted into your Data Diagram, you can use Data Connections to map the available Fields generated by the View to your output source.  In the example highlighted in Figure 5, you can notice that the employeeID, firstname, middlename, lastname, and jobtitle fields are included.

 

At any point, you can access the capability to Insert Database Objects by selecting Insert in the Side Menu.  However, it should also be noted that you can select to include multiple objects at once when Creating a New Data Diagram.