Prev Next

Database Functions

Database Functions provide you with a mechanism to extend the functionality of the database server. A Database Function is a routine that accepts parameters, performs an action (such as a complex calculation) and returns the result of that action as a value. Depending on the Function, the return value can be either a single value or a result set.

Once created, a Database Function can be used as an expression in an SQL statement.

In Enterprise Architect, Database Functions can be modeled in one of two ways:

  • As individual objects (the default method) or
  • As Operations in a container

Functionally the two methods result in the same DDL being produced. The main difference is visual - by having several Operations in one container, you have fewer elements and less clutter on the diagram.

Individual objects

Database Functions modeled as individual objects are UML Classes with the stereotype «function»; you create these either:

  • Within the Database Builder or
  • By dragging the Function icon from the Data Modeling Toolbox onto a diagram

Add a Database Function using the Database Builder

Step

Action

See also

1

Open the Database Builder.

The Database Builder

2

Load or create a Data model.

3

Right-click on the Functions Package and select 'Add New Function'.

4

Overtype the default name with the appropriate name for the Function, and press the Enter key.

5

Double-click on the new Function, or right-click on it and select 'SQL Object Properties'.

The SQL Object Editor screen displays.

Add a Database Function to a diagram

Step

Action

See also

1

Open your Data Modeling diagram and, if necessary, display the 'Data Modeling' page of the Diagram Toolbox (click on to display the 'Find Toolbox Item' dialog and specify 'Data Modeling').

2

Drag the 'Function' icon onto the diagram.

This generates the Function element:

3

Right-click on the new Function element and select 'SQL Object Properties'.

The SQL Object Editor screen displays.

SQL Object Editor

The 'SQL Object Editor' dialog is shared by a number of SQL-based database objects (Views, Procedures and Functions); it helps you to manage the various properties of the SQL-based object.

Option

Action

See also

Database

If it has already been set, the default database type displays.

If the default has not been set, or you want to change the database type for this Function, click on the drop-down arrow and select the target DBMS to model.

Set the Database Type

Notes

If necessary, type in a comment on the current  Function.

Definition

Type the full SQL Function definition including the CREATE FUNCTION syntax.

The code editor provides Intelli-sense for basic SQL keywords, functions and names of all objects in the current data model.

Options - Code Editors Intelli-sense

Operations in a Container

Database Functions modeled as operations have a container object, this being a UML Class with the stereotype «functions» (with an s on the end). Each Function is an operation with the stereotype «func». The system provides a dedicated Maintenance window through which you can easily manage the Database Functions stored as operations.

Learn more