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



See also


Open the Database Builder.

The Database Builder


Load or create a Data model.


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


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


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



See also


Open your Data Modeling diagram and, if necessary, display the Data Modeling page of the Diagram Toolbox (More tools | Data Modeling).


Drag the Function icon onto the diagram.

This generates the Function element:


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 is a dialog that is shared by a number of SQL-based database objects (Views, Procedures and Functions) and that helps you to manage the various properties of the SQL-based object.



See also


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


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


Type the full SQL Function definition.

The code editor provides Intelli-sense for basic SQL keywords and functions.

Intelli-sense Options - Code Editors

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

Learning Center topics

  • Alt+F1 | Enterprise Architect | Database Engineering | Physical Data Model | Functions