Prev Next

Database Sequences

Sequences are a feature that some DBMS products implement to provide users with a mechanism to generate unique values - the Sequence ensures that each call to it returns a unique value. This is particularly important when the Sequence's result is used as a Primary Key. These can be generated with a schema for loading onto the DBMS server.

Sequences are provided so that database users are not forced to implement their own unique value generator. Not all DBMS products support Sequences; those that do not instead provide functionality for columns to be initialized with an incrementing value.

In Enterprise Architect, Sequences 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

Sequences modeled as individual objects are UML Classes with the stereotype «dbsequence»; you create these either:

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

Add a Database Sequence 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 Sequences Package and select 'Add New Sequence'.

4

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

5

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

The 'SQL Object Editor' dialog displays.

Add a Database Sequence 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 'Sequence' icon onto the diagram.

This generates the Sequence element:

3

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

The 'SQL Object Editor' dialog 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 Sequence, 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 Sequence.

Definition

Type the full SQL Sequence definition including the CREATE SEQUENCE 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 Sequences modeled as operations have a container object, this being a UML Class with the stereotype «sequences» (with an s on the end). Each Sequence is an operation with the stereotype «sequ». The system provides a dedicated Maintenance window through which the modeler can easily manage the Sequences defined as operations.

Learn more