database models...entity-relationship modeling is a database modeling method, used to produce a type...

335
Database Models The Sparx Systems Enterprise Architect Database Builder helps visualize, analyze and design system data at conceptual, logical and physical levels, generate database objects from a model using customizable Transformations, and reverse engineer a DBMS. Enterprise Architect User Guide Series Author: Sparx Systems Date: 2020-01-20 Version: 15.1 CREATED WITH

Upload: others

Post on 25-Jun-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

Database ModelsThe Sparx Systems Enterprise Architect

Database Builder helps visualize, analyze anddesign system data at conceptual, logical and

physical levels, generate database objects froma model using customizable Transformations,

and reverse engineer a DBMS.

Enterprise Architect

User Guide Series

Author: Sparx SystemsDate: 2020-01-20

Version: 15.1

CREATED WITH

Page 2: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,
Page 3: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

Table of Contents

Database Models 7Data Modeling Overview 9Conceptual Data Model 13Logical Data Model 15Entity Relationship Diagrams (ERDs) 16Physical Data Models 22

Database Modeling 25Create a Data Model from a Model Pattern 26Create a Data Model Diagram 30Example Data Model Diagram 34

The Database Builder 36Opening the Database Builder 39Working in the Database Builder 43Columns 52Create Database Table Columns 54Delete Database Table Columns 59Reorder Database Table Columns 61

Constraints/Indexes 63Database Table Constraints/Indexes 65Primary Keys 71Database Indexes 77Unique Constraints 83Foreign Keys 85

Page 4: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

Check Constraints 93Table Triggers 96

SQL Scratch Pad 99Database Compare 103Execute DDL 118

Database Objects 123Database Tables 125Create a Database Table 128Database Table Columns 131Create Database Table Columns 132Delete Database Table Columns 137Reorder Database Table Columns 139

Working with Database Table Properties 141Set the Database Type 144Set Database Table Owner/Schema 146Set MySQL Options 148Set Oracle Database Table Properties 150

Database Table Constraints/Indexes 152Primary Keys 158Non Clustered Primary Keys 164

Database Indexes 166Unique Constraints 172Foreign Keys 174Check Constraints 182Table Triggers 185

Database Views 188Database Procedures 192

Page 5: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

Database Functions 197Database Sequences 202Database SQL Queries 207Create Operation Containers 210Oracle Packages 213Database Connections 215

Manage DBMS Options 221Data Types 225Map Data Types Between DBMS Products 226DBMS Product Conversion for a Package 229Data Type Conversion For a Table 231Database Datatypes 233MySQL Data Types 237Oracle Data Types 239

Data Modeling Settings 241Data Modeling Notations 243DDL Name Templates 249

Import Database Schema 252Generate DDL 261Generate DDL For Objects 262Edit DDL Templates 271DDL Template Syntax 275DDL Templates 277Base Templates for DDL Generation 278Base Templates for Alter DDL Generation 287

DDL Macros 289Element Field Macros 291

Page 6: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

Column Field Macros 296Constraint Field Macros 298

DDL Function Macros 303DDL Property Macros 313DDL Options in Templates 324

DDL Limitations 330Supported DBMSs 333

Page 7: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Models

The power of model-based engineering is the ability tovisualize, analyze and design all aspects of a system. Beingable to view and manage information and data alongsideother models of a system provides great clarity and reducesthe chance of error. Enterprise Architect has extensivesupport for the data modeling discipline, ranging from therepresentation of information in a conceptual model rightdown to the generation of database objects. Whether you aregenerating database objects from the UML model or reverseengineering legacy DBMS into a model for analysis, the toolfeatures will save time and valuable project resources.

Enterprise Architect supports the modeling of information atthe conceptual, logical and physical layers. Using a numberof standard features, these models can be interconnected,providing traceability. The logical and physical models can

(c) Sparx Systems 2019 Page 7 of 335

Page 8: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

also be generated automatically using a fully customizableTransformation engine. Legacy systems can be imported,analyzed and compared using the powerful reverseengineering facility.

The Database Builder tool can be used to create andmaintain physical data models and can connect to a runningDBMS, so you can therefore import, generate, compare andalter a live database.

Notes

The Database Builder is available in the Corporate,·Unified and Ultimate editions of Enterprise Architect

(c) Sparx Systems 2019 Page 8 of 335

Page 9: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Data Modeling Overview

Information Modelers, Data Modelers and Architects areresponsible for creating models of an organization’sinformation that span multiple levels of abstraction, fromconceptual through to logical and physical. The conceptualmodels are technology independent and can be used fordiscussions with business people and domain experts,allowing the basic concepts in the domain to be represented,discussed and agreed upon. The logical model elaborates theconceptual model, adding more detail and precision but isstill typically technology neutral, allowing InformationAnalysts to discuss and agree on logical structures. Thephysical model applies technology specific data to themodels and allows engineers to discuss and agree ontechnology decisions in preparation for generation to atarget environment, such as a database management system.

Enterprise Architect provides a number of features to assistin this process, including the ability to develop conceptual,logical and physical models and to be able to trace theunderlying concepts between the models. The physicalmodels can be developed for a wide range of databasesystems, and forward and reverse engineering allows thesemodels to be synchronized with live databases.

Data Models

(c) Sparx Systems 2019 Page 9 of 335

Page 10: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Type Description

ConceptualData Models

Conceptual data models, also calledDomain models, establish the basicconcepts and semantics of a givendomain and help to communicate these toa wide audience of stakeholders.Conceptual models also serve as acommon vocabulary during the analysisstages of a project; they can be created inEnterprise Architect usingEntity-Relationship or UML Classmodels.

Logical DataModels

Logical data models add further detail toconceptual model elements and refine thestructure of the domain; they can bedefined using Entity-Relationship orUML Class models.One benefit of a Logical data model isthat it provides a foundation on which tobase the Physical model and subsequentdatabase implementation.Entity-relationship modeling is anabstract and conceptual databasemodeling method, used to produce aschema or semantic data model of, forexample, a relational database and itsrequirements, visualized in

(c) Sparx Systems 2019 Page 10 of 335

Page 11: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Entity-Relationship Diagrams (ERDs).ERDs assist you in building conceptualdata models through to generating DataDefinition Language (DDL) for the targetDBMS.A Logical model can be transformed to aPhysical data model using a DDLTransformation.

Physical DataModels

Physical data models in EnterpriseArchitect help you visualize yourdatabase structure and automaticallyderive the corresponding databaseschema; you use Enterprise Architect'sUML Profile for Data Modelingspecifically for this purpose.The profile provides useful extensions ofthe UML standard that map databaseconcepts of Tables and relationships ontothe UML concepts of Classes andAssociations; you can also modeldatabase columns, keys, constraints,indexes, triggers, referential integrity andother relational database features.Because Enterprise Architect helps youvisualize each type of data model in thesame repository, you can easily managedependencies between each level ofabstraction to maximize traceability and

(c) Sparx Systems 2019 Page 11 of 335

Page 12: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

verify completeness of systemimplementation.

(c) Sparx Systems 2019 Page 12 of 335

Page 13: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Conceptual Data Model

A Conceptual data model is the most abstract form of datamodel. It is helpful for communicating ideas to a wide rangeof stakeholders because of its simplicity. Thereforeplatform-specific information, such as data types, indexesand keys, is omitted from a Conceptual data model. Otherimplementation details, such as procedures and interfacedefinitions, are also excluded.

This is an example of a Conceptual data model, renderedusing two of the notations supported by EnterpriseArchitect.

Using Entity-Relationship (ER) notation, we represent thedata concepts 'Customers' and 'Customers Addresses' asEntities with a 1-to-many relationship between them. Wecan represent exactly the same semantic information usingUML Classes and Associations.

Whether you use UML or ER notation to represent dataconcepts in your project depends on the experience andpreferences of the stakeholders involved. The detailed

(c) Sparx Systems 2019 Page 13 of 335

Page 14: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

structure of the data concepts illustrated in a Conceptualdata model is defined by the Logical data model.

(c) Sparx Systems 2019 Page 14 of 335

Page 15: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Logical Data Model

Logical data models help to define the detailed structure ofthe data elements in a system and the relationships betweendata elements. They refine the data elements introduced by aConceptual data model and form the basis of the Physicaldata model. In Enterprise Architect, a Logical data model istypically represented using the UML Class notation.

Example

This is a simple example of a Logical data model:

Note that the data elements 'Customers' and 'CustomersAddresses' contain UML attributes; the names and genericdata types to remain platform-independent.Platform-specific data types and other metadata that relate toa specific DBMS implementation are defined by thePhysical data model.

(c) Sparx Systems 2019 Page 15 of 335

Page 16: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Entity Relationship Diagrams (ERDs)

According to the online Wikipedia:

An entity-relationship model (ERM) is an abstract andconceptual representation of data. Entity-relationshipmodeling is a database modeling method, used to produce atype of conceptual schema or semantic data model of asystem, often a relational database, and its requirements ina top-down fashion. Diagrams created by this process arecalled Entity-Relationship Diagrams, ER Diagrams, orERDs.

Entity Relationship Diagrams in EnterpriseArchitect

Entity Relationship diagrams in Enterprise Architect arebased on Chen's ERD building blocks: entities (tables) arerepresented as rectangles, attributes (columns) arerepresented as ellipses (joined to their entity) andrelationships between the entities are represented asdiamond-shape connectors.

(c) Sparx Systems 2019 Page 16 of 335

Page 17: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

ERD technology in Enterprise Architect assists you in everystage from building conceptual data models to generatingData Definition Language (DDL) for the target DBMS.

MDG Technology for ERD and ERDTransformations

Enterprise Architect enables you to develop EntityRelationship diagrams quickly and simply, through use ofan MDG Technology integrated with the EnterpriseArchitect installer.

The Entity Relationship diagram facilities are provided inthe form of:

An Entity Relationship diagram type, accessed through·

the 'New Diagram' dialog

An Entity Relationship Diagram page in the Diagram·

Toolbox

Entity Relationship element and relationship entries in the·

'Toolbox Shortcut' menu and Quick Linker

Enterprise Architect also provides transformation templatesto transform Entity Relationship diagrams into DataModeling diagrams, and vice versa.

Entity Relationship Diagram Toolbox Page

(c) Sparx Systems 2019 Page 17 of 335

Page 18: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

You can access the 'Entity Relationship Diagram' page ofthe Diagram Toolbox by specifying 'Entity RelationshipDiagrams' in the Toolbox 'Find Toolbox Item' dialog

Entity is an object or concept that is uniquely identifiable;·

the property of 'Multiplicity' in the SourceRole andTargetRole definitions for the Relationship connector canbe used to define the cardinality of an Entity thatparticipates in this relationship

Attribute is a property of an entity or a relationship type·

N-ary Association represents unary (many-to-many·

recursive) or ternary relationships and can also be used torepresent relationships that have attributes among theentities; the N-ary Association element should always beat the target end of a connector

Connector is a connector between an Entity and an·

Attribute, and between two Attributes

Relationship is a diamond-shape connector, representing·

the meaningful association among entities

Disjoint and Overlapping represent the relationships·

between the super-class Entity and the sub-class Entity

(c) Sparx Systems 2019 Page 18 of 335

Page 19: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

A typical Entity Relationship diagram

Tagged Values

Some of the Entity Relationship diagram components can bemodified by Tagged Values, as indicated:

(c) Sparx Systems 2019 Page 19 of 335

Page 20: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Component Tagged Value / Notes

Entity isWeakEntityNotes: If true, this entity is a weak entity.

Attribute attributeTypeNotes: There are four valid options:'normal', 'primary key', 'multi-valued' and'derived'

Attribute commonDataTypeNotes: Defines the common data type foreach attribute.

Attribute dbmsDataTypeNotes: Defines the customized DBMSdata type for each attribute. This option isonly available when thecommonDataType tag is set to 'na'.You must define the customized type firstthrough the 'Configure > Reference Data> Settings > Database Datatypes' ribbonoption.

N-aryAssociation

isRecursiveNotes: If true, the N-ary Associationrepresents the many-to-many recursiverelationship.

(c) Sparx Systems 2019 Page 20 of 335

Page 21: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

For one-to-many and one-to-onerecursive relationships, we suggest usingthe normal Relationship connector.Sometimes you might want to limit thestretch of the diamond-shapeRelationship connectors; simply pick aRelationship connector, right-click todisplay the context menu, and select the'Bend Line at Cursor' option.

Relationship isWeakNotes: If true, the Relationship is a weakrelationship.

DisjoinOverlapping

ParticipationNotes: There are two valid options,'partial' and 'total'.

Notes

Entity Relationship diagrams are supported in the·

Corporate, Unified and Ultimate editions of EnterpriseArchitect

(c) Sparx Systems 2019 Page 21 of 335

Page 22: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Physical Data Models

A Physical Data Model visually represents the structure ofdata as implemented by a relational database schema. Inaddition to providing a visual abstraction of the databasestructure, an important benefit of defining a Physical DataModel is that you can automatically derive the databaseschema from the model. This is possible due to the richnessof metadata captured by a Physical Data Model and its closemapping to aspects of the database schema, such as databaseTables, columns, Primary keys and Foreign keys.

Example Data Model

This example shows a Physical Data Model that could beused to automatically generate a database schema. EachTable is represented by a UML Class; Table columns,Primary Keys and Foreign Keys are modeled using UMLattributes and operations.

(c) Sparx Systems 2019 Page 22 of 335

Page 23: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Notation

The example model is defined using Enterprise Architect'sUML Profile for Data Modeling; the relationship betweenthe Tables uses the Information Engineering notation.

Information Engineering is one of three notations thatEnterprise Architect supports to help Data Modelers identifycardinality in relationships.

Default DBMS

Prior to creating a Physical Data Model it is advisable foryou to set the default DBMS for the project. Setting adefault DBMS ensures that all new database elements thatare created on diagrams are automatically assigned thedefault DBMS.

If the default DBMS is not set, new Tables are createdwithout a DBMS assigned, this restricts EnterpriseArchitect's ability to model the physical objects correctly.For example Enterprise Architect is unable to determine thecorrect list of datatypes for columns.

You can set the default DBMS type using:

'Start > Desktop > Preferences > Preferences > Code·

Editors', or

The Code Generation Toolbar·

(c) Sparx Systems 2019 Page 23 of 335

Page 24: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Note: When modeling via the Database Builder the defaultDBMS is defined at the model level (as a Tagged Value'DBMS' against the <<Database>> Package) instead of atthe project level, thereby allowing for greater flexibilitywhen projects involve multiple DBMSs.

(c) Sparx Systems 2019 Page 24 of 335

Page 25: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Modeling

Enterprise Architect is a fully featured database modelingplatform that enables the user to work with their PhysicalData models at all stages, from design right through to theimplementation of the live database, for a wide range ofdatabase management systems such as Microsoft SQLServer, Oracle, PostgreSQL and MySQL.

This section explains in detail how to use EnterpriseArchitect to work with your Physical Database schema.

(c) Sparx Systems 2019 Page 25 of 335

Page 26: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Create a Data Model from a ModelPattern

The easiest way to create a Data Modeling workspace is touse the predefined Database Model Patterns, availablethrough the Model Wizard. Enterprise Architect provides aPattern for each DBMS supported by the system.

Access

Display the Model Wizard window using any of themethods outlined here.

In the Model Wizard window, select the 'Model Patterns'tab. In the 'Technology' panel, select 'Database'.

Ribbon Design > Model > Add > Model Wizard

ContextMenu

Right-click on Package | Add a ModelUsing Wizard

KeyboardShortcuts

Ctrl+Shift+M

Other Browser window caption bar menu | NewModel from Pattern

(c) Sparx Systems 2019 Page 26 of 335

Page 27: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Create a Data Model

Field/Button Action

Add toPackage

Displays the name of the selected rootPackage.

Technology Click on 'Database'.

Name If necessary, expand the DatabaseEngineering group of Patterns.Click on the checkbox against eachDatabase Management System you aresupporting in the model.

All Click on this button to select thecheckboxes for all Database Engineeringmodel types and the Entity Relationshipdiagram, to include them all in the model.

None Click on this button to clear all selectedcheckboxes so that you can re-selectcertain checkboxes individually.

OK Click on this button to add to the Browserwindow the Packages and diagram for

(c) Sparx Systems 2019 Page 27 of 335

Page 28: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

each Database Management System youare modeling.

What each Data Modeling Pattern provides

A summary diagram of the model·

A Report Specification Artifact element (on the summary·

diagram) that can be used to quickly document the datamodel

A Package for each of the Logical and Physical models·

Within the Physical Model Package, a predefined·

hierarchy of sub-Packages, one for each object typesupported by the DBMS being modeled (such as Tables,Views, Procedures and Functions); these automaticallyorganize the database objects as they are added

The DBMS type for the workspace·

A default owner·

A Data Modeling diagram in each Package with the·

connector notation set to IDEF1X

Notes

Once a data modeling workspace has been created, you·

can begin to develop your model in one of two ways:

(c) Sparx Systems 2019 Page 28 of 335

Page 29: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

- Through the Database Builder, which is apurpose-built view that supports database modelers - Through the Browser window and diagrams, whichis the traditional method that might suit users who are experienced UML modelers

(c) Sparx Systems 2019 Page 29 of 335

Page 30: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Create a Data Model Diagram

To model the structure of a relational database you use DataModeling diagrams, which are extended Class diagrams.When you open a Data Modeling diagram the matchingDiagram Toolbox is automatically opened, which containsthe diagram elements:

Table·

View·

Procedure·

Sequence·

Function·

Association and·

Database Connection·

Access

Display the 'New Diagram' dialog using any of the methodsoutlined here.

Ribbon Design > Diagram > Add

ContextMenu

Right-click on Package | Add DiagramRight-click on element | Add | AddDiagram

(c) Sparx Systems 2019 Page 30 of 335

Page 31: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

KeyboardShortcuts

Ctrl+Insert

Other Browser window caption bar menu | NewDiagram

Create a Data Modeling diagram

Field/Button Action

Package Defaults to the name of the Packageselected in the Browser window or, if theparent is an element, the name of thePackage containing that element.If you are adding a diagram directly to aPackage and notice that it is not thecorrect Package, click on the buttonand browse for the correct Package.

Parent If you are adding a diagram to anelement, this field displays the elementname.

Diagram This field defaults to the name of theparent Package or element.If required, overtype the default name

(c) Sparx Systems 2019 Page 31 of 335

Page 32: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

with your preferred name.

Select From Click on this header and select thePerspective Group and Perspective orWorkspace most appropriate to the areayou are working in (in this instance,'Information Engineering > DatabaseModels').From the options listed in the panel, clickon 'Extended'.

DiagramTypes

Click on 'Data Modeling'.

OK Click on this button to create the diagram.The Diagram View displays the blankdiagram, and the 'Data Modeling' pagesdisplay in the Diagram Toolbox.Drag elements and connectors from theToolbox onto your diagram, to createyour data model.

Notes

The default diagram connector notation for all new·

diagrams is Information Engineering, although many data

(c) Sparx Systems 2019 Page 32 of 335

Page 33: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

modelers prefer the notation IDEF1X; to make thischange select 'Design > Diagram > Manage > Properties >Connectors' and click on the required option in the'Connector Notation' drop-down list

(c) Sparx Systems 2019 Page 33 of 335

Page 34: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Example Data Model Diagram

This example of a Data Model diagram shows a data modelof a bookstore warehousing system. You can examine thismodel in greater detail in EAExampleModel.eap, installedwith Enterprise Architect.

(c) Sparx Systems 2019 Page 34 of 335

Page 35: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

(c) Sparx Systems 2019 Page 35 of 335

Page 36: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

The Database Builder

The Database Builder is a tailored interface for the datamodeler; all database-related modeling tasks can beperformed in a single location. The interface and its relatedscreens include only the information relevant to datamodeling, thereby streamlining and simplifying themodeling process.

Access

Ribbon Develop > Data Modeling > DatabaseBuilder

Database Builder

(c) Sparx Systems 2019 Page 36 of 335

Page 37: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

This figure shows the Database Builder loaded with the'Orders (postgres)' data model as it appears in the Examplemodel.

Overview

The interface of the Database Builder consists of:

A Tree of data models, listing all defined data models in·

the current repository

A 'Columns' tab through which you directly manage the·

Table columns

A 'Constraints/Indexes' tab for the direct management of·

Table constraints such as Primary Keys, Foreign Keys andIndexes

An SQL Scratch Pad that you can use to run ad-hoc SQL·

queries against a live database

A 'Database Compare' tab that displays the results of·

(c) Sparx Systems 2019 Page 37 of 335

Page 38: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

comparisons between the data model and a live database

An 'Execute DDL' tab on which you can execute·

generated DDL against a live database, instantly

You can use the Database Builder to:

Create, edit and delete database objects (Tables, Views,·

Procedures, Sequences and Functions)

Create, edit and delete Table constraints (Primary Keys,·

Indexes, Unique Constraints, Check Constraints andTriggers)

Create, edit and delete Table Foreign Keys·

Reverse engineer database schema information·

Generate DDL from a modeled database·

Compare a live database schema with a modeled database·

Execute generated DDL against a live database·

Execute adhoc SQL statements against a live database·

Notes

The Database Builder is available in the Corporate,·

Unified and Ultimate editions of Enterprise Architect

(c) Sparx Systems 2019 Page 38 of 335

Page 39: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Opening the Database Builder

When you first open the Database Builder, it searches theentire project for all Packages that have the stereotype<<Data Model>> and loads the corresponding data modelsas root nodes into the tree. A grayed-out icon indicates thatthe details of the data model are not loaded.

This figure shows the Database Builder with a singleunloaded data model called 'Orders (postgres)'.

Using the Database Builder

You can start working in the Database Builder in one ofthese two ways:

Task Action

Create a newdata model

Once you have opened the DatabaseBuilder view, right-click in the emptyspace of the tree and select 'New DataModel' to invoke the Model Wizard.

Load an Once the Database Builder view is

(c) Sparx Systems 2019 Page 39 of 335

Page 40: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

existing DataModel

opened, load any of the defined datamodels by either:

Right-clicking on the name and·

selecting 'Load', orDouble-clicking on the name·

Data Model Properties

In earlier versions of Enterprise Architect (prior to theintroduction of the Database Builder) it was necessary forthe data modeler to manually set properties on databaseobjects before some tasks were allowed. For example,Enterprise Architect would not allow the definition of aTable column without the Table first being assigned aDBMS. This was because the DBMS controls the list ofavailable datatypes.

To improve efficiency and the user experience, the DatabaseBuilder defines defaults for a number of properties at thedata model level and then applies these default valuesautomatically whenever new objects are created.

Properties

Option Description

(c) Sparx Systems 2019 Page 40 of 335

Page 41: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DBMS Defined against: The data model's<<Database>> PackageDefined as: Tagged ValueDetails: Defines the DBMS of thecurrent data modelExtra Information:

Controls which logical folders are·shown for the current data model in theDatabase Builder's treeControls what DBMS rules are applied·during database comparisonsIs automatically assigned to every new·database object created in the currentdata model

DefaultOwner

Defined against: The data model's<<Database>> PackageDefined as: Tagged ValueDetails: Defines the default Owner forthe current data modelExtra Information:

Is automatically assigned to every new·

database object created in the currentdata model, if the DBMS supportsowners/schemas

DefaultConn Defined against: The data model's

(c) Sparx Systems 2019 Page 41 of 335

Page 42: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

ection <<Database>> PackageDefined as: Tagged ValueDetails: (Optional) the name of thedefault connectionExtra Information:

Whenever a data model is loaded, the·

'DefaultConnection' property ischecked; if present, the Connection bythat name is automatically made activeThe database engineering model·

Patterns do not define a value for thisproperty, it is created or updatedwhenever a user sets a Connection asthe default

Notes

If a data model is selected in the Browser window when·

the Database Builder is opened, that model's details willbe automatically loaded

(c) Sparx Systems 2019 Page 42 of 335

Page 43: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Working in the Database Builder

When a data model is loaded, the Database Builder creates aset of logical folders, one for each object type supported bythe current DBMS. Each logical folder is populated with allobjects of that type found in the data model's hierarchy ofPackages (as shown in the Browser window).

In this image the data model 'Orders (postgres)' showslogical folders for Tables, Views, Functions, Sequences,Queries and Connections. It is worth noting there is nofolder for 'Procedures' since PostgreSQL does not supportdatabase procedures.

(c) Sparx Systems 2019 Page 43 of 335

Page 44: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Available Actions in the Database BuilderTree

The majority of the Database Builder functions areaccessible via context menus. Each object in the Tree has itsown set of unique menu items based on its type and status.This table describes the available context menu items andidentifies which objects they apply to.

Menu Option Applies to / Description

New datamodel

Applies To: Blank SpaceDescription: Opens the Model Wizardscreen.

Refresh All Applies to: Blank SpaceDescription: Reloads the complete list ofdata models.

Load Applies to: Root NodeDescription: Loads the full details of thedata model.

Unload Applies to: Root NodeDescription: Unloads the full details ofthe data model.

Import DB Applies to: Loaded Root Node

(c) Sparx Systems 2019 Page 44 of 335

Page 45: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Schema fromODBC

Description: Opens the 'Import DBschema from ODBC' dialog using thecurrent active connection as the ODBCsource.

GenerateDDL

Applies to: Loaded Root Node, Folder,Table, View, Procedure, Function,Sequence, PackageDescription: Opens the 'Generate DDL'dialog with the current object(s) selected.

ShowDifferences

Applies to: Loaded Root Node, Folder,Table, View, Procedure, Function,SequenceDescription: Compares the selectedobjects to the current active connection.

ShowDifferenceswith Options

Applies to: Loaded Root Node, Folder,Table, View, Procedure, Function,Sequence, PackageDescription: Compares the selectedobjects to the current active connectionand optionally ignore some of thedifferences based on the specifiedcompare options.

ManageDBMSOptions

Applies to: Loaded Root NodeDescription: Opens the 'Manage DBMSOptions' dialog, which can be used to

(c) Sparx Systems 2019 Page 45 of 335

Page 46: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

change the allocated DBMS and Ownerof multiple objects.

View RecordCount

Applies to: Table, ViewDescription: Builds and runs a SELECTquery (formatted to suit the element'sDBMS) to show the number of records inthe selected Table or View.If there is no active connection, you areprompted to select one.

View Top100 Rows

Applies to: Table, ViewDescription: Builds and runs a SELECTquery (formatted to suit the element'sDBMS) to show the top 100 rows of theselected Table or View.If there is no active connection, you areprompted to select one.

View Top1000 Rows

Applies to: Table, ViewDescription: Builds and runs a SELECTquery (formatted to suit the element'sDBMS) to show the top 1000 rows of theselected Table or View.If there is no active connection, you areprompted to select one.

View All Applies to: Table, View

(c) Sparx Systems 2019 Page 46 of 335

Page 47: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Rows Description: Builds and runs a SELECTquery (formatted to suit the element'sDBMS) to show all rows of the selectedTable or View.If there is no active connection, you areprompted to select one.

Properties Applies to: Loaded Root Node, Folder,Table, View, Procedure, Function,Sequence, Package, ConnectionDescription: Opens the standard'Properties' dialog for the selected object.

Find inProjectBrowser

Applies to: Loaded Root Node, Folder,Table, View, Procedure, Function,Sequence, Package, SQL Query,ConnectionDescription: Finds the selected object inthe Browser window.

Refresh Applies to: Loaded Root NodeDescription: Reloads the details of thecurrent loaded data model. This isnecessary when objects are added,changed or deleted by other users orwhen the changes are performed outsideof the Database Builder.

Add new Applies to: Folder, Table, View,

(c) Sparx Systems 2019 Page 47 of 335

Page 48: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

<type> Procedure, Function, Sequence, Package,SQL Query, ConnectionDescription: Creates a new object of thespecified type.

Clone<name>

Applies to: Folder, Table, View,Procedure, Function, Sequence, Package,SQL Query, ConnectionDescription: Makes a new copy of theselected object. When you select thisoption, a prompt displays on which youset the name and owner of the newobject. For Table objects, you can choosewhich existing constraints should becopied (and set a name for each one)along with which Foreign Keys should becopied. For SQL-based objects, you canmake any necessary changes to the SQLfor the new element.

Delete<name>

Applies To: Table, View, Procedure,Function, Sequence, Package, SQLQuery, ConnectionDescription: Permanently deletes theselected object from the repository.

Add newForeign Keyon <name>

Applies to: TableDescription: Creates a new relationshipbetween the selected Table and another

(c) Sparx Systems 2019 Page 48 of 335

Page 49: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

one, then shows the 'Foreign keyConstraint' screen for the newrelationship.

SQL ObjectProperties

Applies to: View, Procedure, Function,SequenceDescription: Opens the 'SQL ObjectEditor' screen.

Edit Applies to: SQL QueryDescription: Loads the SQL (as definedin the selected element) into the SQLScratch Pad.

Run Applies to: SQL QueryDescription: Loads the SQL in the SQLScratch Pad and runs it.If there is no active connection, you areprompted to select one.

Set as activeDBConnection

Applies to: ConnectionDescription: Flags the selected DatabaseConnection as the active one for thecurrent session.

Set asDefault DBConnection

Applies to: ConnectionDescription: Flags the selected DatabaseConnection as the active one each time

(c) Sparx Systems 2019 Page 49 of 335

Page 50: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

the data model is loaded.

DBConnectionProperties

Applies to: ConnectionDescription: Opens the 'DatabaseConnection Properties' screen, to managethe connection settings.

Create/Edit/Delete Database Objects

The pages listed in this section describe in detail how to usethe Database Builder's interface to create and manipulatedatabase Tables; however, the process of creating andmanipulating SQL-based database objects is documented inother areas. See these topics for details:

Database Views·

Database Procedures·

Database Functions·

Database Sequences·

Database Connections·

Database Connections in the DatabaseBuilder

(c) Sparx Systems 2019 Page 50 of 335

Page 51: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

When performing certain tasks such as 'Compare' or'Execute DDL', the Database Builder requires an activedatabase connection. Only one database connection can bemade active (indicated by a colored 'Database Connection'icon, while the others are gray) at a given time. If a databaseconnection is not currently active and you try to perform atask that requires one, the Database Builder performs one ofthese actions based on how many connections are defined:

0 Connections – prompts you to create a connection and,·

if successful, continues

1 Connection – sets it as active and continues·

2 (or more) Connections – prompts you to select one and,·

if successful, continues

(c) Sparx Systems 2019 Page 51 of 335

Page 52: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Columns

Tables are the fundamental database object, and Columns(and their properties) are the most frequently modified Tablefeature updated and changed by data modelers, therefore the'Columns' page is conveniently located as the first page ofthe Database Builder's interface.

Once a Table is selected in the Database Builder's tree, the'Columns' page is populated with the currently defined listof columns for that Table. The data modeler can then makechanges to main column properties directly in the list orgrid. As the data modeler selects individual columns in thelist, the column's extended properties (and Comments) areshown immediately under the list, allowing modification tothese extended properties.

Notes

(c) Sparx Systems 2019 Page 52 of 335

Page 53: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

The 'Columns' page will only be populated when a Table·

item is selected in the Database Builder's tree

(c) Sparx Systems 2019 Page 53 of 335

Page 54: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Create Database Table Columns

A database Table column is represented in the UML DataModeling Profile as an attribute with the <<column>>stereotype. For a selected Table, you can review the existingcolumns and create new columns, on the 'Columns' page ofthe Database Builder or on the 'Columns and Constraints'screen.

You can define column details directly on the list ofcolumns on the 'Columns' tab. The changes areautomatically saved as you complete each field. Some fieldshave certain restrictions on the data you can enter, asdescribed here. The tab also contains a 'Properties' panel anda 'Notes' field, which are populated with the existinginformation on the selected column. Each new column thatyou create is automatically assigned a set of default valuesand added to the bottom of the list.

Access

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table > Columns >Right-Click > Add new Column

ContextMenu

In diagram, right-click on required Table |Features | Columns | Right-Click | Add

(c) Sparx Systems 2019 Page 54 of 335

Page 55: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

new Column

KeyboardShortcuts

Select a table | F9 | Tab Key (to set inputfocus on the 'Columns' tab) | Ctrl+N

Create columns in a Table

Option Action

Name Overtype the default name with theappropriate column name text.

Type Click on the drop-down arrow and selectthe appropriate datatype for the column.The available datatypes depend on theDBMS assigned to the parent Table.

Length (Optional) Some datatypes have a lengthcomponent - for example, VARCHARhas a length that defines the number ofcharacters that can be stored. If thedatatype does not have a lengthcomponent, this field is disabled.If the field is available and if you need todefine a number of characters, type the

(c) Sparx Systems 2019 Page 55 of 335

Page 56: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

value here.

Scale (Optional) Some datatypes have a scalecomponent - for example, DECIMAL hasa scale that defines the number ofdecimal places that can be held. If thedatatype does not have a scalecomponent, this field is disabled.If the field is available and if you need todefine a scale, type the value here.

PK Select the checkbox if the column is partof the Primary Key for this Table.

Not Null Select the checkbox if empty values areforbidden for this column.The checkbox is disabled if the 'PK'checkbox is selected.

Alias If required for display and documentationpurposes, type in an alternative name forthe field.

Initial Value If required, type in a value that can beused as a default value for this column.

Notes Type in any additional informationnecessary to document the column.You can format the text using the Notes

(c) Sparx Systems 2019 Page 56 of 335

Page 57: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

toolbar at the top of the field.

Column Properties

The appropriate properties for the Table's DatabaseManagement System automatically display in the 'Property'panel (expand the 'Column (<name>)' branch if they are notvisible).

Property DBMS

Autonum(StartnumIncrement)

OracleMySQLSQL ServerDB2PostgreSQLSybase ASASybase ASENotes: If you require an automaticnumbering sequence, set this property toTrue and, if necessary, define the startnumber and increment.

Generated DB2Notes: Set this additional property forauto numbering in DB2, to 'By Default' or

(c) Sparx Systems 2019 Page 57 of 335

Page 58: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

'Always'.

NotForRep SQLServerNotes: Set this property to True if youwant to block replication.

Zerofill MySQLNotes: Set this property to True or Falseto indicate if fields are zerofilled or not.

Unsigned MySQLNotes: Set this property to True or Falseto indicate whether or not fields acceptunsigned numbers.

LengthType OracleNotes: Set this property to define thecharacter semantics as 'None', 'Byte' or'Char'.

(c) Sparx Systems 2019 Page 58 of 335

Page 59: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Delete Database Table Columns

For a selected database Table, you can review the existingcolumns and delete any individual column, on the 'Columns'tab of the Columns and Constraints screen.

Access

Use one of the methods outlined here to display a list ofcolumns for a table, then select a column and delete it.

When you select the 'Delete column '<name>'' option, if allvalidation rules are satisfied the column is immediatelydeleted.

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table > Columns >Right-click on column name > Deletecolumn <name>

ContextMenu

In diagram, right-click on required Table |Features | Columns | Right-click oncolumn name | Delete column <name>

KeyboardShortcuts

F9 | Use 'Up Arrow' or 'Down Arrow' toselect a column | Ctrl+D

(c) Sparx Systems 2019 Page 59 of 335

Page 60: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Notes

If the deleted database Table column is involved in any·

constraints it will automatically be removed from them

(c) Sparx Systems 2019 Page 60 of 335

Page 61: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Reorder Database Table Columns

If you have several columns defined in a database Table,you can change the order in which they are listed. The orderin the list is the order in which the columns appear in thegenerated DDL.

Access

Use one of the methods outlined here to display a list ofcolumns for a Table, then select a column and reposition itwithin the list.

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table

ContextMenu

In diagram, right-click on required Table |Features | Columns

KeyboardShortcuts

F9

Change the column order

(c) Sparx Systems 2019 Page 61 of 335

Page 62: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Step

Action

1 In the 'Columns' tab, click on the required columnname in the list.

2 Right-click and select the:'Move column <name> up' option (or press·

Ctrl+Up Arrow) to move the column up oneposition'Move column <name> down' option (or press·

Ctrl+Down Arrow) to move the column down oneposition

These options have an immediate effect both in the'Columns' tab and on a diagram.

(c) Sparx Systems 2019 Page 62 of 335

Page 63: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Constraints/Indexes

Tables are the fundamental database object, and Constraintsand Indexes (and their properties) are the second mostfrequently modified Table feature updated and changed bydata modelers, therefore the 'Constraints/indexes' page isconveniently located as the second page of the DatabaseBuilder's interface.

Once a Table is selected in the Database Builder's tree, the'Constraints/Indexes' page is populated with the currentlydefined list of constraints and indexes for the selected Table.The data modeler can then make changes to main propertiesdirectly in the list. As the data modeler selects individualconstraints or indexes in the list, the constraint's extendedproperties (and Comments) are shown immediately underthe list, allowing modification of these extended properties.

(c) Sparx Systems 2019 Page 63 of 335

Page 64: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Notes

The 'Constraints/Indexes' page will only be populated·

when a Table item in the Database Builder's tree isselected

(c) Sparx Systems 2019 Page 64 of 335

Page 65: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Table Constraints/Indexes

Within Enterprise Architect, Table Constraints and Indexesare modeled on the same screen; collectivity they arereferred to as Constraints. Database Constraints define theconditions imposed on the behavior of a database Table.They include:

Primary Key - uniquely identifies a record in a Table,·

consisting of one or more columns

Index - improves the performance of retrieval and sort·

operations on Table data

Unique Constraints - a combination of values that·

uniquely identify a row in the Table

Foreign Key - a column (or collection of columns) that·

enforce a relationship between two Tables

Check Constraints - enforces domain integrity by limiting·

the values that are accepted by a column

Table Trigger - SQL or code automatically executed as a·

result of data in a Table being modified

In Enterprise Architect, you can define and maintain TableConstraints using either the purpose-designed'Constraints/Indexes' page of the Database Builder or theColumns and Constraints screen.

Access

(c) Sparx Systems 2019 Page 65 of 335

Page 66: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table name >Constraints/Indexes | Right-click | AddNew Constraint

ContextMenu

In diagram | Right-click on Table |Features | Constraints/Indexes |Right-click | Add New Constraint

KeyboardShortcuts

Click on Table: F9 > Constraints/Indexes:Ctrl+N

Create a Constraint

The process of creating any of these constraint types is thesame and is achieved in one of the ways described here.

Create a Constraint - Using the context menuor keyboard

Step

Action

(c) Sparx Systems 2019 Page 66 of 335

Page 67: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

1 A new constraint is automatically created andassigned the default name constraint n (where n is acounter) and a 'Type' of 'index'.Overtype the default name with your own constraintname.

2 If necessary, in the 'Type' field click on thedrop-down arrow and select the appropriateconstraint type.

3 If you prefer, type an alias for the constraint, in the'Alias' field.The 'Columns' field is read-only; it is populated withthe columns that you assign to the 'InvolvedColumns' tab.

Create a Constraint - Overtype the templatetext

Step

Action

1 On the 'Constraints/Indexes' tab for the selectedTable, the list of constraints ends with the templatetext New Constraint.

(c) Sparx Systems 2019 Page 67 of 335

Page 68: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Overtype this text with the appropriate constraintname, and press the Enter key.

2 The new constraint is automatically created andassigned the default Type of index.If necessary, in the 'Type' field click on thedrop-down arrow and select the appropriateconstraint type.

3 If you prefer, type an alias for the constraint, in the'Alias' field.The 'Columns' field is read-only; it is populated withthe columns that you assign to the 'InvolvedColumns' tab.

Assign Columns to a Constraint

The constraint types of Primary Key, Foreign Key, Indexand Unique all must have at least one column assigned tothem; this defines the columns that are involved in theconstraint.

Step

Action

1 On the 'Constraints/Indexes' tab for the selectedTable, click on the constraint to which you are

(c) Sparx Systems 2019 Page 68 of 335

Page 69: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

assigning columns.

2 The 'Available Columns' panel lists all columnsdefined for the Table.For each column to assign to the constraint,right-click on the column name and select 'Assigncolumn <name>'.The column name is transferred to the 'AssignedColumns' list.

Unassign Columns from a Constraint

Step

Action

1 On the 'Constraints/Indexes' tab for the selectedTable, click on the constraint from which you areunassigning columns.

2 In the 'Assigned Columns' list, right-click on thename of the column to unassign from the constraintand select 'Unassign column <name>'.The column name is transferred to the 'AvailableColumns' list.

(c) Sparx Systems 2019 Page 69 of 335

Page 70: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Reorder the Assigned Columns in aConstraint

If you have a number of columns in the constraint, you canrearrange the sequence by moving a selected column nameone place up or down the list at a time. To do this:

Right-click on the column name to move and select either:·

- Move column '<name>' up (Ctrl+Up Arrow) or - Move column '<name>' down (Ctrl+Down Arrow)

Delete a constraint

To delete a constraint you no longer require, right-click onthe constraint name in the list on the 'Constraints/Indexes'tab and select the 'Delete constraint <name>' option. If allvalidation rules for the given constraint type are met, theconstraint is immediately removed from the repository alongwith all related relationships (if there are any).

(c) Sparx Systems 2019 Page 70 of 335

Page 71: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Primary Keys

A Primary Key is a column (or set of columns) that uniquelyidentifies each record in a Table. A Table can have only onePrimary Key. Some DBMSs support additional properties ofPrimary Keys, such as Clustered or Fill Factor.

Access

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table name

ContextMenu

In diagram | Right-click on Table |Features | Constraints/Indexes

Create a Primary Key

In Enterprise Architect you can create a Primary Key fromeither the 'Columns' tab or the 'Constraints/Indexes' tab. Ineither case, when you add a column to a Primary Keyconstraint, the column is automatically set to be 'Not Null'.Additionally any diagram (assuming the 'Show Qualifiersand Visibility Indicators' option is set) containing the Tableelement will show the 'PK' prefix against the column name.

(c) Sparx Systems 2019 Page 71 of 335

Page 72: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

In this image, see the first column 'id: bigserial'.

Create a Primary Key - from the Columns tab

Step

Action

1 Either:In the Database Builder, click on a Table with one·

or more defined columns, and click on the'Columns' tab, orOn a diagram, click on a Table and press F9 to·

display the 'Columns' tab

(c) Sparx Systems 2019 Page 72 of 335

Page 73: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

2 For each column to include in the Primary Key,select the 'PK' checkbox.If a Primary Key constraint is not previously definedfor the current Table, the system will create a newconstraint using the Primary Key Name template.

Create a Primary Key - from the Constraintstab

Step

Action

1 Either:In the Database Builder, click on a Table with one·or more defined columns, and click on the'Constraints/Indexes' tab, orOn a diagram, click on a Table and press F10 to·display the 'Constraints/Indexes' tab

2 Overtype the New Constraint text with the PrimaryKey name, press the Enter key and click on the'Type' field drop-down arrow, and select 'PK'.

3 Assign the required columns to the PK constraint.

(c) Sparx Systems 2019 Page 73 of 335

Page 74: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

4 Set the Primary key's extended properties using theproperty panel.

Fill Factor is a numeric value between 0 and 100·

Is Clustered is a boolean value that determines the·

physical order of how the data is stored; for mostDBMSs the Is Clustered property defaults to Truefor Primary Keys

Remove columns from a Primary Key

You can remove columns from a Primary Key using eitherthe 'Columns' tab or the 'Constraints/Indexes' tab.

Remove columns from a Primary Key - usingthe Columns tab

Step

Action

1 Either:In the Database Builder, click on the Table with·

the Primary Key, and click on the 'Columns' tab,or

(c) Sparx Systems 2019 Page 74 of 335

Page 75: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

On a diagram, click on a Table and press F9 to·

display the 'Columns' tab

2 Against each column you want to remove from thePrimary Key, deselect the 'PK' checkbox.If you have removed all columns from the PrimaryKey constraint and the Primary Key is no longerneeded, it must be manually deleted.

Remove columns from a Primary Key - usingthe Constraints/Indexes tab

Step

Action

1 Either:In the Database Builder, click on the Table with·

the Primary Key, and click on the'Constraints/Indexes' tab, orOn a diagram, click on a Table and press F10 to·

display the 'Constraints/Indexes' tab

2 Unassign the columns on the PK constraint, asnecessary.

(c) Sparx Systems 2019 Page 75 of 335

Page 76: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Notes

Warning: Enterprise Architect assumes that Primary Key·

constraints have at least one column assigned to them;however, Enterprise Architect does not enforce this ruleduring modelingIf DDL is generated for a Table whose Primary Key hasno column assigned, that DDL will be invalid

(c) Sparx Systems 2019 Page 76 of 335

Page 77: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Indexes

Database indexes are applied to Tables to improve theperformance of data retrieval and sort operations. Multipleindexes can be defined against a Table; however, each indeximposes overheads (in the form of processing time andstorage) on the database server to maintain them asinformation is added to and deleted from the Table

In Enterprise Architect an index is modeled as a stereotypedoperation.

Some DBMSs support special types of index; EnterpriseArchitect defines these using additional properties such asfunction-based, clustered and fill-factor.

Access

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table name >Constraints/Indexes

ContextMenu

In diagram | Right-click on Table |Features | Constraints/Indexes

KeyboardShortcuts

Click on Table: F9 > Constraints/Indexes

(c) Sparx Systems 2019 Page 77 of 335

Page 78: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Work on an index

Step

Action

1 On the 'Constraints/Indexes' tab for the Table,right-click and select 'Add new constraint'.The new constraint is added with the default name'constraint1' and the Type of 'index'.Overtype the name with your preferred index name.

2 Assign the appropriate columns to the Index.The 'Assigned Columns' list has an additional 'Order'field that specifies the order (Ascending or

(c) Sparx Systems 2019 Page 78 of 335

Page 79: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Descending) in which each assigned column isstored in the index. You can toggle the order foreach column, as required.Additionally, for MySQL indexes, a 'Len' field willbe visible in which you can define Partial Indexes;that is, an index that uses the leading 'n' number ofcharacters of a text based field. The 'Len' field takesonly whole number numeric values of between 0 andthe column's defined length. A value of 0 (which isthe default) indicates that the entire column is to beindexed.

3 In the 'Property' panel, review the settings of theextended properties that are defined for the currentDBMS.

Additional Properties

Property Description

Is Unique (True / False) indicates whether thecurrent index is a 'Unique Index'. AUnique Index ensures that the indexedcolumn (or columns) does not containduplicate values, thereby ensuring thateach row has a unique value (or

(c) Sparx Systems 2019 Page 79 of 335

Page 80: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

combination of values when the indexconsists of multiple columns).

Is Clustered (True / False) indicates whether thecurrent index is a 'Clustered Index'. Witha clustered index, the rows of the tableare physically stored in the same order asin the index, therefore there can be onlyone clustered index per table. By defaulta table's Primary Key is clustered.Not all DBMS's support clusteredindexes, therefore the 'Is Clustered' Indexproperty will only be visible for DBMSsthat support it.

Is Bitmap (True / False) indicates whether thecurrent index is a 'Bitmap' index. Bitmapindexes are meant to be used on columnsthat have relatively few unique values(referred to as 'low cardinality' columns)and that physically consist of a bit array(commonly called bitmaps) for eachunique value. Each of the arrays will havea bit for each row in the table.Consider this example: a bitmap index iscreated on a column called 'Gender',which has the options 'Male' or 'Female'.Physically, the index will consist of twobit arrays, one for 'Male' and one for

(c) Sparx Systems 2019 Page 80 of 335

Page 81: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

'Female'. The female bit array will have a1 in each bit where the matching row hasthe value 'Female'.The 'Is Bitmap' and 'Is Unique' propertiesare mutually exclusive, and so the DDLgeneration will ignore the 'Is Unique'property when the 'Is Bitmap' property isTrue.Bitmap Indexes are only supported byOracle; therefore, this property is onlyvisible while modeling Oracle indexes.

Fill Factor A numeric value between 0 and 100, thatdefines the percentage of available spacethat should be used for data.Not all DBMSs support fill factor,therefore the 'Fill Factor' index propertywill only be visible for DBMSs thatsupport it.

Functional-based

A SQL statement that defines thefunction/statement that will be evaluatedand the results indexed; for example: LOWER("field")Not all DBMSs support functional-basedindexes, therefore the 'Functional-based'Index property will only be visible forDBMSs that support them, such asPostgreSQL and Oracle.

(c) Sparx Systems 2019 Page 81 of 335

Page 82: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Include Identifies a comma-separated list (CSV)of non-key Columns from the currenttable.Not all DBMSs support the 'Include'property on indexes, therefore thisproperty will only be visible for DBMSsthat support it.

Notes

Warning: Enterprise Architect assumes that Indexes have·

at least one column assigned to them; however, EnterpriseArchitect does not enforce this rule during modelingIf DDL is generated for a Table that has an Index definedwithout column(s) assigned, that DDL will be invalid,unless the index is functional-based

Any columns assigned to a functional-based index are·

ignored

(c) Sparx Systems 2019 Page 82 of 335

Page 83: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Unique Constraints

Unique Constraints enforce the 'uniqueness' of a set of fieldsin all rows of a Table, which means that no two rows in aTable can have the same values in the fields of a UniqueConstraint. Unique Constraints are similar to Primary Keys(in that they also enforce 'uniqueness') but the maindifference is that a Table can have multiple UniqueConstraints defined but only one Primary Key.

Access

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table name >Constraints/Indexes > Right-click > AddNew Constraint

ContextMenu

In diagram or Browser window |Right-click on Table element | Features |Constraints/Indexes

KeyboardShortcuts

Click on Table: F9 > Constraints/Indexes:Ctrl+N

(c) Sparx Systems 2019 Page 83 of 335

Page 84: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Create a Constraint

Step

Action

1 On the 'Constraints/Indexes' tab, a new constraint isautomatically created and assigned the defaultconstraint name and a 'Type' of index.Overtype the constraint name with a name thatidentifies this as a unique constraint.

2 In the 'Type' field, change the value from 'index' to'unique'.

Notes

Warning: Enterprise Architect assumes that Unique·

Constraints have at least one column assigned to them;however, Enterprise Architect does not enforce this ruleduring modelingIf DDL is generated for a Table that has a uniqueconstraint defined without column(s) assigned, that DDLwill be invalid

(c) Sparx Systems 2019 Page 84 of 335

Page 85: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Foreign Keys

A Foreign Key defines a column (or a collection ofcolumns) that enforces a relationship between two Tables. Itis the responsibility of the database server to enforce thisrelationship to ensure data integrity. The model definition ofa Foreign Key consists of a parent (primary) Tablecontaining a unique set of data that is then referred to in achild (foreign) Table.

In Enterprise Architect, a Foreign Key is modeled with twodifferent (but related) UML components:

A Foreign Key constraint (a UML operation with the·

stereotype of <<FK>>) stored on the child Table and

An Association connector (stereotype of <<FK>>)·

defining the relationship between the two Tables

Create a Foreign Key

Although the definition of a Foreign Key can be complex,the Foreign Key Constraint screen simplifies the modelingof Foreign Keys. This screen is purpose-designed to helpyou select which constraint in the parent Table to use, andwill automatically match the child Table columns to those inthe parent Table that are part of the constraint. Differentaspects of the process of developing a Foreign Key aredescribed here separately for illustration, but the overallprocess should be a smooth transition.

(c) Sparx Systems 2019 Page 85 of 335

Page 86: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

A number of conditions must be met before a Foreign Keydefinition can be saved:

Both Tables must have matching DBMSs defined·

The parent Table must have at least one column·

The parent Table must have a Primary Key, unique·

constraint or unique index defined

Create a Foreign Key - using the DatabaseBuilder

Step

Action

1 In the Database Builder tree, right-click on the childTable name and click on 'Add new Foreign Key on<table name>'.A dialog displays listing all the possible parentTables.

2 Double-click on the required parent Table name inthe list or select it and click on the OK button.The 'Foreign Key Constraint' screen displays.

(c) Sparx Systems 2019 Page 86 of 335

Page 87: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Create a Foreign Key - using a relationship ona diagram

Step

Action

1 In the Data Modeling diagram, locate the requiredchild (Foreign Key) Table and parent (Primary Key)Table.

2 Select an Association connector in the 'DataModeling' page of the Diagram Toolbox.

3 Click on the child Table and draw the connector tothe parent Table.

4 If the Foreign Key Constraint screen has been set todisplay automatically when two Tables are joined, itdisplays now. Otherwise, either:

Double-click on the connector or·

Right-click on the connector and select the·

'Foreign Keys' optionThe Foreign Key Constraint screen displays.

The Foreign Key Constraint Screen

(c) Sparx Systems 2019 Page 87 of 335

Page 88: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

As an example this image shows the Foreign Key Constraintscreen loaded with the details of'fk_customersaddresses_customers' (as defined in theExample model).

Option Action

Join onConstraint

This combo box lists all definedconstraints in the parent Table that couldbe used as the basis of a Foreign Key.(These constraints can be Primary Keys,Unique Constraints or Unique Indexes.)The first constraint in the list is selectedby default; if this is not the constraint youwant, select the correct constraint fromthe combo box.When you select the constraint, itscolumns are automatically listed in the

(c) Sparx Systems 2019 Page 88 of 335

Page 89: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

'Involved Columns' panel, under the'Parent: <tablename>' column.

InvolvedColumns

This list is divided into two: the columnsinvolved in the selected constraint arelisted on the left, and the child columnsthat are going to be paired to the parentcolumns are listed on the right.When a constraint is selected (in the 'Joinon constraint' field) the parent side isrefreshed to display all columns assignedto the selected constraint. On the childside the system will automaticallyattempt to match each parent column toone of the same name in the child Table.If the child Table does not have a columnof the same name, a new column of thatname will be added to the list, flaggedwith (*) to indicate that a new columnwill be created in the Table.However, if you want to force the pairingto an existing child Table column or anew column with a different name, clickon the column name field and either:

Type in the replacement name, or·

Select an existing column (click on the·

drop-down arrow and select the namefrom the list)

(c) Sparx Systems 2019 Page 89 of 335

Page 90: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Name This field defines the name of the ForeignKey constraint, and defaults to a nameconstructed by the Foreign Key NameTemplate.To change the name to something otherthan the default, simply overtype thevalue.

On Delete Select the action that should be taken onthe data in the child Table when data inthe parent is deleted, so as to maintainreferential integrity.

On Update Select the action that should be taken onthe data in the child Table when data inthe parent is updated, so as to maintainreferential integrity.

Parent Click on the drop-down arrow and selectthe cardinality of the parent Table in theForeign Key.

Child Click on the drop-down arrow and selectthe cardinality of the child Table in theForeign Key.

Create? If you want to create a Foreign Key Indexat the same time as the Foreign Key, setthis property to True.

(c) Sparx Systems 2019 Page 90 of 335

Page 91: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

The name of the Foreign Key Index iscontrolled by the Foreign Key Indextemplate, and the generated name isshown in the 'Name' field underneath the'Create?' field.

Automatically show thisscreen whentables arejoined

(For diagrammatic modeling) Select thischeckbox to automatically display thisscreen whenever an Association iscreated between two Tables.

Delete Click on this button to delete thecurrently selected existing (saved)Foreign Key.A prompt is displayed to confirm thedeletion (and the deletion of the ForeignKey Index, if one exists) - click on theYes button.Deleting a Foreign Key leaves anAssociation connector in place, whichyou can either edit or delete (right-clickand select 'Delete association: to <Tablename>').

OK Click on this button to save the ForeignKey.

(c) Sparx Systems 2019 Page 91 of 335

Page 92: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Examples

This example shows simple Foreign Keys in a diagram:

The same Foreign Key will be shown in the DatabaseBuilder's tree as a child node under the Table'customers.addresses'.

(c) Sparx Systems 2019 Page 92 of 335

Page 93: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Check Constraints

A Check Constraint enforces domain integrity by limitingthe values that are accepted by a column.

Access

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table name >Constraints/Indexes > Right-click > AddNew Constraint

ContextMenu

In diagram | Right-click on Table |Features | Constraints/Indexes |Right-click | Add New Constraint

KeyboardShortcuts

Click on Table: F9 > Constraints/Indexes:Ctrl+N

Create a Constraint

Step

Action

(c) Sparx Systems 2019 Page 93 of 335

Page 94: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

1 On the 'Constraints/Indexes' tab of the Columns andConstraints screen, a new constraint is automaticallycreated and assigned the default constraint name anda 'Type' of index.Overtype the constraint name with a name thatidentifies the constraint as a check constraint, suchas 'CHK_ColumnName' (the CHK_ prefix isoptional).

2 In the 'Type' field, change the value from 'index' to'check'.

3 In the 'Properties' panel for the Condition property,type the SQL statement that will be used as theCheck Condition; for example, column1 < 1000.If the condition is long, click on the button todisplay a SQL editor (with syntax highlighting).

Delete a Check Constraint

If you do not want to keep a check constraint, either:

Right-click on it in the list and select 'Delete constraint·

<name>', or

Click on the item and press Ctrl+D·

The constraint is immediately deleted.

(c) Sparx Systems 2019 Page 94 of 335

Page 95: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Notes

Any columns assigned to a check constraint are ignored·

(c) Sparx Systems 2019 Page 95 of 335

Page 96: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Table Triggers

A Table trigger is SQL or code that is automaticallyexecuted as a result of data being modified in a databaseTable. Triggers are highly customizable and can be used inmany different ways; for example, they could be used tostop certain database activities from being performed duringbusiness hours, or to provide validation or perform deletionsin secondary Tables when a record in the primary Table isdeleted.

In Enterprise Architect, a Table trigger is modeled as astereotyped operation and managed using the Table's'Constraints' screen.

Access

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table name >Constraints/Indexes | Right-click | AddNew Constraint

ContextMenu

In diagram | Right-click on Table |Features | Constraints/Indexes |Right-click | Add New Constraint

Keyboard Click on Table: F9 > Constraints/Indexes:

(c) Sparx Systems 2019 Page 96 of 335

Page 97: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Shortcuts Ctrl+N

Create a Table Trigger

Step

Action

1 On the 'Constraints/Indexes' tab, a new constraint isautomatically created and assigned the defaultconstraint name and a 'Type' of index.Overtype the constraint name with a name thatidentifies the constraint as a trigger, such asTRG_OnCustomerUpdate. (The TRG_ prefix isoptional.)

2 In the 'Type' field, change the value from 'index' to'trigger'.

3 In the 'Properties' panel for the Statement property,type in the complete SQL statement (includingCREATE TRIGGER) that will define the Trigger.If the condition is long, click on the button todisplay a SQL editor (with syntax highlighting).

4 The properties Trigger Time and Trigger Event arecurrently information-only values and are not used in

(c) Sparx Systems 2019 Page 97 of 335

Page 98: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DDL generation.

Delete a Table Trigger

If you do not want to keep a trigger, either:

Right-click on it in the list and select 'Delete constraint·

<name>', or

Click on the item and press Ctrl+D·

The trigger is immediately deleted.

Notes

Any columns assigned to table triggers are ignored·

(c) Sparx Systems 2019 Page 98 of 335

Page 99: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

SQL Scratch Pad

The SQL Scratch Pad provides a mechanism to develop andrun ad-hoc SQL Queries against a live database. While youdevelop your data model you might want to execute and testad-hoc SQL Queries for a DDL script, or run enquiries onthe live database; all of this is possible within the EnterpriseArchitect Database Builder interface.

The SQL Scratch Pad requires the Database Builder to havea valid ODBC connection to a live database. This databaseconnection is shared between the 'SQL Scratch Pad','Database Compare' and 'Execute DDL' tabs of the DatabaseBuilder.

The Scratch Pad consists of:

A toolbar providing facilities for importing, saving,·

executing and clearing the SQL Queries

An editor panel in which you create or import the SQL·

Queries - this panel provides SQL-based syntaxhighlighting for the current data model

A tabbed panel consisting of two pages, one to show the·

results of executing the Query and one to display anymessages generated during the execution

Access

Open the Database Builder window, then display the 'SQLScratch Pad' tab.

(c) Sparx Systems 2019 Page 99 of 335

Page 100: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Ribbon Develop > Data Modeling > DatabaseBuilder > SQL Scratch Pad

The Scratch Pad Toolbar

The functionality of each button on the Scratch Pad Toolbaris described in this table, working from left to right.

Button Action

Run SQL Executes the SQL Query currently shownin the Scratch Pad.Check the 'Results' and 'Messages' tabsfor the output of executing the Query.

New Clears the SQL Query editor fields sothat you can enter a new query.

Open Loads an SQL Query from file.A source file browser displays, defaultedto display SQL files. Click on the filename and on the Open button to displaythe file contents in the Scratch Pad.

Save to SQL Saves this SQL statement to the SQL

(c) Sparx Systems 2019 Page 100 of 335

Page 101: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Query Query object it came from.

Save to NewSQL Query

Creates a new SQL Query object andsaves this statement to that object.

Save to File Saves the currently-displayed Query tothe file it came from.If you created the Query from scratch, asource file browser displays in which youtype the new file name and click on theSave button to save the Query.

Save to NewFile

Saves the currently-displayed Query to anew .sql file.A source file browser displays on whichyou type in the new file name and clickon the Save button to save the Query.

Clear Clears the contents of the Scratch Pad.Any Query displayed in the Scratch Padremains there until you either replace itwith another Query from file or you closethe model.

ToggleComment

Applies the SQL comment characters '--'to the beginning of each selected line or,if the selected lines are alreadycommented, removes the commentcharacters. Alternatively, press

(c) Sparx Systems 2019 Page 101 of 335

Page 102: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Ctrl+Shift+C.

StatementSeparator

Type in the character(s) to use to markthe end of each statement.

Help Displays the Help on the SQL QueryScratch Pad.

QueryDescription

Displays a label providing a descriptionof the current SQL, whether there arepending changes (indicated by a leading*), and the name of the loaded SQLQuery object or Filename.

Notes

The SQL Scratch Pad does not manipulate your SQL in·

any way, so you must use the correct syntax for thecurrent DBMS

While the SQL Scratch Pad can execute multiple SQL·

statements, and the status and messages of each statementare shown in the 'Messages' list, only the results of oneSELECT statement can be shown in the 'Results' list at atime; all subsequent SELECT statements will be ignored

(c) Sparx Systems 2019 Page 102 of 335

Page 103: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Compare

The 'Database Compare' tab provides a mechanism forcomparing the current data model with a live database, andoptionally synchronizing any differences in either direction.Differences 'pushed' into a live database are performedusing 'Alter DDL' statements, while changes imported fromthe live database can be directly 'pulled' into the model.

The Database Compare functionality requires the DatabaseBuilder to have a valid ODBC connection to a live database.This database connection is shared by the 'SQL ScratchPad', 'Database Compare' and 'Execute DDL' tabs of theDatabase Builder.

Access

Open the Database Builder window, then display the'Database Compare' tab.

Ribbon Develop > Data Modeling > DatabaseBuilder > Database Compare

The DDL Compare Tab

(c) Sparx Systems 2019 Page 103 of 335

Page 104: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

The 'Database Compare' tab has a number of controls, asdescribed here.

Number &Name

Description

1 CaseSensitive

Click on this checkbox to make allcomparisons of properties recognizedifferences in letter-case in the propertytext.

2 Use Aliasif Available

Click on this checkbox to indicate thatany defined aliases should be usedinstead of object names (at both object

(c) Sparx Systems 2019 Page 104 of 335

Page 105: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

and column level).

3 Reset All Click on this button to set the 'Action'flag for all objects back to the defaultvalue.

4 Set ImportAll

Click on this button to set the 'Action'flag of all detected differences to <====;that is, update the model with the value(s)from the live database.

5 SetSynchronizeAll

Click on this button to set the 'Action'flag of all detected differences to ====>;that is, update the live database with thevalue(s) from the model.

6Differences

Review the list of objects found to havemis-matches between the model and thelive database. Selecting an item in this listwill populate the 'Components' list.(See the Differences List table for adetailed description of each column.)

7Components

Review this list of properties of theselected object that differ between themodel and the live database.(See the Component List table for adetailed description of each column.)

(c) Sparx Systems 2019 Page 105 of 335

Page 106: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

8 Reset Click on this button to set the 'Action'flag for all properties of the current objectback to the default value.

9 Importfrom ODBC

Click on this button to import allproperties' values (with the 'Action' of<===) from the live database into themodel.

10 GenerateDDL

Click on this button to generate the 'AlterDDL' statements for all objects with an'Action' of ====>, and send thestatements to the 'Execute DDL' tab.

Differences List

Column Description

EA Displays the name of each object in themodel that has one or more detecteddifferences. Blank values indicate that theobject is missing in the model but existsin the live database.

Action Defaults to 'No Action' as the action totake considering this object's

(c) Sparx Systems 2019 Page 106 of 335

Page 107: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

difference(s). Click on the drop-downarrow and select a specific action. The listof available actions in the list will dependon whether or not the given object ispaired in the model and live database.Paired objects

No Action - do not update the database·

or model with this change===> - update the object in the·

database from the model<=== - update the object in the model·

from the databaseCustomize - set the items to No Action·

prior to setting different actions oneach item in the lower panelUnpair - separate the paired objects so·

that they are not compared with eachother or updated from each other

Unpaired objectsCreate <object name> - create the·

missing database object in the databaseor model, as appropriateDelete <object name> - delete the·

object from the modelDrop <object name> - delete the object·

from the databasePair with <object name> - pair the·

(c) Sparx Systems 2019 Page 107 of 335

Page 108: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

object in the database with the named(unpaired) object in the model, so thatthey are compared for differencesbetween them

The 'Action' fields in the 'ComponentsList' (the lower panel) will be updatedbased on the selection of this field.For example, if the live database has aTable column 'Address1' and the modeldoesn't, setting the object 'Action' to'===>' (update the object in the databasefrom the model) sets the column 'ItemAction' to 'Drop Address1', which willremove the column from the livedatabase.

ODBC Shows the name of each object in the livedatabase that has one or more detecteddifferences. Blank values indicate that theobject exists in the model but is missingin the live database.

Count Shows the total number of detecteddifferences for the object (and all of itscomponents) between the model and livedatabase.

(c) Sparx Systems 2019 Page 108 of 335

Page 109: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Component List

Column Description

Item Shows the component name ordescription for each detected difference.The differences are grouped into threecategories: Properties, Columns andConstraints, in a tree structure.

EA Shows the value of the given componentas detected in the model. Blank valuesindicate that the value is missing in themodel but exists in the live database.

Action Defaults to the action corresponding tothe setting of the object 'Action' field inthe 'Differences' list, to indicate the actionto take regarding the difference detectedfor the component. Click on thedrop-down arrow to select an alternativeaction; the available options in the listdepend on the component's type and thedetected difference.

No Action - do not update the database·

or model===> - update the object in the live·

database from the model

(c) Sparx Systems 2019 Page 109 of 335

Page 110: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

<=== - update the object in the model·

from the live databaseAdd <item name> - create the missing·

item in the database or model, asappropriateDelete <item name> - delete the item·

from the modelDrop <item name> - delete the item·

from the live database

ODBC Shows the value for the selectedcomponent in the live database. Blankvalues indicate that the value exists in themodel but is missing in the live database.

Count Shows the number of differences betweenthe model and the live database detectedin the selected component.

Working with the Database Comparison

Whenever you perform a comparison, Enterprise Architectreads the definition from both the live database and themodel, and then attempts to 'pair' each object from onesource with the other, using its name (and schema, ifrelevant for the current DBMS).

(c) Sparx Systems 2019 Page 110 of 335

Page 111: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

If a match is found, the object name is shown in both the'EA' and 'ODBC' columns with a default action of 'NoAction'. The 'Count' column indicates the total number ofdifferences found for the object and its components orproperties.

If a match is not found between the systems, the objectname is shown in the source column (either 'EA' or 'ODBC')while the other column is blank. In this state it is possible topair the object with an object of a different name; the'Action' dropdown list will present the available objects. If anew pairing is made the two objects' definitions arecompared for differences and the results are shown in the'Components' list, with the default action of '====>'selected.

If you select an action at the object level, this will set thematching action for all of the object's components andproperties. However, if you select the 'Customize' action atthe object level, you can determine a different action foreach component.

As an example, both a column (tax_amount) and constraint(ck_customersordersitems_discount) were renamed in Table'public.customers_order_items' (in the Example model) anda database compare performed; this image shows thedifferences found:

(c) Sparx Systems 2019 Page 111 of 335

Page 112: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

In the image there is only one Table that had detecteddifferences - 'public.customers_order_items'; selecting thispopulates the 'Components' list. From the detected results itcan be determined that the data model contains a column(tax_amount2) and a check constraint(ck_customerordersitems_discount1) that the live databasedoesn't and in turn the live database contains a column(tax_amount) and a check constraint(ck_customerordersitems_discount) that the data modeldoesn't.

Comparing with Options

The 'Compare with Options' functionality works in the samemanner as for a direct comparison, except that you areprompted to choose which object/property comparisonsshould be performed. This enables you to ignore particular

(c) Sparx Systems 2019 Page 112 of 335

Page 113: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

differences that are not of relevance at the current time.

These tables describe the different comparisons that can beenabled or disabled.

All Objects, Owner

Comparison Action

Owner Select to indicate that the 'Owner'property of all database objects should becompared, after the objects have been'paired'.

Table Options

Option Action

Tables Select this parent option to enable all ofthe Table comparison options. Deselect todisable all the other options. You wouldthen deselect or select specific options inthe list.

Table - Select to indicate that extended properties

(c) Sparx Systems 2019 Page 113 of 335

Page 114: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

ExtendedProperties

of Tables (such as DB Version andTablespace) should be compared.

Table -Remarks

Select to indicate that remarks applied toTables should be compared.

Columns Select this parent option to enable all ofthe 'Column comparison' options.Deselect to disable all the other 'Column'options. You would then deselect orselect specific options in the list.

Column -Type

Select to indicate that the datatype namefor the Table Columns should becompared.

Column -Size

Select to indicate that the datatype sizefor the Table Columns should becompared.

Column -DefaultValue

Select to indicate that the default valuesof the Table Columns should becompared.

Column -Position

Select to indicate that the Table Columnpositions should be compared.

Column - NotNull

Select to indicate that the not nullproperty of the Table Columns should be

(c) Sparx Systems 2019 Page 114 of 335

Page 115: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

compared.

Column -AutoNumbering

Select to indicate that the autonumberingproperties for the Table Columns shouldbe compared (such as AutoNum,StartNum and Increment).

Column -UnmatchedColumns

Select to indicate that Table Columns thatare unmatched between the model and thelive database should be compared.Typically these are columns that exist inone system but do not exist in the other.

Column -ExtendedProperties

Select to indicate that extended propertiesof Table Columns (such as Unsigned andZerofill) should be compared.

Column -Remarks

Select to indicate that remarks applied toTable Columns should be compared.

Constraints Select this parent option to enable all ofthe 'Table Constraint comparison'options. Deselect to disable all the 'TableConstraint' options. You would thendeselect or select specific options in thelist.

Constraint -Primary Keys

Select to indicate that properties relatedto Primary Keys should be compared.

(c) Sparx Systems 2019 Page 115 of 335

Page 116: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Constraint -Foreign Keys

Select to indicate that properties relatedto Foreign Keys should be compared.

Constraint -Indexes

Select to indicate that properties relatedto Indexes should be compared.

Constraint -UniqueConstraints

Select to indicate that properties relatedto Unique Constraints should becompared.

Constraint -CheckConstraints

Select to indicate that properties relatedto Check Constraints should becompared.

Constraint -TableTriggers

Select to indicate that properties relatedto Table Triggers should be compared.

Constraint -UnmatchedConstraints

Select to indicate that Table Constraintsthat are unmatched between the modeland the live database should becompared. Typically these are constraintsthat exist in one system but do not existin the other.

Constraints -ExtendedProperties

Select to indicate that extended propertiesof Table Constraints (such as Fill Factorand Clustered) should be compared.

(c) Sparx Systems 2019 Page 116 of 335

Page 117: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Constraints -Remarks

Select to indicate that remarks applied toTable Constraints should be compared.

Notes

The Database Compare functionality currently can·

perform comparisons on Table, View, Procedure,Function and Sequence object types

(c) Sparx Systems 2019 Page 117 of 335

Page 118: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Execute DDL

The 'Execute DDL' tab provides a mechanism to easilyexecute generated DDL statements against a live database,and provides instant feedback on their success, all within theEnterprise Architect interface and without the need for otherproducts.

There are two different types of DDL statement thatEnterprise Architect can generate and send to the 'ExecuteDDL' tab:

Create DDL statements, created by the Generate DDL·

screen, and

Alter DDL statements, created by the Database Compare·

window

The Execute DDL functionality requires the DatabaseBuilder to have a valid ODBC connection to a live database.This database connection is shared between the SQL ScratchPad, Database Compare and 'Execute DDL' tabs of theDatabase Builder.

Access

Open the Database Builder window, then display the'Execute DDL' tab.

Ribbon Develop > Data Modeling > DatabaseBuilder > Execute DDL

(c) Sparx Systems 2019 Page 118 of 335

Page 119: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Execute the DDL

The 'Execute DDL' tab has these fields and buttons:

Field/Button Action

1 ExecutionQueue

Lists the tasks (each with an associatedDDL statement) that are yet to beexecuted. The list has three columns thatspecify the name of the object involved,the task and the action being performed.Selecting an item in the list will displaythe associated DDL statement (in the

(c) Sparx Systems 2019 Page 119 of 335

Page 120: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

'Script' field) for the given task.

2 Script A text box with SQL syntax highlighting,showing the DDL statement for theselected task.

3 Save Click on this button to save all theindividual DDL statements from both the'Execution Queue' and the 'Results List'into a single file.

4 ResetFailedActions

Click on this button to re-queue anyfailed or skipped tasks from the 'ResultsList' to the bottom of the 'ExecutionQueue'.

5 Skip Click on this button to skip over the nexttask in the 'Execution Queue' and notexecute it. The task will be moved intothe 'Results List' and not given a result.When you click on the Reset FailedActions button, skipped tasks are returnedto the Execution Queue along with anyfailed tasks.

6 Execute Click on this button to execute the nexttask in the 'Execution Queue'. The task isremoved from the top of the 'ExecutionQueue' and added to the end of the

(c) Sparx Systems 2019 Page 120 of 335

Page 121: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

'Results List' with the execution result.

7 ExecuteAll

Click on this button to execute all tasks inthe 'Execution Queue'. When execution iscomplete, the 'Results List' will displaythe results of each individual task.

8 ResultsList

Lists the executed tasks with the resultsof execution for each task. Selecting anitem in this list will display the DDLstatement that was executed, in the'Script' field.

Example

In the example used in the earlier section on DatabaseComparison (when a column and constraint were renamed),if the defaults are used to 'push' the data model changes intothe live database the Execute DDL screen is populated withthe details shown here.

(c) Sparx Systems 2019 Page 121 of 335

Page 122: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

In summary, DDL is generated to drop both the old columnand the old constraint (tasks 'Drop Column' and 'DropConstraint'), then the column and constraint are created withthe new names (tasks 'Add Column' and 'Add Constraint')and finally each has their comments/remarks applied (tasks'Add Constraint - Constraint Comment' and 'Add Column -Column Comment').

(c) Sparx Systems 2019 Page 122 of 335

Page 123: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Objects

Whilst Tables are the fundamental components of arelational database, representing multiple rows of structureddata elements, there are numerous other objects that supportTables to improve the functionality and use of the storeddata, such as:

Database Views - a View represents the result-set of a·

pre-defined query; they are dynamically derived from thedata stored in one or more Tables (or other Views)

Database Procedures - a feature that some DBMS·

products implement to provide subroutines that cancontain one or more SQL statements to perform a specifictask such as data validation, access control, or to reducenetwork traffic between clients and the DBMS servers

Database Functions - a feature that some DBMS products·

implement to provide a mechanism to extend thefunctionality of the database server; each is a routine thatcan accept parameters, perform an action (such as acomplex calculation) and return the result of that action asa value

Database Sequences - a feature that some DBMS products·

implement to provide a mechanism to generate uniquevalues - the Sequence ensures that each call to it returns aunique value

The UML itself does not specify how data modeling isperformed, but Enterprise Architect has a fully integratedUML profile for data modeling and a range of features built

(c) Sparx Systems 2019 Page 123 of 335

Page 124: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

in to the core product that will make data modeling easy.

The profile uses stereotypes and Tagged Values to extendstandard UML elements into data modeling constructs. Thisis achieved by adding the database object stereotype to aUML Class; so that you would model:

Data Modeling diagrams as extended UML Class·

diagrams

Database Tables as UML Class objects with a stereotype·

of <<table>>

Database Views as UML Class objects with a stereotype·

of <<view>>

Database Procedures as UML Class objects with a·

stereotype of <<procedure>>

Database Functions as UML Class objects with a·

stereotype of <<function>>

Database Sequences as UML Class objects with a·

stereotype of <<dbsequence>>

You can quickly create and configure all of these objects inyour database model with Enterprise Architect.

(c) Sparx Systems 2019 Page 124 of 335

Page 125: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Tables

Tables are the fundamental components of a relationaldatabase, representing multiple rows of structured dataelements (referred to as Columns). Every individual item ofdata entered into a relational database is represented by avalue in a column.

Enterprise Architect's UML Profile for Data Modelingrepresents:

Database Tables as UML Class objects with a stereotype·

of <<table>>

Table columns as UML attributes of a Table, with a·

stereotype of <<column>>

Primary Keys as UML operations/methods of a Table,·

with a stereotype of <<PK>>

Foreign Keys as UML operations/methods of a Table,·

with a stereotype of <<FK>>

Indexes as UML operations/methods of a Table, with a·

stereotype of <<index>>

Unique Constraints as UML operations/methods of a·

Table, with a stereotype of <<unique>>

Check Constraints as UML operations/methods of a·

Table, with a stereotype of <<check>>

Table Triggers as UML operations/methods of a Table,·

with a stereotype of <<trigger>>

Enterprise Architect refers to all of the UML operations of aTable collectively as Constraints, hence the screen you use

(c) Sparx Systems 2019 Page 125 of 335

Page 126: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

to maintain a Table's UML attributes and operations iscalled the Columns and Constraints screen.

Example

This simple example of a Physical Data Model diagram inEnterprise Architect consists of two Database Tablesrepresented by UML Classes, named customers andcustomer_addresses.

Each Table defines database columns, using UML attributestyped appropriately for the target DBMS (in this case,PostgreSQL).

Notes

The Table stereotype is denoted by the icon in the·

top-right corner of each Class (see the Data ModelingNotation topic)

The Enterprise Architect maintenance screen for·

(c) Sparx Systems 2019 Page 126 of 335

Page 127: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

managing Table Columns doesn't allow you to change theattributes stereotype, since <<column>> is the only validoption

It is possible to hide the <<column>> stereotype label·

shown in the example Tables (see the Data ModelingNotation topic)

(c) Sparx Systems 2019 Page 127 of 335

Page 128: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Create a Database Table

Fundamental to data modeling is the creation of DatabaseTables within the model. There are two ways to create aTable:

Within the Database Builder or·

On an open Data Model diagram·

Add a Database Table with the DatabaseBuilder

Step

Action

1 Open the Database Builder ('Develop > DataModeling > Database Builder').

2 Load or create a Data model.

3 Right-click on the Tables Package and select 'AddNew Table'.

(c) Sparx Systems 2019 Page 128 of 335

Page 129: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

4 Overtype the default name with the appropriatename for the Table, and press the Enter key.

5 Double-click on the Table element to define theTable properties.

Add a Database Table to a diagram

Step

Action

1 Create and/or open a Data Modeling diagram.

2 Drag and drop the 'Table' toolbox icon onto thediagram.

(c) Sparx Systems 2019 Page 129 of 335

Page 130: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

This generates a new Table element:

3 Double-click on the Table element to define theTable properties.

(c) Sparx Systems 2019 Page 130 of 335

Page 131: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Table Columns

In a relational database, a Table column (sometimes referredto as a field) stores a single data value of a particular type ineach row of the Table. Table columns can have variousindividual properties such as a default value or whether thefield accepts Null values.

A Database Table Column is represented in the UML DataModeling Profile as a stereotyped attribute; that is, anattribute with the <<column>> stereotype. In EnterpriseArchitect you define and maintain Table Columns using thepurpose-designed 'Columns' page of the Database Builder,or the 'Columns and Constraints' dialog.

(c) Sparx Systems 2019 Page 131 of 335

Page 132: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Create Database Table Columns

A database Table column is represented in the UML DataModeling Profile as an attribute with the <<column>>stereotype. For a selected Table, you can review the existingcolumns and create new columns, on the 'Columns' page ofthe Database Builder or on the 'Columns and Constraints'screen.

You can define column details directly on the list ofcolumns on the 'Columns' tab. The changes areautomatically saved as you complete each field. Some fieldshave certain restrictions on the data you can enter, asdescribed here. The tab also contains a 'Properties' panel anda 'Notes' field, which are populated with the existinginformation on the selected column. Each new column thatyou create is automatically assigned a set of default valuesand added to the bottom of the list.

Access

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table > Columns >Right-Click > Add new Column

ContextMenu

In diagram, right-click on required Table |Features | Columns | Right-Click | Add

(c) Sparx Systems 2019 Page 132 of 335

Page 133: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

new Column

KeyboardShortcuts

Select a table | F9 | Tab Key (to set inputfocus on the 'Columns' tab) | Ctrl+N

Create columns in a Table

Option Action

Name Overtype the default name with theappropriate column name text.

Type Click on the drop-down arrow and selectthe appropriate datatype for the column.The available datatypes depend on theDBMS assigned to the parent Table.

Length (Optional) Some datatypes have a lengthcomponent - for example, VARCHARhas a length that defines the number ofcharacters that can be stored. If thedatatype does not have a lengthcomponent, this field is disabled.If the field is available and if you need todefine a number of characters, type the

(c) Sparx Systems 2019 Page 133 of 335

Page 134: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

value here.

Scale (Optional) Some datatypes have a scalecomponent - for example, DECIMAL hasa scale that defines the number ofdecimal places that can be held. If thedatatype does not have a scalecomponent, this field is disabled.If the field is available and if you need todefine a scale, type the value here.

PK Select the checkbox if the column is partof the Primary Key for this Table.

Not Null Select the checkbox if empty values areforbidden for this column.The checkbox is disabled if the 'PK'checkbox is selected.

Alias If required for display and documentationpurposes, type in an alternative name forthe field.

Initial Value If required, type in a value that can beused as a default value for this column.

Notes Type in any additional informationnecessary to document the column.You can format the text using the Notes

(c) Sparx Systems 2019 Page 134 of 335

Page 135: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

toolbar at the top of the field.

Column Properties

The appropriate properties for the Table's DatabaseManagement System automatically display in the 'Property'panel (expand the 'Column (<name>)' branch if they are notvisible).

Property DBMS

Autonum(StartnumIncrement)

OracleMySQLSQL ServerDB2PostgreSQLSybase ASASybase ASENotes: If you require an automaticnumbering sequence, set this property toTrue and, if necessary, define the startnumber and increment.

Generated DB2Notes: Set this additional property forauto numbering in DB2, to 'By Default' or

(c) Sparx Systems 2019 Page 135 of 335

Page 136: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

'Always'.

NotForRep SQLServerNotes: Set this property to True if youwant to block replication.

Zerofill MySQLNotes: Set this property to True or Falseto indicate if fields are zerofilled or not.

Unsigned MySQLNotes: Set this property to True or Falseto indicate whether or not fields acceptunsigned numbers.

LengthType OracleNotes: Set this property to define thecharacter semantics as 'None', 'Byte' or'Char'.

(c) Sparx Systems 2019 Page 136 of 335

Page 137: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Delete Database Table Columns

For a selected database Table, you can review the existingcolumns and delete any individual column, on the 'Columns'tab of the Columns and Constraints screen.

Access

Use one of the methods outlined here to display a list ofcolumns for a table, then select a column and delete it.

When you select the 'Delete column '<name>'' option, if allvalidation rules are satisfied the column is immediatelydeleted.

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table > Columns >Right-click on column name > Deletecolumn <name>

ContextMenu

In diagram, right-click on required Table |Features | Columns | Right-click oncolumn name | Delete column <name>

KeyboardShortcuts

F9 | Use 'Up Arrow' or 'Down Arrow' toselect a column | Ctrl+D

(c) Sparx Systems 2019 Page 137 of 335

Page 138: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Notes

If the deleted database Table column is involved in any·constraints it will automatically be removed from them

(c) Sparx Systems 2019 Page 138 of 335

Page 139: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Reorder Database Table Columns

If you have several columns defined in a database Table,you can change the order in which they are listed. The orderin the list is the order in which the columns appear in thegenerated DDL.

Access

Use one of the methods outlined here to display a list ofcolumns for a Table, then select a column and reposition itwithin the list.

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table

ContextMenu

In diagram, right-click on required Table |Features | Columns

KeyboardShortcuts

F9

Change the column order

(c) Sparx Systems 2019 Page 139 of 335

Page 140: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Step

Action

1 In the 'Columns' tab, click on the required columnname in the list.

2 Right-click and select the:'Move column <name> up' option (or press·

Ctrl+Up Arrow) to move the column up oneposition'Move column <name> down' option (or press·

Ctrl+Down Arrow) to move the column down oneposition

These options have an immediate effect both in the'Columns' tab and on a diagram.

(c) Sparx Systems 2019 Page 140 of 335

Page 141: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Working with Database TableProperties

Once you have created a Database Table, you can review itsproperties and check that the DBMS and Owner values arecorrect. To display the 'Properties' dialog for a Table, eitherdouble-click on the Table name in the 'Database BuilderTables' Package or on the Table element on a diagram.

Important

A DBMS must be assigned to a Table before you can addcolumns in it. If you are using the Database Builder then theDBMS of the data model will be automatically applied to allnew Tables; however, if you have added a Table by othermeans (such as working on a diagram) then this is a manualstep.

Tasks

Once the Database Table properties are defined, you areready to add columns.

Task

Set the database type for a Table - other than the Table

(c) Sparx Systems 2019 Page 141 of 335

Page 142: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

name, the most important property to set for a DatabaseTable is the database type.

Set the database Table Owner - For some DBMSs allTables must be assigned an Owner/Schema; in EnterpriseArchitect this property is defined as a Tagged Value withthe name Owner.

Set extended options - some DBMSs have extendedoptions that are only relevant to that DBMS. Theseextended properties are stored as Tagged Values.

Default DBMS

Prior to creating a Physical Data Model it is advisable foryou to set the default DBMS, which will be automaticallyapplied to new database objects that you create outside ofthe Database Builder. You can set the default DBMS type inone of these ways:

Select 'Start > Desktop > Preferences > Preferences >·

Source Code Engineering > Code Editors', then set thefield 'Default Database'

Select 'Configure > Reference Data > Settings > Database·

Datatypes', then select a Product Name and select the 'Setas Default' checkbox

Set the DBMS in the second field of the Code Generation·

(c) Sparx Systems 2019 Page 142 of 335

Page 143: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Toolbar

(c) Sparx Systems 2019 Page 143 of 335

Page 144: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Set the Database Type

The most important property to set for a Database Table(after its name) is the database type or DBMS. The DBMSvalue selected will control how Enterprise Architect willdetermine:

How the Table name will be shown (with or without an·Owner)

What set of validation rules will be applied while database·modeling

The data types that are available when creating columns,·What set of DDL templates will be used in DDL·Generation

Access

Select a Table in the Browser window or on a diagram then,using any of the methods outlined here, open the Table's'Properties' dialog, display the 'General' tab, then display the'Main' child tab.

Ribbon Design > Element > Editors > PropertiesDialog > General > Main

ContextMenu

Right-click on the Table element |Properties | Special Action | General |Main

(c) Sparx Systems 2019 Page 144 of 335

Page 145: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

KeyboardShortcuts

Shift+Enter | General | Main

Other Double-click on the Table element|General | Main

Options

Field/Button Action

Database Click on the drop-down button and selectthe required database type from the list.

Apply Click on the Apply button to save anypending changes.

OK Click on the OK button to save anypending changes and close the screen.

(c) Sparx Systems 2019 Page 145 of 335

Page 146: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Set Database Table Owner/Schema

For some DBMSs all Tables must be assigned anOwner/Schema. In Enterprise Architect this property isphysically defined as a Tagged Value with the name Owner.However, a special properties page is provided to help youeasily manage the Owner property.

Access

Select a Table in the Browser window or on a diagram then,using any of the methods outlined here, open the Table's'Properties' dialog, display the 'General' tab and display the'Table Detail' child tab.

Ribbon Design > Element > Editors > Properties> << table >>

ContextMenu

Right-click on the Table element |Properties |Special Action > General >Table Detail

KeyboardShortcuts

Shift+Enter | General | Table Detail

Other Double-click on the Table element|'General' | 'Table Detail'

(c) Sparx Systems 2019 Page 146 of 335

Page 147: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Set the Database Table owner

Step

Action

1 In the 'Owner' field, type the name of the owner orschema of the Table.

(c) Sparx Systems 2019 Page 147 of 335

Page 148: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Set MySQL Options

To make use of Foreign Keys in MySQL, you must declarethe Database Table type as InnoDB.

Declare the Table type as InnoDB

Step

Action

1 Add a Tagged Value named Type to the Table.

2 Set the 'Value' field to 'InnoDB'.

Generate DDL

When you generate DDL for this Table, the Table type isincluded in the SQL script.

To allow for later versions of MySQL, additional Tableoptions that can be added in the same way include:

Tag Value (Example)

ENGINE InnoDB

(c) Sparx Systems 2019 Page 148 of 335

Page 149: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

CHARACTER SET

latin1

CHARSET latin1

COLLATE latin1_german2_ci

(c) Sparx Systems 2019 Page 149 of 335

Page 150: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Set Oracle Database Table Properties

To set additional Oracle Database Table properties, you usethe Table's Tagged Values.

Set Properties

The same properties can be added to indexes andconstraints, by highlighting the index or constraintOperation and adding the appropriate Tagged Values.

Step

Action

1 Add one or more Tagged Values to the Table, usingthe names provided in the 'Property/Tag' column ofthe 'Properties' Table.

2 Specify the appropriate value for each tag.Examples are provided in the 'Value' column of thisProperties Table.

CACHE - NOCACHE·

DBVERSION - 9.0.111·

FREELISTS - 1·

GRANT OWNER1 - SELECT·

GRANT OWNER2 - DELETE, INSERT,·

SELECT, UPDATE

(c) Sparx Systems 2019 Page 150 of 335

Page 151: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

INITIAL - 65536·

INITRANS - 1·

LOGGING - LOGGING·

MAXEXTENTS - 2147483645·

MAXTRANS - 255·

MINEXTENTS - 1·

MONITORING - MONITORING·

OWNER - OWNER1·

PARALLEL - NOPARALLEL·

PCTFREE - 10·

PCTINCREASE - 0·

PCTUSED - 0·

SYNONYMS -·

PUBLIC:TABLE_PUB;OWNER2:TABLE_OWNER2TABLESPACE - MY_TABLESPACE·

TEMPORARY - YES·

(c) Sparx Systems 2019 Page 151 of 335

Page 152: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Table Constraints/Indexes

Within Enterprise Architect, Table Constraints and Indexesare modeled on the same screen; collectivity they arereferred to as Constraints. Database Constraints define theconditions imposed on the behavior of a database Table.They include:

Primary Key - uniquely identifies a record in a Table,·consisting of one or more columns

Index - improves the performance of retrieval and sort·operations on Table data

Unique Constraints - a combination of values that·uniquely identify a row in the Table

Foreign Key - a column (or collection of columns) that·enforce a relationship between two Tables

Check Constraints - enforces domain integrity by limiting·the values that are accepted by a column

Table Trigger - SQL or code automatically executed as a·result of data in a Table being modified

In Enterprise Architect, you can define and maintain TableConstraints using either the purpose-designed'Constraints/Indexes' page of the Database Builder or theColumns and Constraints screen.

Access

(c) Sparx Systems 2019 Page 152 of 335

Page 153: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table name >Constraints/Indexes | Right-click | AddNew Constraint

ContextMenu

In diagram | Right-click on Table |Features | Constraints/Indexes |Right-click | Add New Constraint

KeyboardShortcuts

Click on Table: F9 > Constraints/Indexes:Ctrl+N

Create a Constraint

The process of creating any of these constraint types is thesame and is achieved in one of the ways described here.

Create a Constraint - Using the context menuor keyboard

Step

Action

(c) Sparx Systems 2019 Page 153 of 335

Page 154: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

1 A new constraint is automatically created andassigned the default name constraint n (where n is acounter) and a 'Type' of 'index'.Overtype the default name with your own constraintname.

2 If necessary, in the 'Type' field click on thedrop-down arrow and select the appropriateconstraint type.

3 If you prefer, type an alias for the constraint, in the'Alias' field.The 'Columns' field is read-only; it is populated withthe columns that you assign to the 'InvolvedColumns' tab.

Create a Constraint - Overtype the templatetext

Step

Action

1 On the 'Constraints/Indexes' tab for the selectedTable, the list of constraints ends with the templatetext New Constraint.

(c) Sparx Systems 2019 Page 154 of 335

Page 155: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Overtype this text with the appropriate constraintname, and press the Enter key.

2 The new constraint is automatically created andassigned the default Type of index.If necessary, in the 'Type' field click on thedrop-down arrow and select the appropriateconstraint type.

3 If you prefer, type an alias for the constraint, in the'Alias' field.The 'Columns' field is read-only; it is populated withthe columns that you assign to the 'InvolvedColumns' tab.

Assign Columns to a Constraint

The constraint types of Primary Key, Foreign Key, Indexand Unique all must have at least one column assigned tothem; this defines the columns that are involved in theconstraint.

Step

Action

1 On the 'Constraints/Indexes' tab for the selectedTable, click on the constraint to which you are

(c) Sparx Systems 2019 Page 155 of 335

Page 156: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

assigning columns.

2 The 'Available Columns' panel lists all columnsdefined for the Table.For each column to assign to the constraint,right-click on the column name and select 'Assigncolumn <name>'.The column name is transferred to the 'AssignedColumns' list.

Unassign Columns from a Constraint

Step

Action

1 On the 'Constraints/Indexes' tab for the selectedTable, click on the constraint from which you areunassigning columns.

2 In the 'Assigned Columns' list, right-click on thename of the column to unassign from the constraintand select 'Unassign column <name>'.The column name is transferred to the 'AvailableColumns' list.

(c) Sparx Systems 2019 Page 156 of 335

Page 157: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Reorder the Assigned Columns in aConstraint

If you have a number of columns in the constraint, you canrearrange the sequence by moving a selected column nameone place up or down the list at a time. To do this:

Right-click on the column name to move and select either:·

- Move column '<name>' up (Ctrl+Up Arrow) or - Move column '<name>' down (Ctrl+Down Arrow)

Delete a constraint

To delete a constraint you no longer require, right-click onthe constraint name in the list on the 'Constraints/Indexes'tab and select the 'Delete constraint <name>' option. If allvalidation rules for the given constraint type are met, theconstraint is immediately removed from the repository alongwith all related relationships (if there are any).

(c) Sparx Systems 2019 Page 157 of 335

Page 158: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Primary Keys

A Primary Key is a column (or set of columns) that uniquelyidentifies each record in a Table. A Table can have only onePrimary Key. Some DBMSs support additional properties ofPrimary Keys, such as Clustered or Fill Factor.

Access

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table name

ContextMenu

In diagram | Right-click on Table |Features | Constraints/Indexes

Create a Primary Key

In Enterprise Architect you can create a Primary Key fromeither the 'Columns' tab or the 'Constraints/Indexes' tab. Ineither case, when you add a column to a Primary Keyconstraint, the column is automatically set to be 'Not Null'.Additionally any diagram (assuming the 'Show Qualifiersand Visibility Indicators' option is set) containing the Tableelement will show the 'PK' prefix against the column name.

(c) Sparx Systems 2019 Page 158 of 335

Page 159: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

In this image, see the first column 'id: bigserial'.

Create a Primary Key - from the Columns tab

Step

Action

1 Either:In the Database Builder, click on a Table with one·

or more defined columns, and click on the'Columns' tab, orOn a diagram, click on a Table and press F9 to·

display the 'Columns' tab

(c) Sparx Systems 2019 Page 159 of 335

Page 160: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

2 For each column to include in the Primary Key,select the 'PK' checkbox.If a Primary Key constraint is not previously definedfor the current Table, the system will create a newconstraint using the Primary Key Name template.

Create a Primary Key - from the Constraintstab

Step

Action

1 Either:In the Database Builder, click on a Table with one·

or more defined columns, and click on the'Constraints/Indexes' tab, orOn a diagram, click on a Table and press F10 to·

display the 'Constraints/Indexes' tab

2 Overtype the New Constraint text with the PrimaryKey name, press the Enter key and click on the'Type' field drop-down arrow, and select 'PK'.

3 Assign the required columns to the PK constraint.

(c) Sparx Systems 2019 Page 160 of 335

Page 161: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

4 Set the Primary key's extended properties using theproperty panel.

Fill Factor is a numeric value between 0 and 100·

Is Clustered is a boolean value that determines the·

physical order of how the data is stored; for mostDBMSs the Is Clustered property defaults to Truefor Primary Keys

Remove columns from a Primary Key

You can remove columns from a Primary Key using eitherthe 'Columns' tab or the 'Constraints/Indexes' tab.

Remove columns from a Primary Key - usingthe Columns tab

Step

Action

1 Either:In the Database Builder, click on the Table with·

the Primary Key, and click on the 'Columns' tab,or

(c) Sparx Systems 2019 Page 161 of 335

Page 162: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

On a diagram, click on a Table and press F9 to·

display the 'Columns' tab

2 Against each column you want to remove from thePrimary Key, deselect the 'PK' checkbox.If you have removed all columns from the PrimaryKey constraint and the Primary Key is no longerneeded, it must be manually deleted.

Remove columns from a Primary Key - usingthe Constraints/Indexes tab

Step

Action

1 Either:In the Database Builder, click on the Table with·

the Primary Key, and click on the'Constraints/Indexes' tab, orOn a diagram, click on a Table and press F10 to·

display the 'Constraints/Indexes' tab

2 Unassign the columns on the PK constraint, asnecessary.

(c) Sparx Systems 2019 Page 162 of 335

Page 163: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Notes

Warning: Enterprise Architect assumes that Primary Key·

constraints have at least one column assigned to them;however, Enterprise Architect does not enforce this ruleduring modelingIf DDL is generated for a Table whose Primary Key hasno column assigned, that DDL will be invalid

(c) Sparx Systems 2019 Page 163 of 335

Page 164: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Non Clustered Primary Keys

When you create a Primary Key in some DBMSs (such asSQL Server or ASA), it is automatically created with the 'IsClustered' property set to True. Therefore when you model aPrimary Key in an Enterprise Architect data model, thesame behavior occurs.

Clustered indexes provide improved performance foraccessing the column(s) involved, by physically organizingthe data by those columns. There can be only one clusteredindex per Table.

In some situations, you might be more interested in theperformance of columns other than the ones assigned to thePrimary Key, and therefore you would need to change thedefault assignment so that the Primary Key is not clustered.

Access

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table name >Constraints/Indexes

ContextMenu

In diagram or Browser window |Right-click on Table | Features |Constraints/Indexes

(c) Sparx Systems 2019 Page 164 of 335

Page 165: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

KeyboardShortcuts

Click on Table: F9 > Constraints/Indexes

Define Primary Key as non-clustered

Subsequently, you can model an index for the same Table asclustered.

Step

Action

1 Highlight the existing Primary Key constraint.The Primary Key properties display in the 'Property'panel.

2 For the Is Clustered property, in the 'Value' fieldclick on the drop-down arrow and change the valueto False.

(c) Sparx Systems 2019 Page 165 of 335

Page 166: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Indexes

Database indexes are applied to Tables to improve theperformance of data retrieval and sort operations. Multipleindexes can be defined against a Table; however, each indeximposes overheads (in the form of processing time andstorage) on the database server to maintain them asinformation is added to and deleted from the Table

In Enterprise Architect an index is modeled as a stereotypedoperation.

Some DBMSs support special types of index; EnterpriseArchitect defines these using additional properties such asfunction-based, clustered and fill-factor.

Access

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table name >Constraints/Indexes

ContextMenu

In diagram | Right-click on Table |Features | Constraints/Indexes

KeyboardShortcuts

Click on Table: F9 > Constraints/Indexes

(c) Sparx Systems 2019 Page 166 of 335

Page 167: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Work on an index

Step

Action

1 On the 'Constraints/Indexes' tab for the Table,right-click and select 'Add new constraint'.The new constraint is added with the default name'constraint1' and the Type of 'index'.Overtype the name with your preferred index name.

2 Assign the appropriate columns to the Index.The 'Assigned Columns' list has an additional 'Order'field that specifies the order (Ascending or

(c) Sparx Systems 2019 Page 167 of 335

Page 168: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Descending) in which each assigned column isstored in the index. You can toggle the order foreach column, as required.Additionally, for MySQL indexes, a 'Len' field willbe visible in which you can define Partial Indexes;that is, an index that uses the leading 'n' number ofcharacters of a text based field. The 'Len' field takesonly whole number numeric values of between 0 andthe column's defined length. A value of 0 (which isthe default) indicates that the entire column is to beindexed.

3 In the 'Property' panel, review the settings of theextended properties that are defined for the currentDBMS.

Additional Properties

Property Description

Is Unique (True / False) indicates whether thecurrent index is a 'Unique Index'. AUnique Index ensures that the indexedcolumn (or columns) does not containduplicate values, thereby ensuring thateach row has a unique value (or

(c) Sparx Systems 2019 Page 168 of 335

Page 169: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

combination of values when the indexconsists of multiple columns).

Is Clustered (True / False) indicates whether thecurrent index is a 'Clustered Index'. Witha clustered index, the rows of the tableare physically stored in the same order asin the index, therefore there can be onlyone clustered index per table. By defaulta table's Primary Key is clustered.Not all DBMS's support clusteredindexes, therefore the 'Is Clustered' Indexproperty will only be visible for DBMSsthat support it.

Is Bitmap (True / False) indicates whether thecurrent index is a 'Bitmap' index. Bitmapindexes are meant to be used on columnsthat have relatively few unique values(referred to as 'low cardinality' columns)and that physically consist of a bit array(commonly called bitmaps) for eachunique value. Each of the arrays will havea bit for each row in the table.Consider this example: a bitmap index iscreated on a column called 'Gender',which has the options 'Male' or 'Female'.Physically, the index will consist of twobit arrays, one for 'Male' and one for

(c) Sparx Systems 2019 Page 169 of 335

Page 170: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

'Female'. The female bit array will have a1 in each bit where the matching row hasthe value 'Female'.The 'Is Bitmap' and 'Is Unique' propertiesare mutually exclusive, and so the DDLgeneration will ignore the 'Is Unique'property when the 'Is Bitmap' property isTrue.Bitmap Indexes are only supported byOracle; therefore, this property is onlyvisible while modeling Oracle indexes.

Fill Factor A numeric value between 0 and 100, thatdefines the percentage of available spacethat should be used for data.Not all DBMSs support fill factor,therefore the 'Fill Factor' index propertywill only be visible for DBMSs thatsupport it.

Functional-based

A SQL statement that defines thefunction/statement that will be evaluatedand the results indexed; for example: LOWER("field")Not all DBMSs support functional-basedindexes, therefore the 'Functional-based'Index property will only be visible forDBMSs that support them, such asPostgreSQL and Oracle.

(c) Sparx Systems 2019 Page 170 of 335

Page 171: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Include Identifies a comma-separated list (CSV)of non-key Columns from the currenttable.Not all DBMSs support the 'Include'property on indexes, therefore thisproperty will only be visible for DBMSsthat support it.

Notes

Warning: Enterprise Architect assumes that Indexes have·

at least one column assigned to them; however, EnterpriseArchitect does not enforce this rule during modelingIf DDL is generated for a Table that has an Index definedwithout column(s) assigned, that DDL will be invalid,unless the index is functional-based

Any columns assigned to a functional-based index are·

ignored

(c) Sparx Systems 2019 Page 171 of 335

Page 172: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Unique Constraints

Unique Constraints enforce the 'uniqueness' of a set of fieldsin all rows of a Table, which means that no two rows in aTable can have the same values in the fields of a UniqueConstraint. Unique Constraints are similar to Primary Keys(in that they also enforce 'uniqueness') but the maindifference is that a Table can have multiple UniqueConstraints defined but only one Primary Key.

Access

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table name >Constraints/Indexes > Right-click > AddNew Constraint

ContextMenu

In diagram or Browser window |Right-click on Table element | Features |Constraints/Indexes

KeyboardShortcuts

Click on Table: F9 > Constraints/Indexes:Ctrl+N

(c) Sparx Systems 2019 Page 172 of 335

Page 173: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Create a Constraint

Step

Action

1 On the 'Constraints/Indexes' tab, a new constraint isautomatically created and assigned the defaultconstraint name and a 'Type' of index.Overtype the constraint name with a name thatidentifies this as a unique constraint.

2 In the 'Type' field, change the value from 'index' to'unique'.

Notes

Warning: Enterprise Architect assumes that Unique·

Constraints have at least one column assigned to them;however, Enterprise Architect does not enforce this ruleduring modelingIf DDL is generated for a Table that has a uniqueconstraint defined without column(s) assigned, that DDLwill be invalid

(c) Sparx Systems 2019 Page 173 of 335

Page 174: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Foreign Keys

A Foreign Key defines a column (or a collection ofcolumns) that enforces a relationship between two Tables. Itis the responsibility of the database server to enforce thisrelationship to ensure data integrity. The model definition ofa Foreign Key consists of a parent (primary) Tablecontaining a unique set of data that is then referred to in achild (foreign) Table.

In Enterprise Architect, a Foreign Key is modeled with twodifferent (but related) UML components:

A Foreign Key constraint (a UML operation with the·

stereotype of <<FK>>) stored on the child Table and

An Association connector (stereotype of <<FK>>)·

defining the relationship between the two Tables

Create a Foreign Key

Although the definition of a Foreign Key can be complex,the Foreign Key Constraint screen simplifies the modelingof Foreign Keys. This screen is purpose-designed to helpyou select which constraint in the parent Table to use, andwill automatically match the child Table columns to those inthe parent Table that are part of the constraint. Differentaspects of the process of developing a Foreign Key aredescribed here separately for illustration, but the overallprocess should be a smooth transition.

(c) Sparx Systems 2019 Page 174 of 335

Page 175: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

A number of conditions must be met before a Foreign Keydefinition can be saved:

Both Tables must have matching DBMSs defined·

The parent Table must have at least one column·

The parent Table must have a Primary Key, unique·

constraint or unique index defined

Create a Foreign Key - using the DatabaseBuilder

Step

Action

1 In the Database Builder tree, right-click on the childTable name and click on 'Add new Foreign Key on<table name>'.A dialog displays listing all the possible parentTables.

2 Double-click on the required parent Table name inthe list or select it and click on the OK button.The 'Foreign Key Constraint' screen displays.

(c) Sparx Systems 2019 Page 175 of 335

Page 176: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Create a Foreign Key - using a relationship ona diagram

Step

Action

1 In the Data Modeling diagram, locate the requiredchild (Foreign Key) Table and parent (Primary Key)Table.

2 Select an Association connector in the 'DataModeling' page of the Diagram Toolbox.

3 Click on the child Table and draw the connector tothe parent Table.

4 If the Foreign Key Constraint screen has been set todisplay automatically when two Tables are joined, itdisplays now. Otherwise, either:

Double-click on the connector or·

Right-click on the connector and select the·

'Foreign Keys' optionThe Foreign Key Constraint screen displays.

The Foreign Key Constraint Screen

(c) Sparx Systems 2019 Page 176 of 335

Page 177: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

As an example this image shows the Foreign Key Constraintscreen loaded with the details of'fk_customersaddresses_customers' (as defined in theExample model).

Option Action

Join onConstraint

This combo box lists all definedconstraints in the parent Table that couldbe used as the basis of a Foreign Key.(These constraints can be Primary Keys,Unique Constraints or Unique Indexes.)The first constraint in the list is selectedby default; if this is not the constraint youwant, select the correct constraint fromthe combo box.When you select the constraint, itscolumns are automatically listed in the

(c) Sparx Systems 2019 Page 177 of 335

Page 178: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

'Involved Columns' panel, under the'Parent: <tablename>' column.

InvolvedColumns

This list is divided into two: the columnsinvolved in the selected constraint arelisted on the left, and the child columnsthat are going to be paired to the parentcolumns are listed on the right.When a constraint is selected (in the 'Joinon constraint' field) the parent side isrefreshed to display all columns assignedto the selected constraint. On the childside the system will automaticallyattempt to match each parent column toone of the same name in the child Table.If the child Table does not have a columnof the same name, a new column of thatname will be added to the list, flaggedwith (*) to indicate that a new columnwill be created in the Table.However, if you want to force the pairingto an existing child Table column or anew column with a different name, clickon the column name field and either:

Type in the replacement name, or·

Select an existing column (click on the·

drop-down arrow and select the namefrom the list)

(c) Sparx Systems 2019 Page 178 of 335

Page 179: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Name This field defines the name of the ForeignKey constraint, and defaults to a nameconstructed by the Foreign Key NameTemplate.To change the name to something otherthan the default, simply overtype thevalue.

On Delete Select the action that should be taken onthe data in the child Table when data inthe parent is deleted, so as to maintainreferential integrity.

On Update Select the action that should be taken onthe data in the child Table when data inthe parent is updated, so as to maintainreferential integrity.

Parent Click on the drop-down arrow and selectthe cardinality of the parent Table in theForeign Key.

Child Click on the drop-down arrow and selectthe cardinality of the child Table in theForeign Key.

Create? If you want to create a Foreign Key Indexat the same time as the Foreign Key, setthis property to True.

(c) Sparx Systems 2019 Page 179 of 335

Page 180: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

The name of the Foreign Key Index iscontrolled by the Foreign Key Indextemplate, and the generated name isshown in the 'Name' field underneath the'Create?' field.

Automatically show thisscreen whentables arejoined

(For diagrammatic modeling) Select thischeckbox to automatically display thisscreen whenever an Association iscreated between two Tables.

Delete Click on this button to delete thecurrently selected existing (saved)Foreign Key.A prompt is displayed to confirm thedeletion (and the deletion of the ForeignKey Index, if one exists) - click on theYes button.Deleting a Foreign Key leaves anAssociation connector in place, whichyou can either edit or delete (right-clickand select 'Delete association: to <Tablename>').

OK Click on this button to save the ForeignKey.

(c) Sparx Systems 2019 Page 180 of 335

Page 181: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Examples

This example shows simple Foreign Keys in a diagram:

The same Foreign Key will be shown in the DatabaseBuilder's tree as a child node under the Table'customers.addresses'.

(c) Sparx Systems 2019 Page 181 of 335

Page 182: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Check Constraints

A Check Constraint enforces domain integrity by limitingthe values that are accepted by a column.

Access

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table name >Constraints/Indexes > Right-click > AddNew Constraint

ContextMenu

In diagram | Right-click on Table |Features | Constraints/Indexes |Right-click | Add New Constraint

KeyboardShortcuts

Click on Table: F9 > Constraints/Indexes:Ctrl+N

Create a Constraint

Step

Action

(c) Sparx Systems 2019 Page 182 of 335

Page 183: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

1 On the 'Constraints/Indexes' tab of the Columns andConstraints screen, a new constraint is automaticallycreated and assigned the default constraint name anda 'Type' of index.Overtype the constraint name with a name thatidentifies the constraint as a check constraint, suchas 'CHK_ColumnName' (the CHK_ prefix isoptional).

2 In the 'Type' field, change the value from 'index' to'check'.

3 In the 'Properties' panel for the Condition property,type the SQL statement that will be used as theCheck Condition; for example, column1 < 1000.If the condition is long, click on the button todisplay a SQL editor (with syntax highlighting).

Delete a Check Constraint

If you do not want to keep a check constraint, either:

Right-click on it in the list and select 'Delete constraint·

<name>', or

Click on the item and press Ctrl+D·

The constraint is immediately deleted.

(c) Sparx Systems 2019 Page 183 of 335

Page 184: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Notes

Any columns assigned to a check constraint are ignored·

(c) Sparx Systems 2019 Page 184 of 335

Page 185: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Table Triggers

A Table trigger is SQL or code that is automaticallyexecuted as a result of data being modified in a databaseTable. Triggers are highly customizable and can be used inmany different ways; for example, they could be used tostop certain database activities from being performed duringbusiness hours, or to provide validation or perform deletionsin secondary Tables when a record in the primary Table isdeleted.

In Enterprise Architect, a Table trigger is modeled as astereotyped operation and managed using the Table's'Constraints' screen.

Access

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on Table name >Constraints/Indexes | Right-click | AddNew Constraint

ContextMenu

In diagram | Right-click on Table |Features | Constraints/Indexes |Right-click | Add New Constraint

Keyboard Click on Table: F9 > Constraints/Indexes:

(c) Sparx Systems 2019 Page 185 of 335

Page 186: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Shortcuts Ctrl+N

Create a Table Trigger

Step

Action

1 On the 'Constraints/Indexes' tab, a new constraint isautomatically created and assigned the defaultconstraint name and a 'Type' of index.Overtype the constraint name with a name thatidentifies the constraint as a trigger, such asTRG_OnCustomerUpdate. (The TRG_ prefix isoptional.)

2 In the 'Type' field, change the value from 'index' to'trigger'.

3 In the 'Properties' panel for the Statement property,type in the complete SQL statement (includingCREATE TRIGGER) that will define the Trigger.If the condition is long, click on the button todisplay a SQL editor (with syntax highlighting).

4 The properties Trigger Time and Trigger Event arecurrently information-only values and are not used in

(c) Sparx Systems 2019 Page 186 of 335

Page 187: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DDL generation.

Delete a Table Trigger

If you do not want to keep a trigger, either:

Right-click on it in the list and select 'Delete constraint·

<name>', or

Click on the item and press Ctrl+D·

The trigger is immediately deleted.

Notes

Any columns assigned to table triggers are ignored·

(c) Sparx Systems 2019 Page 187 of 335

Page 188: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Views

A Database View represents the results of a pre-definedquery. Unlike a Table, a View is dynamically derived fromdata in one or more Tables (or other Views). EnterpriseArchitect supports the definition of Views both with andwithout this statement:

"Create View {viewName} As" statement

The system will automatically add it dynamically (ifmissing) whenever DDL generation is performed. Theadvantage of not defining this statement is that when a viewobject is renamed the 'View Definition' property does nothave to be manually updated.

You can create a Database View either:

Within the Database Builder or·

By dragging the 'View' icon from the Data Modeling·

Toolbox onto a diagram

Add a Database View with the DatabaseBuilder

Step

Action

1 Open the Database Builder.

(c) Sparx Systems 2019 Page 188 of 335

Page 189: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

2 Load or create a Data model.

3 Right-click on the 'Views' Package and select 'AddNew View'.

4 Overtype the default name with the appropriatename for the View, and press the Enter key.

5 Double-click on the new View, or right-click on itand select 'SQL Object Properties'.The 'SQL Object Editor' dialog displays.

Add a Database View to a diagram

Step

Action

1 Open your Data Modeling diagram and, if necessary,display the 'Data Modeling' page of the DiagramToolbox (click on to display the 'Find ToolboxItem' dialog and specify 'Data Modeling').

2 Drag the 'View' icon onto the diagram.

This generates the View element:

(c) Sparx Systems 2019 Page 189 of 335

Page 190: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

3 Right-click on the new View 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 ofSQL-based database objects (Views, Procedures, Functionsand Sequences); it helps the data modeler manage thevarious properties of the SQL-based object.

Option Action

Database If it has already been set, the defaultdatabase type displays.If the default has not been set, or youwant to change the database type for thisView, click on the drop-down arrow andselect the target DBMS to model.

Dependencies

A list of objects that the current objectdepends on. The 'Dependencies' listshows:

(c) Sparx Systems 2019 Page 190 of 335

Page 191: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Each Depends connector between this·

View and another Table or ViewAny object names (specified as a CSV·

list) in the 'parents' Tagged Values

Notes If necessary, type in a comment on thecurrent View.

Definition Type the full SQL View definition. Forreleases of Enterprise Architect up to12.1 (Build 1227), this must include theCREATE_VIEW syntax as appropriatefor the target DBMS (for later versionsthis is not needed). For example: CREATE VIEW 'MyViewName' AS [view definition]

The code editor provides Intelli-sense forbasic SQL keywords, functions andnames of all objects in the current datamodel.

(c) Sparx Systems 2019 Page 191 of 335

Page 192: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Procedures

Database Procedures (sometimes referred to as StoredProcedures or Procs) are subroutines that can contain one ormore SQL statements that perform a specific task. They canbe used for data validation, access control, or to reducenetwork traffic between clients and the DBMS servers.Extensive and complex business logic can be embedded intothe subroutine, thereby offering better performance.

Database Procedures are similar to Database Functions. Themajor difference is the way in which they are invoked -Database Functions can be used in the same way as for anyother expression within SQL statements, whereas DatabaseProcedures must be invoked using the CALL or EXECstatement, depending on the DBMS.

In Enterprise Architect, Database Procedures can bemodeled 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 beingproduced. The main difference is visual - by having severalOperations in one container, you have fewer elements andless clutter on the diagram.

Individual objects

Database Procedures modeled as individual objects are

(c) Sparx Systems 2019 Page 192 of 335

Page 193: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

UML Classes with the stereotype «procedure»; you createthese either:

Within the Database Builder or·

By dragging the 'Procedure' icon from the Data Modeling·

Toolbox onto a diagram

Add a Database Procedure using theDatabase Builder

Step

Action

1 Open the Database Builder.

2 Load or create a Data model.

3 Right-click on the Procedures Package and select'Add New Procedure'.

4 Overtype the default name with the appropriatename for the Procedure, and press the Enter key.

5 Double-click on the new Procedure, or right-click onit and select 'SQL Object Properties'.The SQL Object Editor screen displays.

(c) Sparx Systems 2019 Page 193 of 335

Page 194: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Add a Database Procedure to a diagram

Step

Action

1 Open your Data Modeling diagram and, if necessary,display the 'Data Modeling' page of the DiagramToolbox (click on to display the 'Find ToolboxItem' dialog and specify 'Data Modeling').

2 Drag the 'Procedure' icon onto the diagram.

This generates the Procedure element:

3 Right-click on the new Procedure 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

(c) Sparx Systems 2019 Page 194 of 335

Page 195: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

SQL-based database objects (Views, Procedures andFunctions); it helps you to manage the various properties ofthe SQL-based object.

Option Action

Database If it has already been set, the defaultdatabase type displays.If the default has not been set, or youwant to change the database type for thisProcedure, click on the drop-down arrowand select the target DBMS to model.

Notes If necessary, type in a comment on thecurrent Procedure.

Definition Type the full SQL Procedure definition,including the CREATE PROCEDUREsyntax.The code editor provides Intelli-sense forbasic SQL keywords, functions andnames of all objects in the current datamodel.

Operations in a Container

Database Procedures modeled as operations have a

(c) Sparx Systems 2019 Page 195 of 335

Page 196: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

container object, this being a UML Class with the stereotype«procedures» (with an 's' on the end). Each DatabaseProcedure is an operation with the stereotype «proc». Thesystem provides a dedicated Maintenance window throughwhich you can easily manage the Database Proceduresdefined as operations.

(c) Sparx Systems 2019 Page 196 of 335

Page 197: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Functions

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

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

In Enterprise Architect, Database Functions can be modeledin 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 beingproduced. The main difference is visual - by having severalOperations in one container, you have fewer elements andless clutter on the diagram.

Individual objects

Database Functions modeled as individual objects are UMLClasses with the stereotype «function»; you create theseeither:

Within the Database Builder or·

By dragging the Function icon from the Data Modeling·

Toolbox onto a diagram

(c) Sparx Systems 2019 Page 197 of 335

Page 198: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Add a Database Function using the DatabaseBuilder

Step

Action

1 Open 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 appropriatename for the Function, and press the Enter key.

5 Double-click on the new Function, or right-click onit and select 'SQL Object Properties'.The SQL Object Editor screen displays.

Add a Database Function to a diagram

(c) Sparx Systems 2019 Page 198 of 335

Page 199: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Step

Action

1 Open your Data Modeling diagram and, if necessary,display the 'Data Modeling' page of the DiagramToolbox (click on to display the 'Find ToolboxItem' 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 ofSQL-based database objects (Views, Procedures andFunctions); it helps you to manage the various properties ofthe SQL-based object.

Option Action

(c) Sparx Systems 2019 Page 199 of 335

Page 200: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database If it has already been set, the defaultdatabase type displays.If the default has not been set, or youwant to change the database type for thisFunction, click on the drop-down arrowand select the target DBMS to model.

Notes If necessary, type in a comment on thecurrent Function.

Definition Type the full SQL Function definitionincluding the CREATE FUNCTIONsyntax.The code editor provides Intelli-sense forbasic SQL keywords, functions andnames of all objects in the current datamodel.

Operations in a Container

Database Functions modeled as operations have a containerobject, this being a UML Class with the stereotype«functions» (with an 's' on the end). Each Function is anoperation with the stereotype «func». The system provides adedicated Maintenance window through which you caneasily manage the Database Functions stored as operations.

(c) Sparx Systems 2019 Page 200 of 335

Page 201: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

(c) Sparx Systems 2019 Page 201 of 335

Page 202: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Sequences

Sequences are a feature that some DBMS productsimplement to provide users with a mechanism to generateunique values - the Sequence ensures that each call to itreturns a unique value. This is particularly important whenthe Sequence's result is used as a Primary Key. These can begenerated with a schema for loading onto the DBMS server.

Sequences are provided so that database users are not forcedto implement their own unique value generator. Not allDBMS products support Sequences; those that do notinstead provide functionality for columns to be initializedwith an incrementing value.

In Enterprise Architect, Sequences can be modeled in one oftwo ways:

As individual objects (the default method) or·

As Operations in a container·

Functionally the two methods result in the same DDL beingproduced. The main difference is visual - by having severalOperations in one container, you have fewer elements andless clutter on the diagram.

Individual objects

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

Within the Database Builder or·

(c) Sparx Systems 2019 Page 202 of 335

Page 203: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

By dragging the 'Sequence' icon from the 'Data Modeling'·

Toolbox pages onto a diagram

Add a Database Sequence using theDatabase Builder

Step

Action

1 Open 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 appropriatename for the Sequence, and press the Enter key.

5 Double-click on the new Sequence, or right-click onit and select 'SQL Object Properties'.The 'SQL Object Editor' dialog displays.

Add a Database Sequence to a diagram

(c) Sparx Systems 2019 Page 203 of 335

Page 204: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Step

Action

1 Open your Data Modeling diagram and, if necessary,display the 'Data Modeling' page of the DiagramToolbox (click on to display the 'Find ToolboxItem' 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 ofSQL-based database objects (Views, Procedures andFunctions); it helps you to manage the various properties ofthe SQL-based object.

(c) Sparx Systems 2019 Page 204 of 335

Page 205: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Option Action

Database If it has already been set, the defaultdatabase type displays.If the default has not been set, or youwant to change the database type for thisSequence, click on the drop-down arrowand select the target DBMS to model.

Notes If necessary, type in a comment on thecurrent Sequence.

Definition Type the full SQL Sequence definitionincluding the CREATE SEQUENCEsyntax.The code editor provides Intelli-sense forbasic SQL keywords, functions andnames of all objects in the current datamodel.

Operations in a Container

Database Sequences modeled as operations have a containerobject, this being a UML Class with the stereotype«sequences» (with an 's' on the end). Each Sequence is anoperation with the stereotype «sequ». The system provides a

(c) Sparx Systems 2019 Page 205 of 335

Page 206: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

dedicated Maintenance window through which the modelercan easily manage the Sequences defined as operations.

(c) Sparx Systems 2019 Page 206 of 335

Page 207: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database SQL Queries

An SQL Query object provides a convenient mechanism forstoring an SQL Statement in the repository, for repeatedexecution on live database(s).

An SQL Query element is represented in the UML DataModeling Profile as an Artifact element with the stereotype<<sqlquery>>. You can create these elements either:

Within the Database Builder or·

By dragging the 'SQL Query' icon from the 'Data·

Modeling' Toolbox pages onto a diagram

Add a Database SQL Query using theDatabase Builder

Step

Action

1 Open the Database Builder.

2 Load or create a Data model.

3 Right-click on the Queries Package and select 'AddNew SQL Query'.

4 Overtype the default name with the appropriate

(c) Sparx Systems 2019 Page 207 of 335

Page 208: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

name for the Query, and press the Enter key.

5 Right-click on the new element and select 'Edit'.The 'SQL Scratch Pad' tab displays, on which youcan create the SQL Query statement.

6 When you have finished the SQL statement, click onthe Save to SQL Query button in the toolbar to savethe changes to the query element.

Add a Database Function to a diagram

Step

Action

1 Open your Data Modeling diagram and, if necessary,display the 'Data Modeling' page of the DiagramToolbox (click on to display the 'Find ToolboxItem' dialog and specify 'Data Modeling').

2 Drag the 'SQL Query' icon onto the diagram.

This generates the SQL Query Artifact element:

(c) Sparx Systems 2019 Page 208 of 335

Page 209: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

3 Double-click on the new element and update theelement name and other properties as necessary.To edit the element's SQL statement, access theDatabase Builder, click on the element in theQueries Package and edit the Query on the 'SQLScratch Pad' tab.

(c) Sparx Systems 2019 Page 209 of 335

Page 210: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Create Operation Containers

Whilst the default method of modeling Database Functions,Procedures and Sequences is to create them as individualelements, you can also represent a number of each type ofstructure as operations of a container Class. You add astereotype to the Class, which specifies:

The type of data structure the Class will contain·

The stereotype that will be automatically assigned to each·

operation created in the Class (for a given data structure,the operations can only be of one stereotype)

Access

Toolbox Drag the 'Class' icon onto the diagram

Create the Container Class

Step

Action

1 Right-click on the Class element on the diagram andselect the 'Design > Element > Editors > Properties

(c) Sparx Systems 2019 Page 210 of 335

Page 211: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Dialog' option.The element 'Properties' dialog displays, showing the'General' tab.

2 In the 'Name' field, type an appropriate name for thecontainer.

3 In the 'Stereotype' field (in the table at the right edgeof the dialog) type:

'functions' for a Database Function container·

'procedures' for a Stored Procedure container·

'sequences' for a Sequence container·

The 's' at the end of the stereotype name is important.

4 Click on the OK button to save the setting and closethe dialog.

Create database structures as operations ofthe Class

Step

Action

Click on the Class element on the diagram and press

(c) Sparx Systems 2019 Page 211 of 335

Page 212: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

1 F10.The 'Database <Structure> container: <Classname>'dialog displays.

2 Right-click in the 'Functions' ('Procedures' or'Sequences') list and select 'Add New <structure>'.

3 In the 'Name' field, type an appropriate name for theoperation, such as:

fn_WorkDays·

sp_AddOrder or·

seq_AddressID·

4 In the 'Notes' field type any supporting comments orexplanation of the operation.In the 'Function definition' field (or 'Proceduredefinition', or 'Sequence definition') type theappropriate text.

5 Repeat steps 2 to 4 until you have defined all theoperations you require.

6 Click on the list and then on the Close button toclose the dialog and show the operations within theClass on the diagram and in the Browser window.

(c) Sparx Systems 2019 Page 212 of 335

Page 213: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Oracle Packages

Oracle Packages are database objects that are unique to theOracle DBMS. They are containers that grouplogically-related objects into a single definition. Packageshave two parts - a specification and a body. The:

Specification section declares the various components·

Body section provides the full definitions of the·

components

The Package components can consist of Types, Variables,Constants, Exceptions, Cursors and subprograms.

In Enterprise Architect, an Oracle Package is modeled as aUML Class with a stereotype of <<package>>. It has twooperations:

Specification·

Body·

For each of these operations the complete SQL syntax iscontained in the 'Initial Code' field.

Create an Oracle Package

Step

Action

1 Add a Class element to your data model.

(c) Sparx Systems 2019 Page 213 of 335

Page 214: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

2 Open the Properties window for the element and, inthe 'Stereotype' field, type the value 'Package'.

3 Click on the element and press F10, to display theFeatures window at the 'Operations' page.For the Package specification, press Ctrl+N andcreate an operation with the name 'Specification' andwith no return type.

4 The Properties window displays the properties of theoperation; click on the 'Code' tab and type the entirePackage specification into the text panel.

5 Return to the Features window at the 'Operations'page and, for the Package body, press Ctrl+N andcreate an operation with the name 'Body' and noreturn type.

6 On the Properties window, click on the 'Code' taband type the entire Package body code into the textpanel.

(c) Sparx Systems 2019 Page 214 of 335

Page 215: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Connections

A Database Connection object provides a convenient way ofstoring the connection details of a live database. EnterpriseArchitect supports the definition of three differentconnection types:

MS Access·

Firebird, and·

ODBC·

For the first two you only have to specify the full path to thedatabase files; for connections of type ODBC you areprompted to select from the list of pre-defined DSNs onyour machine.

Create a Database Connection element

A Database Connection element is represented in the UMLData Modeling Profile as an Artifact element with thestereotype <<database connection>>. You create theseeither:

Within the Database Builder or·

By dragging the 'Database Connection' icon from the·

'Data Modeling' Toolbox pages onto a diagram

Add a Database Connection using the

(c) Sparx Systems 2019 Page 215 of 335

Page 216: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Builder

Step

Action

1 Open the Database Builder.

2 Load or create a Data model.

3 Right-click on the Connections Package and select'Add New DB Connection'.

4 Overtype the default name with the appropriatename for the Connection, and press the Enter key.

5 Double-click on the new Connection, or right-clickon it and select 'DB Connection Properties'.The 'Database Connection Properties' dialogdisplays.

Add a Database Connection to a diagram

Step

Action

(c) Sparx Systems 2019 Page 216 of 335

Page 217: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

1 Open your Data Modeling diagram and, if necessary,display the 'Data Modeling' page of the DiagramToolbox (click on to display the 'Find ToolboxItem' dialog and specify 'Data Modeling').

2 Drag the 'Database Connection' icon onto thediagram.

This generates the Database Connection element:

3 Double-click on the new element.The 'Database Connection Properties' dialogdisplays.

Database Connection Properties

Option Action

DBMS Type Click on the radio button for theappropriate type:

MS Access file based database·

Firebird file based database, or·

ODBC based database·

The 'Save Password?' checkbox is only

(c) Sparx Systems 2019 Page 217 of 335

Page 218: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

enabled for ODBC connection types, andindicates if Enterprise Architect shouldstore the password for the selected ODBCDSN. The checkbox defaults to selected;that is, passwords are saved. While allconnection passwords are encryptedbefore being saved, there can beoccasions when data modelers want torestrict access to only users that have therequired permissions.

Filename/DSN

If you have selected a 'DBMS Type' ofMS Access or Firebird, type in or browsefor the location and name of a physicalfile. If the file does not already exist itwill be created.If you have selected a 'DBMS Type' ofODBC, type in or select a defined ODBCDSN. Depending on the DBMS, youmight be prompted for other details suchas server, connection user ID andpassword.

OtherSchemas

This field acts as a schema filter to limitthe number of objects returned byenquiries made against the ODBCconnection. Entering a value in this fieldis particularly important for Oracledatabases to reduce the time it takes for

(c) Sparx Systems 2019 Page 218 of 335

Page 219: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

making connections to the database, dueto the large number of system objects.If you need to enter multiple schemas tobe filtered on, separate them withcommas.

OK Click on this button to save the changesyou have made.

Delete connection

If a connection is no longer required, you can delete it as forany other element from the Database Builder, the Browserwindow or a diagram. Right-click on the element and selectthe corresponding 'Delete <element name>' option.

Notes

It is advisable that when working in a team environment·

(that is, multiple users sharing a single EnterpriseArchitect repository) all Database Connection objects aredefined as 'DSN-less' so that a Database Connectionobject can be shared between all users

The DBMS type of a Database Connection object cannot·

(c) Sparx Systems 2019 Page 219 of 335

Page 220: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

be changed once the initial selection has been saved

(c) Sparx Systems 2019 Page 220 of 335

Page 221: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Manage DBMS Options

Using the 'Manage DBMS Options' dialog, you can quicklychange the DBMS Type and/or Owner of an individualdatabase object or several objects within an individualPackage or Package hierarchy. You can also create bulkForeign Key Indexes on all Foreign Keys that do not alreadyhave an index.

Access

Ribbon Design > Model > Manage > DBMSOptionsDevelop > Data Modeling > DatabaseBuilder > Right-click on the requireddatabase | Load | right-click on the rootnode | Manage DBMS Options

Options

Option Action

Package Displays the name of the Package in the

(c) Sparx Systems 2019 Page 221 of 335

Page 222: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Browser window that you are currentlyworking on. If necessary, click on the button and select a different Packageusing the Navigator window (a version ofthe 'Find Package' dialog).

IncludeObjects inChildPackages

Select this checkbox to include all thedatabase objects in all sub-Packages.Selecting or deselecting this control willimmediately refresh the list of objects.

List ofObjects

This list control will display the names ofall objects in the current Package (orPackage hierarchy) along with itsallocated DBMS and owner. By defaultevery object has its checkbox selectedwhenever the list is loaded or refreshed.

All Click on this button to select alldeselected checkboxes in the 'List ofObjects'.

None Click on this button to deselect allselected checkboxes in the 'List ofObjects'.

ChangeDBMS

Select this checkbox if you want tochange the assigned DBMS of objects inthe Package. Provide values for the

(c) Sparx Systems 2019 Page 222 of 335

Page 223: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

'Current DBMS' and 'New DBMS' fieldsin order to continue. The 'Current DBMS'drop-down list includes the option'<All>', which changes several differentDBMS values all to the new value.Note: When performing this function, thedata types of all Table columns areautomatically converted to the closestmatch for the selected DBMS; therefore,you should perform a manual review ofthe data types after running the process.

ChangeOwner

Select this checkbox if you want tochange the Owner of the selected objectsin the 'List of Objects'. Specify thecurrent Owner in the 'Current Owner'field in order to continue. Leaving the'New Owner' field blank will remove theOwner property of all selected objects.

CreateIndexes onForeign Keys

Select this checkbox to create an index onall Foreign Keys in the Package, whereone does not already exist.

OK Click on this button to start the updateprocess. The button is disabled unless atleast one object in the list and one of theupdate options are selected.

(c) Sparx Systems 2019 Page 223 of 335

Page 224: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

(c) Sparx Systems 2019 Page 224 of 335

Page 225: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Data Types

Every Table column that you define in your data model hasa data type assigned that specifies the type of informationthat can be stored by the column. The available datatypesfor a column are dependent on the selected DBMS for theTable, because each DBMS supports its own list ofdatatypes. Whilst each DBMS supports the same basictypes, such as string, whole or decimal numbers, eachDBMS calls them by different names and have differentproperties.

Each Enterprise Architect repository contains the definitionsof the core datatypes for a number of standard DBMSproducts. However, since data types vary from one DBMSproduct to another, and from one version of a product toanother, Enterprise Architect provides you with tools to:

Define new data types for a new version of your DBMS·

product

Define data types for a new, non-standard database·

product

Automatically convert data types from one defined·

DBMS product to another

Import and export datatypes between repositories·

(c) Sparx Systems 2019 Page 225 of 335

Page 226: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Map Data Types Between DBMSProducts

Whilst modeling physical data models provides a great dealof detail about all Tables and their columns, this level ofdetail does make it harder to change the target technology orplatform. For example, after reverse engineering yourdatabase into a physical data model, you must remap thedata types before generating the schema for the new DBMSproduct.

Enterprise Architect provides a set of default mappings forstandard, supported DBMS products, to help you automatethe conversion process.

However, you might want to customize the defaultmappings to suit your specific project requirements, orwhere the mapping of one data type to another is notcurrently defined. For example, in your migration from oneDBMS platform to another, one of the platforms might benon-standard or otherwise not supported by EnterpriseArchitect.

Access

Ribbon Configure > Reference Data > Settings >Database Datatypes : Datatype Map

(c) Sparx Systems 2019 Page 226 of 335

Page 227: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Data Types Mapping

Repeat this process for each of the data types to map.

Once you are satisfied with the data type mappings, you canconvert either individual Tables or an entire Package ofTables to the new target DBMS product.

Field/Button Action

From ProductName

Click on the drop-down arrow and selectthe DBMS product to map data typesfrom.

DefinedDatatypes forDatabases

Displays all the defined data types for theproduct and, where appropriate, theirsizes and values.Click on the data type to map - this musthave a defined size unit and value.The 'Datatype' and 'Common Type' fieldsunder the 'From Product Name' fielddisplay this data type.

To ProductName

Click on the drop-down arrow and selectthe DBMS product to map data types to.The 'Datatype' and 'Common Type' fieldsunder this field display the valuescorresponding to those in the fields for

(c) Sparx Systems 2019 Page 227 of 335

Page 228: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

the 'From' product.

Size Click on the radio button for theappropriate size unit and type the defaultvalues in the corresponding data fields.

Save Click on this button to save the mapping.

(c) Sparx Systems 2019 Page 228 of 335

Page 229: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DBMS Product Conversion for aPackage

Using the DBMS Package mapper, you can automaticallyconvert a Package of database Tables from one supportedDBMS type to another supported DBMS type. You can alsochange the DBMS type for individual Tables.

If one of the DBMS types is non-standard or otherwise notsupported by Enterprise Architect, you should check that themapping of datatypes from one DBMS type to the other hasbeen defined.

Access

Ribbon Design > Model > Manage > DBMSOptionsDevelop > Data Modeling > DatabaseBuilder > Right-click on the requireddatabase | Load | right-click on the rootnode | Manage DBMS Options

Map the DBMS data types of a Package tothe data types of another DBMS

(c) Sparx Systems 2019 Page 229 of 335

Page 230: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Field/Button Action

IncludeObjects inChildPackages

If there are objects in child Packages thatalso require changing, select thecheckbox.

ChangeDBMS

Select the checkbox.

CurrentDBMS

Click on the drop-down arrow and selectthe current DBMS.

New DBMS Click on the drop-down arrow and selectthe target DBMS.

OK Click on this button to map all Tables inthe selected Packages to the new DBMS.

(c) Sparx Systems 2019 Page 230 of 335

Page 231: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Data Type Conversion For a Table

Once a database schema has been set up on an EnterpriseArchitect diagram (either by importing through ODBC ormanually setting up the Tables), the DBMS can be changedto another type and the column datatypes are mappedaccordingly for each Table.

You might use this procedure if you have copied a smallnumber of Tables into the project from elsewhere, but if youhave many Tables you can also convert all of them at oncewithin their parent Package.

If one of the DBMS types is non-standard or otherwise notsupported by Enterprise Architect, you should check that themapping of datatypes from one DBMS type to the other hasbeen defined.

Map the DBMS type of a Table to anotherDBMS type

Step

Action

1 Double-click on the Table element in a diagram.The Table 'Properties' dialog displays, with the'Database' field showing the current DBMS for thisTable.

(c) Sparx Systems 2019 Page 231 of 335

Page 232: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

2 To map the datatypes to another DBMS, click on the'Database' drop-down arrow and select the targetDBMS.

3 Click on the Apply button.The datatypes are converted to match those of thenew DBMS, and these are reflected in any DDLgenerated from this Table.

(c) Sparx Systems 2019 Page 232 of 335

Page 233: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database Datatypes

Using Enterprise Architect's 'Database Datatypes' dialog,you can add to the set of data types that are available for aparticular DBMS. You can:

Identify the DBMS in use and, if required, set this as the·

model default

Include any new data types that are supported by later·

versions of the DBMS and not yet included withEnterprise Architect

Remove any previously-added data types that are no·

longer relevant

Add a new DBMS product and its built-in data types if,·

for example, you want to create a physical data model fora DBMS product that is not yet supported natively byEnterprise Architect

Access

Ribbon Configure > Reference Data > Settings >Database Datatypes

Manage Datatypes

(c) Sparx Systems 2019 Page 233 of 335

Page 234: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

You can transport these database data types betweenEnterprise Architect models using the 'Export ReferenceData' and 'Import Reference Data' options.

Field/Button Action

ProductName

Click on the drop-down arrow and selectan existing DBMS.Once a product is selected, all defineddata types will be shown in the 'DefinedDatatypes for Databases' list.

Add Product If your DBMS is not listed, click on thisbutton to add it.An 'Input' prompt displays, in which youtype the DBMS name; click on the OKbutton to add the name to the drop-downlist.

Set asDefault

Select the checkbox to set the selectedDBMS as the default for your databaseengineering and modeling.Once you set the default database, whenyou create any new Table elements theDatabase type is automatically pre-set tothis default.You can also set the default database typethrough the Code Generation Toolbar.

(c) Sparx Systems 2019 Page 234 of 335

Page 235: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

New Click on this button to clear the data typefields on the dialog so that you can defineanother data type.

Datatype Type a name for the data type.

Size Select the appropriate radio button for therequired size and, if appropriate, specifythe default and maximum values:

None – for data types without a size·

component, such as INTLength – for data types that require a·

single size that defines the Length,such as VARCHAR(10)Precision & Scale – for data types that·

require two numeric values, such asDECIMAL(18,2)

CommonType

Click on the drop-down arrow and selectthe generic name of each data type. Thisis used when a Table's DBMS is changed.

Save Click on the button to immediately saveyour data type to the repository (and addit to the 'Defined Datatypes forDatabases' list).

Defined This panel lists the data types currently

(c) Sparx Systems 2019 Page 235 of 335

Page 236: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Datatypes forDatabases

defined for the selected DBMS, eithersystem-supplied or user-defined.

Delete Select a data type in the 'DefinedDatatypes for Databases' list and click onthis button to remove the data type.

DatatypeMap

If you have changed the DBMS ortechnology for which you have definedthe data types from or to an unsupportedDBMS type, click on this button to definehow to automatically remap the datatypes to your new DBMS or technology.

(c) Sparx Systems 2019 Page 236 of 335

Page 237: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

MySQL Data Types

MySQL supports the ENUM and SET data types, whichmust be added to your Enterprise Architect model beforeyou can use them as the types for columns.

Access

Ribbon Configure > Reference Data > Settings >Database Datatypes

Add the ENUM and SET data types forMySQL

When using these data types later in a column's 'Initial' field,type the values as a comma-separated list, in the format:

('one','two','three')

If one value is the default, use the format:

('one','two','three') default 'three'

Step

Action

(c) Sparx Systems 2019 Page 237 of 335

Page 238: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

1 The 'Database Datatypes' dialog displays.

2 In the 'Product Name' field select 'MySQL'.

3 Add the data types ENUM and SET.

(c) Sparx Systems 2019 Page 238 of 335

Page 239: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Oracle Data Types

The Oracle data types NUMBER and VARCHAR haveadditional properties that you can model.

Access

Ribbon Configure > Reference Data > Settings >Database Datatypes

Data Types

Data Type Detail

NUMBER The NUMBER data type requiresprecision and scale properties.The 'Precision' and 'Scale' fields aredisplayed on the 'Attributes' page of theFeatures window when the data type isset to NUMBER; if you enter informationinto these fields, it is displayed on yourdiagrams.For example:

(c) Sparx Systems 2019 Page 239 of 335

Page 240: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

create NUMBER by setting 'Precision'= 0 and 'Scale' = 0 create NUMBER(8) by setting'Precision' = 8 and 'Scale' = 0 create NUMBER(8,2) by setting'Precision' = 8 and 'Scale' = 2

VARCHAR Oracle VARCHAR2(15 CHAR) andVARCHAR2(50 BYTE) data types canbe created by adding the Tagged ValueLengthType with the value CHAR orBYTE.

(c) Sparx Systems 2019 Page 240 of 335

Page 241: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Data Modeling Settings

Enterprise Architect provides data modeling settings thatcan be used to configure the way database systems aremodeled in Enterprise Architect. These include the ability todefine the data modeling language, which determines theway that connectors are displayed, and settings to configurethe naming of Primary Keys, Foreign Keys and Indexes.The settings are global and will affect any EnterpriseArchitect repository.

Access

Ribbon Start > Desktop > Preferences >Preferences > Source Code Engineering >Code Editors > DDL

DDL Editor

In this field you browse for the full execution file path andname of an external program that Enterprise Architectshould use to open files that are created by its GenerateDDL functionality. If you leave this field empty, EnterpriseArchitect uses the default code editor.

(c) Sparx Systems 2019 Page 241 of 335

Page 242: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Default Database

In this field you select the DBMS that will be automaticallyassigned to database objects that are created outside a DataModel workspace (see the Create a Data Model from ModelPattern Help topic).

MySQL Storage

In this field you select the default storage engine to beassigned to MySQL Tables; from MySQL v 5.5 onwards thedefault value is InnoDB.

(c) Sparx Systems 2019 Page 242 of 335

Page 243: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Data Modeling Notations

Enterprise Architect supports numerous settings related todata modeling that can influence how database objects arerepresented on diagrams. These settings, and how they canaffect the representation of database objects, are describedhere.

Settings

Setting Detail

StereotypeIcons

Access: 'Design > Diagram > Manage >Properties > Elements : Use StereotypeIcons'Default Value: TrueEnterprise Architect provides adiagram-level setting for the display ofstereotyped objects. When the checkboxis selected, database objects on thediagram are displayed with an iconrepresenting their stereotype instead ofthe stereotype name.

(c) Sparx Systems 2019 Page 243 of 335

Page 244: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Show DataModelOwner

Access: 'Design > Diagram > Manage >Properties > Elements : Show DataModel Owner'Default Value: TrueThe system provides a diagram-levelsetting for the display of Owners. Whenthe checkbox is selected, database objectson the current diagram will be displayedwith their full name'{Owner.}ObjectName'.

ShowColumnDetails

Access: 'Design > Diagram > Manage >Properties > Features : Show AttributeDetail'Default Value: Name OnlyThe system provides a diagram-levelsetting for the display of Table columnnames and datatypes. The availableoptions are: 'Name Only' or 'Name andType'.

(c) Sparx Systems 2019 Page 244 of 335

Page 245: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

ShowInvolvedColumnDetails

Access: 'Design > Diagram > Manage >Properties > Features | Show ParameterDetail'Default Value: Type OnlyThe system provides a diagram-levelsetting for the display of columnsinvolved in a Table constraint. Theavailable options are: 'None', 'Type Only','Name Only' and 'Full Details'.In these examples, the Primary Key (PK)constraint 'PK_account' involves thecolumn 'accountID'.

(c) Sparx Systems 2019 Page 245 of 335

Page 246: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

ShowColumn

Access: Start > Desktop > Preferences >Preferences > Objects: Show

(c) Sparx Systems 2019 Page 246 of 335

Page 247: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Stereotype <<column>> stereotypeDefault Value: TrueEnterprise Architect provides aglobal-level setting that controls whetheror not the <<column>> stereotype isdisplayed above each Table's columns.You can therefore hide the stereotype ifyou prefer, considering that attributeswith a stereotype of <<column>> are theonly valid option for Tables.

ConnectorNotation

Access: 'Design > Diagram > Manage >Properties > Connectors : ConnectorNotation'Default Value: UML 2.1Enterprise Architect supports threediagram notations for data modeling:

UML 2.1 - the standard UML 2.1·

notation for connectors

(c) Sparx Systems 2019 Page 247 of 335

Page 248: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Information Engineering - the·

Information Engineering (IE)connection style

IDEF1X - the Integrated Definition·

Methods IDEF1X connection style

(These are the same three connectorsusing the different notations.) The defaultnotation for the Data Modeling diagramis 'Information Engineering', whilst thedefault notation for models created fromDatabase Engineering Patterns is'IDEF1X'.

(c) Sparx Systems 2019 Page 248 of 335

Page 249: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DDL Name Templates

At various times during the process of data modeling,Enterprise Architect is required to automatically generateTable constraints. The naming standard for these generatedconstraints is defined in and applied by the DDL NameTemplates, which you are free to change at any time. TheseName templates are defined at repository level, so wheneverthey are changed all users of the repository will use the newtemplates.

Access

Ribbon Configure > Model > Options > SourceCode Engineering : DDL NameTemplates

DDL Name Templates

Option Action

Primary Key Define the name template used whenPrimary Key constraints are created.

(c) Sparx Systems 2019 Page 249 of 335

Page 250: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

UniqueConstraint

Define the name template used whenUnique Constraints are created.

Foreign Key Define the name template used whenForeign Key constraints are created.

Foreign KeyIndex

Define the name template used whenForeign Key indexes are created.

Save Click on this button to save the nametemplate(s) you have defined.

Template Macros

These recognized macros will be replaced by name textduring the creation of a constraint name.

Macro Applies to

%tablename%

Primary KeyUnique ConstraintDescription: The string that is replaced bythe Table's name.

%columnnam The string that is replaced by the

(c) Sparx Systems 2019 Page 250 of 335

Page 251: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

e% constraint's column name(s).

%primarytablename%

Foreign KeyDescription: The string that is replaced bythe primary (parent) Table's name.

%foreigntablename%

The string that is replaced by the foreign(child) Table's name.

%foreignkeyname%

Foreign Key IndexDescription: The string that is replaced bythe Foreign Key name.

(c) Sparx Systems 2019 Page 251 of 335

Page 252: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Import Database Schema

The power of model-based engineering is the ability tovisualize, analyze and design all aspects of a system. Beingable to view the database schemas alongside other models ofa system provides great clarity and reduces the chance oferror. Enterprise Architect can reverse engineer a DBMSschema and its objects into a model under a number ofdifferent standards, including UML, InformationEngineering and IDEF 1X. A wide range of database objectsare supported including Tables, Views, Procedures,Functions and Sequences. Enterprise Architectcommunicates with the DBMS via ODBC, can import aschema via this connection, and can synchronize the modelwith the live database if it is changed.

Once the schema is in Enterprise Architect, the databaseobjects can be traced to other elements, ensuring theintegrity of design and architecture. When systems targetmultiple DBMSs, these can all be reverse engineered into amodel and elements and datatypes can be compared betweenthese models. The sophisticated reporting engine canproduce high quality documentation, including datadictionaries, diagrams and relationships back to othermodels such as architecture and information requirements,and ultimately to business goals and drivers.

Database schema information can be imported via theDatabase Builder or from the 'Develop' ribbon.

(c) Sparx Systems 2019 Page 252 of 335

Page 253: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Import Database Schema

Step

Action

1 Open the Database Builder (Develop > DataModeling > Database Builder)

2 Load or create a Data Model.

3 Right-click on the loaded Data Model in the·

Database Builder and select 'Import DB schemafrom ODBC' orFrom the ribbon select 'Develop > Data Modeling·

> Import'The 'Import DB Schema from ODBC source' dialogdisplays, showing the details of the current activedatabase connection.

The Import DB Schema from ODBC Sourcedialog

Option Description

(c) Sparx Systems 2019 Page 253 of 335

Page 254: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Database This field shows a description of thecurrent ODBC connection, in the format: dbms.database_server.database_nameIf necessary, click on the button and,on the 'Machine Data Source' tab of the'ODBC Select Data Source' dialog, selectan alternative ODBC connection.

Import to This field shows the target Package thatthe new objects will be saved to.If you want to specify a differentPackage, click on the button and selectan alternative Package.

Only includeobjects fromSchema(s)

If the database type supports multipleschemas (such as SQL Server, Oracle,PostgreSQL and DB2 Express) you canfilter objects to be retrieved from thedatabase by schema.The available schemas are automaticallylisted in this panel. Select the checkboxagainst each schema to include in theimport.(You can click on the All button to selectall the schemas, or the None button toclear all selected checkboxes.)If you suspect that the schema list mighthave changed since you loaded them, youcan refresh the list by clicking on the

(c) Sparx Systems 2019 Page 254 of 335

Page 255: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Reload Schemas button.

SQLWildcardFilter

The 'Name Filter:' field allows filtering ofobjects using SQL wildcards appropriateto the DBMS of the schema beingimported.For example, for Oracle:

LIKE 'A%' - list objects with a name·

starting with the letter 'A'NOT LIKE '%\_%' ESCAPE '\' - list·

objects with a name that does notinclude an underscore (_)IN ('TABLE1','TABLE2') - list objects·

with names that are included in theparenthesesNOT IN ('TABLE1','TABLE2') - list·

objects with names that are notincluded in the parentheses

Note that only one filter can be entered.You cannot add a second filter using theAND clause.Filtering is not available for MS Access

FilterOptions

The 'Filter Options' panel controls whatobject types and properties are read infrom the database schema. Valueschanged on this screen are saved to theregistry so that they are re-applied in the

(c) Sparx Systems 2019 Page 255 of 335

Page 256: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

next work session. The available optionsare briefly described here; select thecheckbox against an option to activate it.Tables

Tables - Select to import Tables·

Primary Keys - Select to import·

Primary Key definitions on TablesForeign Keys - Select to import·

Foreign Key definitions on TablesIndexes - Select to import Table·

IndexesUnique Constraints - Select to import·

Unique Constraint definitions onTablesCheck Constraints - Select to import·

Check Constraint definitions on TablesTable Triggers - Select to import·

Trigger definitions on TablesTable Properties - Select to import·

extended Table propertiesLength Semantics - Select to import·

length semantic definitions on Oraclestring columns

ObjectsViews - Select to import Views·

Procedures - Select to import·

Procedures - As Operations - Select to import

(c) Sparx Systems 2019 Page 256 of 335

Page 257: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Procedures as operations (methods) ofa single Class; you can view and edit them through theDatabase object container 'Properties'dialog (the option defaults to unselected, where the selecteditems are imported as separate Classes)Functions - Select to import Functions·

- As Operations - Select to importFunctions as operations (defaults tounselected)Sequences - Select to import Sequences·

- As Operations - Select to importSequences as operations (defaults tounselected)Package - Select to import Oracle·

PackagesAdvanced

System Objects - Select to import·

system Tables, Views and other systemobjects

Warning: With the 'As Operations'option for Procedures, Functions andSequences, if objects have been importedunder one setting (selected or unselected)and then you change the setting andimport further objects, the objectsimported under the first setting areremoved.

(c) Sparx Systems 2019 Page 257 of 335

Page 258: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Synchronization

Select the appropriate radio button toindicate whether the existing Classes areto be updated, or the database objectsimported as new objects.If you select the 'Synchronize existingclasses' option, also select the appropriatecheckboxes to determine whether modelcomments, column default values and/orTable constraints are to be retained oroverwritten with the comments, valuesand constraints of the imported objects.

Import To Select the appropriate radio button toindicate whether to update the Packageand currently-open data model diagrams,or just the Package.If no diagrams are open, the 'PackageOnly' radio button defaults to selectedand the options are disabled; if the opendiagrams are in the selected Package, youcan select either option.

Import Click on this button to start the import.The 'Select Database Objects to Import'dialog displays, listing all the databaseobjects found that match the selectioncriteria.Select the checkbox against each schema

(c) Sparx Systems 2019 Page 258 of 335

Page 259: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

(or object type) to automatically select allobjects in that group or to import eachobject individually.Click on the All button to select all typesand objects, or on the None button toclear all selected checkboxes.When you have selected all the objects toimport, click on the OK button tocontinue the import.

Notes

Enterprise Architect requires 32-bit ODBC drivers to·

connect to a repository through ODBC; to set up theODBC configuration on 64-bit clients, run the 32-bitODBC Data Source Administrator fromC:\Windows\SysWOW64\odbcad32.exe

The ODBC connection should use the ODBC driver·

available from the DBMS vendor, such as MySQL'sODBC driver for MySQL, and Oracle's ODBC driver forOracle; drivers provided by third-party vendors are notsupported, including the Microsoft ODBC driver forOracle

You can import a suitable ODBC driver for SQLite from·

http://www.ch-werner.de/sqliteodbc/

Due to the limitations of SQLite, round tripping of SQLite·

(c) Sparx Systems 2019 Page 259 of 335

Page 260: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Table and column comments is not possible; to retaincomments entered in an SQLite data model whenimporting from ODBC, deselect the 'Overwrite ObjectComments' checkbox in the 'Synchronization' section ofthe 'Import DB Schema from ODBC Source' dialog

If setting up an ODBC connection for reverse·

engineering, the default settings are sufficient

If you are importing database schema from an MS Access·

Jet 4.0 database, check that you have selected the 'Use Jet4.0' checkbox on the 'General' page of the 'Preferences'dialog (the 'Start > Desktop > Preferences > Preferences'ribbon option), otherwise the Jet 3.5 routines are loaded;you must restart Enterprise Architect after selecting thecheckbox

The list of Data Modeling Data types is defined as static·

data (in each repository), so depending on the age of yourrepository, there could be additional data types availablefrom the 'Data Modeling Data Types' section of the'Resources' page on the Sparx Systems website

(c) Sparx Systems 2019 Page 260 of 335

Page 261: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Generate DDL

Once a physical model has been defined and the objectsmodeled, Enterprise Architect can generate DatabaseDefinition Language (DDL) for a variety of objectsincluding database Tables, Views, Functions, Sequences andProcedures. This is a time saving mechanism and reducesthe errors that can be introduced by doing this by hand inother tools. Forward engineering is governed by a set oftemplates that define how UML constructs are converted tothe objects in the targeted DBMS. Standard templates areprovided for all supported DBMSs, and these can be editedto customize the way the DDL is generated. In the case thata DBMS is not supported out-of-the-box, a new set oftemplates can be created using the existing ones as a startingpoint and reference.

When forward engineering DDL, the output can be directedto a file (or a series of files, one for each object) or to theDDL execution engine. The execution engine allows you toexecute the DDL immediately, targeting a live databasethrough an ODBC connection. If you direct the output to afile you can execute the DDL against a live database later, atyour convenience. The generated files can be opened usingthe code editors, by selecting F12, Ctrl+E or Alt+7, allowingyou to view the DDL inside Enterprise Architect.

(c) Sparx Systems 2019 Page 261 of 335

Page 262: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Generate DDL For Objects

As you create your database model, you can generate theDDL for an individual object, a Package of objects or thecomplete data model. The only difference is how you invokethe generate DDL process.

Access

Open the Database Builder window, then use the contextmenu and select 'Generate DDL'.

Ribbon Develop > Data Modeling > DatabaseBuilder > Click on an object, Package orData Model node : Generate DDL

Generate Tab

Field/Button Action

Package Click on the button and browse for thePackage for which you want to generateDDL, using the Navigator window (aversion of the 'Find Package' dialog).

(c) Sparx Systems 2019 Page 262 of 335

Page 263: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

(Note: This field might not be displayedin all situations.)

Include AllChildPackages

Select this checkbox to include theobjects in sub-Packages in the 'SelectObjects to Generate' list.

Delete TargetFiles

When objects are generated to singlefiles, the full filename is stored with theobject, and displayed in the 'Target File'column of the 'Select Objects to Generate'list.Click on this button to remove all theexisting filenames and prompt for newones.

SelectObjects toGenerate

This field displays the list of objects thatDDL will be generated for, in thedisplayed order. If you need to changethis order to resolve object dependencies,click on an object to move and click onthe buttons to move that object oneposition up or down in the sequence.Select each object for which to generateDDL. Click on:

The All button to select every item·

The None button to clear all selections·

Each of several objects while you press·

Ctrl, to select a number of individual

(c) Sparx Systems 2019 Page 263 of 335

Page 264: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

objectsThe first and last objects in a block·

while you press Shift, to select everyobject in the block

SaveGeneratedOrder

If you have changed the order in whichthe objects are listed, select the checkboxto save the new sequence when you clickon the Generate button.

Refresh Reload the list of objects, restoring eachobject to their previous positions (ifobject positions have been changed).

Single File Select this radio button if you want tosave the generated DDL to a single file.Click on the button to browse for thefile path and file name.

Individualfile for eachtable

Select this radio button if you want tosave the DDL generated for each objectto a separate file.When you click on the Generate button,the system prompts you for the target filename for each object in turn (if it is notspecified already).

Generate toDDL

Select this radio button if you want tosave the DDL to the execution engine

(c) Sparx Systems 2019 Page 264 of 335

Page 265: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

ExecutionEngine

(the 'Execute DDL' tab of the DatabaseBuilder).The DDL Execution Engine provides thefacilities for executing the generated SQLscript and responding to errors inexecution immediately, without having tocreate an external file and load it intoanother tool.'Generate to DDL Execution Engine' isthe default option if the Database Builderis open.

Generate Click on this button to run the GenerateDDL process with the options you haveselected.

View If you have generated the DDL to a singleexternal file, click on this button to viewthe output.By default Enterprise Architect uses thedefault code editor. However, you candefine an alternative default DDL editoron the 'Preferences' dialog ('Start >Desktop > Preferences > Preferences >Source Code Engineering > Code Editors> DDL').

Close Click on this button to close the dialog. Ifyou did not generate the DDL, this button

(c) Sparx Systems 2019 Page 265 of 335

Page 266: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

also abandons DDL generation for theobject.

Options Tab

Set any of these flags to False if you do not want to take theaction they initiate.

Group Options

TableGenerationOptions

Tables - indicates that DDL for Tableelements should be generated (*)Primary keys - indicates that DDL forPrimary Keys should be generated ($)Foreign Keys - indicates that DDL forForeign Keys should be generated ($)Indexes - indicates that DDL for Indexesshould be generated ($)Unique Constraints - indicates that DDLfor Unique Constraints should begenerated ($)Check Constraints - indicates that DDLfor Check Constraints should begenerated ($)Table Triggers - indicates that DDL forTable Triggers should be generated ($)

(c) Sparx Systems 2019 Page 266 of 335

Page 267: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Table properties - indicates that DDLfor extended table properties should begenerated ($)Length Semantics - indicates that DDLfor Oracle Length Semantic should begenerated ($)

ObjectGenerationOptions

Views - indicates that DDL for Viewelements should be generated (*)Procedures - indicates that DDL forProcedure elements should be generated(*)Functions - indicates that DDL forFunction elements should be generated(*)Sequences - indicates that DDL forSequence elements should be generated(*)Packages - indicates that DDL for OraclePackages elements should be generated(*)

Formatting Include pre/post queries - indicates thatthe generated DDL should include theSQL statements defined in the'_PreStatements' and '_PostStatements'SQL QueriesInclude Owners - indicates that thegenerated DDL should include the

(c) Sparx Systems 2019 Page 267 of 335

Page 268: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

schema/owner of all elementsInclude Comments - indicates that thegenerated DDL should include anycommentsInclude Header Comments - indicatesthat the generated DDL should includeany header comments (#)Include Object Comments - indicatesthat the generated DDL should includeany object (such as Table or View)comments (#)Include Column Comments - indicatesthat the generated DDL should includeany columns comments (#)Generate DROP statements - indicatesthat the generated DDL should includethe DROP statement for objectsUse Database - indicates that thegenerated DDL should include a USEDatabase statementUse Alias - indicates that the generatedDDL makes use of any object or columnaliasesSeparate Constraint from Table -indicates that the generated DDL shoulddefine the creation of constraints asseparate statements from the Tabledefinition

(c) Sparx Systems 2019 Page 268 of 335

Page 269: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Include NULL in column definitions -indicates that the generated DDL shouldapply the NULL keyword to each columndefinition that is defined as nullable; thatis, columns with their 'NOT NULL' flagunchecked (this option only applies to theDBMSs that support the 'NULL' syntax)

Notes

(*) - options with this mark will be automatically set to·

True if you have specified to generate DDL for anindividual element of that type; that is, if you select aTable and your 'Generate Table' option is False,Enterprise Architect will change the option to True

($) - options with this mark will be disabled if the 'Tables'·

option is set to False

(#) - options with this mark will be disabled if the 'Include·

Comments' option is set to False

In the Corporate, Unified and Ultimate editions of·

Enterprise Architect, if security is enabled you must have'Generate Source Code and DDL' permission to generateDDL

For a PostgreSQL database, you must set the 'Sequences'·

option to True to enable auto increment columns to be

(c) Sparx Systems 2019 Page 269 of 335

Page 270: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

created

If generating Oracle sequences, you must always set the·

'Table Triggers' and 'Sequences' options to True, so that apre-insert trigger is generated to select the next sequencevalue to populate the column; also, in the columnproperties, set the 'AutoNum' property to True

You can edit the DDL templates that the system uses to·

generate the DDL; these are stored at the repository levelso that all other users of the same repository willautomatically use the updated templates

(c) Sparx Systems 2019 Page 270 of 335

Page 271: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Edit DDL Templates

The DDL Template Editor provides the ability to change thetemplates that the system uses while generating DDL from adata model. It applies the facilities of the Common CodeEditor, including Intelli-sense for the various macros. Formore information on Intelli-sense and the Common CodeEditor, see the Editing Source Code Help topic.

Access

Ribbon Develop > Data Modeling > Templates

Select and Edit Templates

Option Action

Language Click on the drop-down arrow and selectthe database type (Database ManagementSystem).

NewDatabase

Click on this button to create a new set oftemplates for a non-standard DBMS.

(c) Sparx Systems 2019 Page 271 of 335

Page 272: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

The 'Input' dialog displays, on which youtype the name of the new DBMS forwhich you are creating templates.This updates the 'Language' field.

Template Displays the contents of the selectedtemplate, and provides the editor formodifying these contents.

Templates Lists the base DDL templates, Click on atemplate name to display and edit thetemplate contents; the name of theselected template is highlighted.The 'Modified' field indicates whetheryou have modified the default templateoriginally supplied with the system.

StereotypeOverrides

Lists any stereotyped templates that existfor the currently-selected base template.The 'Modified' field indicates whetheryou have modified a default stereotypedtemplate.

Add NewCustomTemplate

Click on this button to display the 'CreateNew Custom Template' dialog, on whichyou select the template type from adrop-down list, and type in a name for thetemplate.The template type becomes a prefix for

(c) Sparx Systems 2019 Page 272 of 335

Page 273: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

the name; for example: Namespace_MyDDLTemplate

Add NewStereotypedOverride

Select a base template and click on thisbutton to display the 'New TemplateOverride' dialog for adding a stereotypedtemplate for the selected template. Fromthe drop-down lists, select the Classand/or Feature stereotype for which toapply the override template.

Get DefaultTemplate

Click on this button to refresh the editordisplay with the default version of theselected template. (This does not deletethe changed version of the template.)

Save Click on this button to overwrite theselected template with the updatedcontents of the Template panel.

Delete If you have overridden the selectedtemplate, click on this button to delete theoverridden template and replace it withthe corresponding default DDL template.

Notes

(c) Sparx Systems 2019 Page 273 of 335

Page 274: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

User-modified and user-defined DDL Templates can be·

imported and exported as Reference Data (see the SharingReference Data topic)

Any user-defined templates for a database type are listed·

in the 'Export Reference Data' dialog in the 'Code, DDL,Transformation & CSV Templates' table, identified by theDBMS name with the suffix _DDL_Template - if nouser-defined templates exist for a DBMS, there is no entryfor the DBMS in the dialog

You must also define any appropriate data types for the·

DBMS and, if exporting the templates as Reference Data,you must export the 'Model Data Types - Code and DDL'table as well

(c) Sparx Systems 2019 Page 274 of 335

Page 275: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DDL Template Syntax

DDL Templates are written using Enterprise Architect'sCode Template Framework, but they have been extended tosupport DDL generation.

DDL Template Development

These aspects of DDL Template development are discussedin this section.

Aspect See also

DDLTemplates

DDL Templates

DDL Macros DDL Macros

DDLFunctionMacros

DDL Function Macros

DDLPropertyMacros

DDL Property Macros

DDL Optionsin Templates

DDL Options in Templates

(c) Sparx Systems 2019 Page 275 of 335

Page 276: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

(c) Sparx Systems 2019 Page 276 of 335

Page 277: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DDL Templates

The DDL Template Editor operates in the same way as theCode Template Editor, except that the DDL Template Editordisplays templates for DDL Generation and templates forAlter DDL Generation at the same time. The Alter DDLGeneration templates are shown at the bottom of the list,prefixed by 'DDL Diff'.

(c) Sparx Systems 2019 Page 277 of 335

Page 278: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Base Templates for DDL Generation

The DDL Template Framework consists of a number ofbase templates for DDL Generation. Each base templategenerates a DDL statement (or a partial statement) for aparticular aspect of the UML data model.

Templates

This table lists and briefly describes the base templates usedfor DDL generation.

Template Description

DDL CheckConstraint

Invoked by the DDL Table Constrainttemplate to generate the Check Constraintstatements for a Table object.

DDL ColumnComment

Normally invoked by the DDL CreateTable Extras template to generateCOMMENT ON statements (orequivalent) for each Table column.

DDL ColumnDefinition

Invoked by numerous templates to buildthe statement to create a single Tablecolumn, as it appears in the CREATETABLE statement.

(c) Sparx Systems 2019 Page 278 of 335

Page 279: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DDL ColumnExtras

Normally invoked by the DDL CreateTable Extras template to generate anyextended column properties for eachTable column.

DDLConstraintColumnName

Invoked by each of the constrainttemplates to retrieve the correctlyformatted column names involved in thecurrent constraint.

DDLConstraintComment

Normally invoked by the DDL CreateTable Extras template to generateCOMMENT ON statements (orequivalent) for each Table constraint.

DDL CreateForeign Keys

Invoked by the DDL Create TableConstraints template to generate ForeignKey constraints for a Table object.

DDL CreateFunction

Invoked by the DDL Script File templateto generate the CREATE FUNCTIONstatement for a Function object.

DDL CreatePackage

Invoked by the DDL Script File templateto generate the CREATE PACKAGEstatements for a Package object (Oracleonly).

DDL Create Invoked by the DDL Script File template

(c) Sparx Systems 2019 Page 279 of 335

Page 280: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Procedure to generate the CREATE PROCEDUREstatement for a Procedure object.

DDL CreateSchema

Currently not used.

DDL CreateSequence

Invoked by the DDL Script File templateto generate the CREATE SEQUENCEstatement for a Sequence object.

DDL CreateTable

Invoked by the DDL Script File templateto generate the CREATE TABLEstatement for a Table object.

DDL CreateTableConstraints

Invoked by the DDL Script File templateto generate Table constraints and Indexesfor a Table object.

DDL CreateTable Extras

Invoked by the DDL Script File templateto generate extended Table properties fora Table object.

DDL CreateView

Invoked by the DDL Script File templateto generate the CREATE VIEWstatement for a View object.

DDL DataType

Invoked by the DDL Column Definitiontemplate to generate the correctlyformatted data type statement for a Table

(c) Sparx Systems 2019 Page 280 of 335

Page 281: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

column.

DDL DropColumnExtras

Invoked by the DDL Drop Table Extrastemplate to generate any specialized dropstatements for column extendedproperties.

DDL DropForeign Keys

Invoked by the DDL Script File templateto generate the statements to DROP allForeign Keys for a Table object.

DDL DropFunction

Invoked by the DDL Script File templateto generate the DROP FUNCTIONstatement for a Function object.

DDL DropProcedure

Invoked by the DDL Script File templateto generate the DROP PROCEDUREstatement for a Procedure object.

DDL DropSequence

Invoked by the DDL Script File templateto generate the DROP SEQUENCEstatement for a Sequence object.

DDL DropTable

Invoked by the DDL Script File templateto generate the DROP TABLE statementfor a Table object.

DDL DropTable Extras

Invoked by the DDL Script File templateto generate the statements to DROP all

(c) Sparx Systems 2019 Page 281 of 335

Page 282: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

extended properties for a Table object.

DDL DropView

Invoked by the DDL Script File templateto generate the DROP VIEW statementfor a View object.

DDL ForeignConstraint

Invoked by the DDL Table Constrainttemplate to generate the ADD FOREIGNKEY CONSTRAINT statements for aTable object.

DDL Grant Invoked by the DDL Create Table Extrastemplate to generate the GRANTstatement for the current object (Oracleonly).

DDL Index Invoked by the DDL Table Constrainttemplate to generate the CREATEINDEX statements for a Table object.

DDL LeftSurround

Used to define the character (orcharacters) used as the left-hand delimiteron the name of an object (or objectcomponent).

DDL Name Used by most templates to provide acommon way of formatting the name ofan object (or object feature). Thistemplate accepts four parameters:

(c) Sparx Systems 2019 Page 282 of 335

Page 283: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Object Location (values: EA or ODBC)·

Object Type (values: OWNER,·

TABLE, VIEW, PROCEDURE,FUNCTION, SEQUENCE,PACKAGE, COLUMN,CONSTRAINT,CONSTRAINT_COLUMN,REFERENCE_TABLE,REFERENCE_COLUMN)Include Owner flag; controls if the·

name should be prefixed by the Ownername (values: INCLUDE_OWNER or{blank})Include Surround flag; controls if the·

name should be delimited by the leftand right surround characters (values:INCLUDE_SURROUND or {blank})

DDL PrimaryConstraint

Invoked by the DDL Table Constrainttemplate to generate the ADD PRIMARYKEY CONSTRAINT statement for aTable object.

DDLReferenceColumnName

Normally invoked by the DDL Nametemplates to retrieve the correctlyformatted reference column namesinvolved in a Foreign Key.

DDL Invoked by the DDL Foreign Constraint

(c) Sparx Systems 2019 Page 283 of 335

Page 284: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

ReferenceDefinition

template to generate the ONDELETE/ON UPDATE statements for aForeign Key constraint.

DDL RightSurround

Used to define the character (orcharacters) used as the right-handdelimiter on the name of an object (orobject component).

DDL ScriptFile

A top-level template to generate DDL; allother templates are invoked from thisone.

DDL ScriptHeader

Invoked by the DDL Script File templateto add a header comment at the start ofeach DDL file.

DDL ScriptSeparator

Used by all templates that must include astatement separator in the generatedDDL.

DDLStatementTerm

Used to define the character (orcharacters) used as the statementterminator. For example, semi-colon (';')for most DBMSs.

DDLStatementTerm Alt

Used to define the character (orcharacters) used as the alternativestatement terminator. For example, some

(c) Sparx Systems 2019 Page 284 of 335

Page 285: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DBMSs must have the statementterminator changed in order to not causeproblems with DDL statements generatedfor SQL-based objects, such as Viewsand Procedures.

DDLSynonym

Invoked by the DDL Create Table Extrastemplate to generate the CREATESYNONYMS statement (Oracle only).

DDL TableConstraint

Invoked by the DDL Create TableConstraints template to generate theTable constraints and Indexes for eachTable object, taking into account thegeneration options.

DDL TableLevelComment

Invoked by the DDL Create Table Extrastemplate to generate COMMENT ONstatements (or the equivalent) for anobject.

DDL Trigger Invoked by the DDL Table Constrainttemplate to generate the CREATETRIGGER statements for a Table object.

DDL UniqueConstraint

Invoked by the DDL Table Constrainttemplate to generate the ADD UNIQUECONSTRAINT statements for a Tableobject.

(c) Sparx Systems 2019 Page 285 of 335

Page 286: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DDL UseDatabase

Invoked by the DDL Script File templateto include a USE DATABASE statementat the start of each DDL file.

(c) Sparx Systems 2019 Page 286 of 335

Page 287: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Base Templates for Alter DDLGeneration

The DDL Template Framework consists of a number ofbase templates for Alter DDL generation. Each basetemplate generates DDL statement(s) based on the detectedAction that must be undertaken to synchronize the datamodel and live database.

Templates

This table lists and briefly describes the base templates usedfor Alter DDL generation.

Template Description

DDL DiffColumn

Invoked directly by Enterprise Architectfor each Table Column difference thatwas detected.

DDL DiffConstraint

Invoked directly by Enterprise Architectfor each Table Constraint difference thatwas detected.

DDL DiffTable

Invoked directly by Enterprise Architectfor each Table difference that wasdetected.

(c) Sparx Systems 2019 Page 287 of 335

Page 288: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DDL DiffView

Invoked directly by Enterprise Architectfor each View difference that wasdetected.

DDL DiffProcedure

Invoked directly by Enterprise Architectfor each Stored Procedure difference thatwas detected.

DDL DiffFunction

Invoked directly by Enterprise Architectfor each Function difference that wasdetected.

DDL DiffSequence

Invoked directly by Enterprise Architectfor each Sequence difference that wasdetected.

(c) Sparx Systems 2019 Page 288 of 335

Page 289: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DDL Macros

Field substitution macros provide access to data from yourmodel. In particular, they are used to access data fieldsfrom:

Database objects (such as Tables and Views)·

Columns·

Constraints·

Constraint Columns·

Field substitution macros are named according to Camelcasing. By convention, all DDL macros are prefixed with'ddl'.

Macros that represent checkboxes or boolean values return astring value of 'T' if the checkbox/boolean is true. Otherwisean empty string is returned.

Internal Field Macro - ddlAction

The ddlAction macro is an internal macro available in the'Alter DDL' templates, providing direct access to EnterpriseArchitect's internal fields; it has no direct mapping to anystored data.

ddlAction represents the action that must be undertaken tosynchronize the live database with the current repository.For example, 'Create Table', 'Drop Table' or 'ChangeOwner'.

(c) Sparx Systems 2019 Page 289 of 335

Page 290: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

(c) Sparx Systems 2019 Page 290 of 335

Page 291: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Element Field Macros

This list identifies the macros that are available in DDLtemplates to access element-level fields, where (inEnterprise Architect) the fields are editable, such as 'TableName' and 'Table Alias'.

ddlFunctionAlias

Function 'Properties' dialog: 'Main' tab: 'Alias' text field.

ddlFunctionName

Function 'Properties' dialog: 'Name' text field.

ddlOwner

{Table element} 'Properties' dialog: {element} 'Table Detail'tab: 'Owner' text field.

ddlPackageAlias

Package 'Properties' dialog: 'Main' tab: 'Alias' text field.

(c) Sparx Systems 2019 Page 291 of 335

Page 292: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

ddlPackageName

Package 'Properties' dialog: 'Name' text field.

ddlProcedureAlias

Procedure 'Properties' dialog: 'Main' tab: 'Alias' text field.

ddlProcedureName

Procedure 'Properties' dialog: 'Name' text field.

ddlSchemaFunctionName

The name of the Function element's definition read in fromthe live database.

ddlSchemaOwner

The 'Owner' property of the element's definition read in

(c) Sparx Systems 2019 Page 292 of 335

Page 293: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

from the live database.

ddlSchemaProcedureName

The name of the Procedure element's definition read in fromthe live database.

ddlSchemaSequenceName

The name of the Sequence element's definition read in fromthe live database.

ddlSchemaTableName

The 'Table Name' property read in from the live database.

ddlSchemaViewName

The name of the View element's definition read in from thelive database.

(c) Sparx Systems 2019 Page 293 of 335

Page 294: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

ddlSequenceAlias

Sequence 'Properties' dialog: 'Main' tab: 'Alias' text field.

ddlSequenceName

Sequence 'Properties' dialog: 'Name' text field.

ddlTableAlias

Table 'Properties' dialog: 'Main' tab: 'Alias' text field.

ddlTableDBMS

Table 'Properties' dialog: 'Main' tab: 'Database' drop downlist field.

ddlTableLevelComment

Table 'Properties' dialog: 'Notes' text field.

(c) Sparx Systems 2019 Page 294 of 335

Page 295: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

ddlTableName

Table 'Properties' dialog: 'Name' text field.

ddlViewAlias

View 'Properties' dialog: 'Main' tab: 'Alias' text field.

ddlViewName

View 'Properties' dialog: 'Name' text field.

(c) Sparx Systems 2019 Page 295 of 335

Page 296: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Column Field Macros

This list identifies the macros that are available in DDLtemplates to access column-related fields, where (inEnterprise Architect) the fields are editable, such as 'ColumnName' and 'Column Alias'.

ddlColumnName

'Columns and Constraints' dialog: 'Column' tab: 'Name' cell.

ddlColumnAlias

'Columns and Constraints' dialog: 'Column' tab: 'Alias' cell.

ddlColumnComment

'Columns and Constraints' dialog: 'Column' tab: 'Notes' textfield.

ddlSchemaColumnName

The Column Name property read in from the live database.

(c) Sparx Systems 2019 Page 296 of 335

Page 297: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Note: This field is not editable directly in EnterpriseArchitect.

(c) Sparx Systems 2019 Page 297 of 335

Page 298: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Constraint Field Macros

This table lists the macros that are available in DDLtemplates to access constraint-related fields, where (inEnterprise Architect) the fields are editable, such as'Constraint Name' and 'Constraint Type'.

ddlConstraintAlias

'Columns and Constraints' dialog: 'Constraints' tab: 'Alias'cell.

ddlConstraintColumnAlias

'Columns and Constraints' dialog: 'Constraints' tab:'Involved Columns: Assigned' list.

ddlConstraintColumnName

'Columns and Constraints' dialog: 'Constraints' tab:'Involved Columns: Assigned' list.

ddlConstraintComment

(c) Sparx Systems 2019 Page 298 of 335

Page 299: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

'Columns and Constraints' dialog: 'Constraints' tab: 'Notes'text field.

ddlConstraintName

'Columns and Constraints' dialog: 'Constraints' tab: 'Name'cell.

ddlPKColumnCount

Only relevant if the current constraint has a type of PrimaryKey, this macro will return a count of assigned columns tothe Primary Key.

'Columns and Constraints' dialog: 'Constraints' tab:'Involved Columns: Assigned' list.

ddlReferenceColumnAlias

Only relevant if the current constraint has a type of ForeignKey, this macro will return the column alias from thereference table.

'Columns and Constraints' dialog: 'Constraints' tab: 'Alias'cell.

(c) Sparx Systems 2019 Page 299 of 335

Page 300: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

ddlReferenceColumnName

Only relevant if the current constraint has a type of ForeignKey, this macro will return the column name from thereference table.

Foreign Key 'Constraint' dialog: 'Involved Columns' list:'Parent' column.

ddlReferenceTableAlias

Only relevant if the current constraint has a type of ForeignKey, this macro will return the reference table's alias.

Table 'Properties' dialog: 'Main' tab: 'Alias' text field.

ddlReferenceTableName

Only relevant if the current constraint has a type of ForeignKey, this macro will return the reference table's name.

Foreign Key 'Constraint' dialog: 'Involved Columns' list:'Parent' column header.

(c) Sparx Systems 2019 Page 300 of 335

Page 301: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

ddlReferenceTableOwner

Only relevant if the current constraint has a type of ForeignKey, this macro will return the reference table's owner.

Foreign Key 'Constraint' dialog: 'Involved Columns' list:'Parent' column header.

ddlSchemaConstraintColumnName

The column names involved in the current constraint read infrom the live database.

Note: this field is not editable directly in EnterpriseArchitect.

ddlSchemaConstraintName

The Constraint Name property read in from the livedatabase.

Note: this field is not editable directly in EnterpriseArchitect.

ddlSchemaConstraintType

(c) Sparx Systems 2019 Page 301 of 335

Page 302: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

The Constraint Type property read in from the livedatabase.

Note: this field is not editable directly in EnterpriseArchitect.

(c) Sparx Systems 2019 Page 302 of 335

Page 303: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DDL Function Macros

The DDL Function macros provide a convenient way ofmanipulating, retrieving or formatting element data relevantto DDL generation. These macros, along with the codefunction macros, are available to the DDL templates. EachFunction macro returns a result string and is used in thesame manner as a Code Template Function macro.

The available function macros are described here. Allparameters have a type of String and are denoted by squarebrackets; that is: FUNCTION_NAME([param]).

DDL_DATATYPE_SIZE ([productName],[datatype])

Returns the fully formatted datatype of the current columnin DDL syntax.

Parameters

productName - the current Table's assigned DBMS, such·

as SQL Server 2012, Oracle or PostgreSQL

datatype - the current column's datatype name, such as·

VARCHAR or INT

Remarks

Within an Enterprise Architect Table column, datatypes aredefined with a Length Type (0, 1 or 2) property thatinfluences the DDL syntax; this function macro takes the

(c) Sparx Systems 2019 Page 303 of 335

Page 304: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Length Type (and other factors) into consideration whenbuilding the return value.

DDL_GET_DEFINITION_PARAS ([definition])

Returns a string representation of the parameters from thesupplied function/procedure definition.

Parameters

definition - the complete SQL definition of the·

procedure/function

Remarks

Some DBMSs (such as PostgreSQL) support multipledefinitions of the same procedure/function name. Thedefinitions differ only in their parameter list, therefore tomanipulate such objects the DDL must specify the name andparameters. This function macro gives the DDL templatesthe ability to extract the parameters so that they can then beused to identify individual objects.

DDL_INCLUDE_SQLQUERY([objectName])

Returns the SQL statement defined in the SQLQuery object.

Parameters

objectName - the name of the SQL Query object defined·

in the current data model

(c) Sparx Systems 2019 Page 304 of 335

Page 305: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Remarks

None.

DDL_INDEX_SORT([product],[columns])

Returns the sort order of a given index.

Parameters

product - the DBMS (currently, Firebird)·

columns - a CSV of column names involved in the index·

Remarks

This macro currently only applies to Firebird indexes.

DDL_RESOLVE_NAME ([productName],[name], [leftSurround], [rightSurround])

Returns the supplied name delimited (with the supplied leftand right characters) if the name is a reserved word for thecurrent DBMS.

Parameters

productName - the current Table's assigned DBMS, such·

as SQL Server 2012, Oracle or PostgreSQL

name - the object/column name·

leftSurround - the left character of the pair used to·

surround the name; for example, single quote {'}

(c) Sparx Systems 2019 Page 305 of 335

Page 306: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

rightSurround - the right character of the pair used to·

surround the name; for example, single quote {'}

Remarks

The DDL syntax of some DBMSs requires names that arereserved words to be delimited in a different manner; thisfunction macro can be used to safely format all names forDB2 and Firebird.

DDL_TABLE_TAGVALUE ([tagName])

Returns the value for the supplied tag name in therepository's version of the current Table.

Parameters

tagName - the tag item's name that is to be retrieved·

Remarks

None.

EXECUTE_CURRENT ([objectName],[actionName], [priority])

Adds the return string from the current template to theExecution Engine's execution queue.

Parameters

objectName - the value that will be shown in the 'Object'·

(c) Sparx Systems 2019 Page 306 of 335

Page 307: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

column of the execution queue, which indicates the nameof the object being updated

actionName - the value that will be shown in the 'Action'·

column of the execution queue, which indicates the actionthat resulted in the generation of this statement

priority - a numeric value that represents the priority of·

the statement; the higher the number, the lower in thequeue the statement is placed

Remarks

This function macro can be called at any point throughoutthe template, but will not execute until the end. Once thetemplate is complete, the DDL it has generated is sent to theexecution queue.

This function macro has no effect if the user has elected togenerate DDL to a file.

EXECUTE_STRING ([objectName],[actionName], [priority], [ddlStatement])

Adds the supplied DDL statement to the Execution Engine'sexecution queue.

Parameters

objectName - the value that will be shown in the 'Object'·

column of the execution queue, which indicates the nameof the object being updated

actionName - the value that will be shown in the 'Action'·

(c) Sparx Systems 2019 Page 307 of 335

Page 308: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

column of the execution queue, which indicates the actionthat resulted in the generation of this statement

priority - a numeric value that represents the priority of·

the statement; the higher the number, the lower in thequeue the statement is placed

ddlStatement - a single DDL statement that performs the·

required action

Remarks

This function macro has no effect if the user has elected togenerate DDL to a file.

EXIST_STRING ([ddlStatement])

Searches the Execution Engine's execution queue for thesupplied DDL Statement and returns 'T' if the statement isfound.

Parameters

ddlStatement - a single DDL statement·

Remarks

None.

GET_FIRST_SQL_KEYWORD([statement])

Returns the first keyword of the provided SQL statement.

(c) Sparx Systems 2019 Page 308 of 335

Page 309: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Parameters

statement - the SQL statement·

Remarks

None.

ODBC_TABLE_TAGVALUE ([tagName])

Returns the value for the supplied tag name in the livedatabase's version of the current table.

Parameters

tagName - the tag item's name that is to be retrieved·

Remarks

None.

PROCESS_DDL_SCRIPT ([type], [parameter2],[parameter3], [parameter4])

A generic function macro that returns a formatted string fora specific purpose.

Parameters

type - specifies the special action to be undertaken·

parameter2 - generic parameter 2, will have a different·

purpose for each type

(c) Sparx Systems 2019 Page 309 of 335

Page 310: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

parameter3 - generic parameter 3, will have a different·

purpose for each type

parameter4 - generic parameter 4, will have a different·

purpose for each type

Remarks

For Oracle Synonyms use these parameters:

type = "SYNONYMS"·

parameter2 = the table name; for example,·

TBL_EMPLOYEES

parameter3 = a delimited string of values, separated by·

semi-colons, specifying the synonym owner and namewith full colon between; for example,OE:EMPLOYEES;PUBLIC:PUB_EMPLOYEES;

parameter4 = the statement terminator·

Return Result

Of the format:

CREATE SYNONYM OE.EMPLOYEES FORTBL_EMPLOYEES;

CREATE PUBLIC SYNONYM PUB_EMPLOYEESFOR TBL_EMPLOYEES;

REMOVE_LAST_SEPARATOR([ddlStatement], [separator])

Returns the supplied DDL statement with the last separator

(c) Sparx Systems 2019 Page 310 of 335

Page 311: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

removed (if it exists).

Parameters

ddlStatement - a partial DDL statement·

separator - the separator character that should be removed·

Remarks

When building a string that represents a DDL statement, it iscommon practice to append the separator character aftereach item; however, the separator is not required after thelast item, so this function macro is provided to remove thetrailing separator.

REMOVE_STRING ([ddlStatement])

Removes the supplied DDL statement from the ExecutionEngine's execution queue.

Parameters

ddlStatement - a single DDL statement·

Remarks

None.

SUPPRESS_EXECUTE_CURRENT ([boolean])

A function macro to enable/disable subsequent calls toEXECUTE_CURRENT.

(c) Sparx Systems 2019 Page 311 of 335

Page 312: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Parameters

boolean - True or False·

Remarks

The default state for this flag is False; that is, calls toEXECUTE_CURRENT are not ignored.

(c) Sparx Systems 2019 Page 312 of 335

Page 313: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DDL Property Macros

The DDL Property macros provide a convenient way ofretrieving element property values (that is, Tagged Values).In the scope of data modeling there are two groups ofproperties:

Internal properties (those that Enterprise Architect·

recognizes and uses in its compares) and

User-defined properties·

These property macros provide access to properties definedagainst the various elements. All property macros have thesame syntax, return a string and require the name of theproperty to be specified.

Syntax: propertyMacroName:"propertyName"

INTERNAL PROPERTIES

tableBoolProperty:"propertyName"

Returns a boolean representation ("T" or "") of the value forthe internal property in the repository's version of thecurrent Table.

Parameters

propertyName - the property name that is to be retrieved·

(c) Sparx Systems 2019 Page 313 of 335

Page 314: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Remarks

None.

tableProperty:"propertyName"

Returns the value for the internal property in the repository'sversion of the current Table.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

columnProperty:"propertyName"

Returns the value for the internal property in the repository'sversion of the current Column.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

columnBoolProperty:"propertyName"

(c) Sparx Systems 2019 Page 314 of 335

Page 315: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Returns a boolean representation ("T" or "") of the value forthe internal property in the repository's version of thecurrent Column.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

constraintProperty:"propertyName"

Returns the value for the internal property in the repository'sversion of the current Constraint.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

constraintBoolProperty:"propertyName"

Returns a boolean representation ("T" or "") of the value forthe internal property in the repository's version of thecurrent Constraint.

Parameters

(c) Sparx Systems 2019 Page 315 of 335

Page 316: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

propertyName - the property name that is to be retrieved·

Remarks

None.

constraintColumnProperty:"propertyName"

Returns the value for the internal property in the repository'sversion of the current Constraint Column.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

constraintColumnBoolProperty:"propertyName"

Returns a boolean representation ("T" or "") of the value forthe internal property in the repository's version of thecurrent Constraint Column.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

(c) Sparx Systems 2019 Page 316 of 335

Page 317: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

viewProperty:"propertyName"

Returns the value for the internal property in the repository'sversion of the current View.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

procedureProperty:"propertyName"

Returns the value for the internal property in the repository'sversion of the current Procedure.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

functionProperty:"propertyName"

Returns the value for the internal property in the repository'sversion of the current Function.

(c) Sparx Systems 2019 Page 317 of 335

Page 318: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

sequenceProperty:"propertyName"

Returns the value for the internal property in the repository'sversion of the current Sequence.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

packageProperty:"propertyName"

Returns the value for the internal property in the repository'sversion of the current database Package.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

(c) Sparx Systems 2019 Page 318 of 335

Page 319: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

odbcTableProperty:"propertyName"

Returns the value for the internal property in the ODBC'sversion of the current Table.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

odbcConstraintProperty:"propertyName"

Returns the value for the internal property in the ODBC'sversion of the current Constraint.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

USER DEFINED PROPERTIES

tableUserProperty:"propertyName"

(c) Sparx Systems 2019 Page 319 of 335

Page 320: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Returns the value for the user-defined property in therepository's version of the current Table.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

columnUserProperty:"propertyName"

Returns the value for the user-defined property in therepository's version of the current Column.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

constraintUserProperty:"propertyName"

Returns the value for the user-defined property in therepository's version of the current Constraint.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

(c) Sparx Systems 2019 Page 320 of 335

Page 321: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

None.

constraintColumnUserProperty:"propertyName"

Returns the value for the user-defined property in therepository's version of the current Constraint Column.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

viewUserProperty:"propertyName"

Returns the value for the user-defined property in therepository's version of the current View.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

procedureUserProperty:"propertyName"

(c) Sparx Systems 2019 Page 321 of 335

Page 322: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Returns the value for the user-defined property in therepository's version of the current Procedure.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

functionUserProperty:"propertyName"

Returns the value for the user-defined property in therepository's version of the current Function.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

None.

sequenceUserProperty:"propertyName"

Returns the value for the user-defined property in therepository's version of the current Sequence.

Parameters

propertyName - the property name that is to be retrieved·

Remarks

(c) Sparx Systems 2019 Page 322 of 335

Page 323: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

None.

(c) Sparx Systems 2019 Page 323 of 335

Page 324: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DDL Options in Templates

The DDL Generation Options macros provide a convenientway for the DDL templates to access the generation options.

This list identifies and briefly describes each of the availableoption macros. Each option has a value of either 'T' for trueor an empty string for false.

ddlGenerateToExecuteEngine

Directs the generated DDL to the Execution Engine.

ddlOptionColumnComments

Include column comments in the generated DDL.

ddlOptionGenerateCheck

Include Check constraints in the generated DDL.

ddlOptionGenerateDrop

(c) Sparx Systems 2019 Page 324 of 335

Page 325: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Include DROP statements in the generated DDL.

ddlOptionGenerateForeign

Include Foreign Keys in the generated DDL.

ddlOptionGenerateFunction

Include Functions in the generated DDL.

ddlOptionGenerateIndex

Include Indexes in the generated DDL.

ddlOptionGenerateLengthSemantic

(Oracle only) Include length semantics syntax on textcolumns in the generated DDL.

ddlOptionGenerateNullable

(c) Sparx Systems 2019 Page 325 of 335

Page 326: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Include the keyword NULL against each column if it hasn'tbeen flagged as a NOT NULL column in the generatedDDL.

ddlOptionGeneratePackage

(Oracle only) Include Packages in the generated DDL.

ddlOptionGeneratePrimary

Include Primary Key constraints in the generated DDL.

ddlOptionGenerateProcedure

Include Procedures in the generated DDL.

ddlOptionGenerateSeparateConstraint

Generate Table constraints separately to the CREATETABLE statement; that is, using an ALTER TABLEstatement.

Note: Some DBMSs do not support separate constraints in

(c) Sparx Systems 2019 Page 326 of 335

Page 327: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

all conditions.

ddlOptionGenerateSequence

Include Sequences in the generated DDL.

ddlOptionGenerateTable

Include Tables in the generated DDL.

ddlOptionGenerateTableProperty

Include extended properties on Tables in the generatedDDL.

ddlOptionGenerateTrigger

Include Table Triggers in the generated DDL.

ddlOptionGenerateUnique

(c) Sparx Systems 2019 Page 327 of 335

Page 328: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Include Unique Constraints in the generated DDL.

ddlOptionGenerateView

Include Views in the generated DDL.

ddlOptionHeaderComments

Include header comments in the generated DDL.

ddlOptionTableComments

Include Table comments in the generated DDL.

ddlOptionUseAlias

Use Aliases instead of Names for all objects (objectcomponents) as specified on the Generate DDL screen.

ddlOptionUseDatabaseName

(c) Sparx Systems 2019 Page 328 of 335

Page 329: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Include the USE DATABASE statement at the beginning ofeach generated file.

ddlUseAlias

Use Aliases instead of Names for all objects (objectcomponents) as specified on the Database Builder 'DatabaseCompare' tab.

(c) Sparx Systems 2019 Page 329 of 335

Page 330: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

DDL Limitations

A fundamental feature of a Database Management System(DBMS) is to allow the definition of database objects via astructured language; this language is called DDL (for datadefinition language, or data description language). The DDLsyntax of each DBMS is unique. While there are commonDDL statements and keywords across all DBMSs, there aredifferences that require each DBMS to have its own set ofDDL templates within Enterprise Architect.

This page summarizes the main limitations for each of thesupported Database Management Systems.

MS Access

Comments cannot be applied to (or changed in) Tables,·

Table Columns, Table Constraints or Views, thereforeEnterprise Architect ignores these differences

The CREATE TABLE statement does not support the·

definition of column defaults, therefore EnterpriseArchitect excludes the Default definition from allgenerated DDL; however, it does highlight a Defaultdifference in the comparison logic

Generally object names in DDL can be enclosed in square·

brackets ([ ]) so that they can include spaces and othernon standard characters, however the CREATE VIEWDDL statement does not support the square bracket

(c) Sparx Systems 2019 Page 330 of 335

Page 331: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

notation; the 'Create View' DDL template replaces allspaces with underscore ('_') characters

MySQL

Comments can only be applied to Indexes and Unique·

Constraints, when the MySQL version is greater than5.5.3

Comments can only be applied to Indexes and Unique·

Constraints when they are created, therefore changing anIndex or Unique Constraint's comment causes theconstraint to be dropped and recreated

Check Constraints are not supported; whilst the MySQL·

DDL engine can parse such statements, it simply ignoresthem

Comments cannot be applied to (or changed in) Views,·

Procedures or Functions, therefore Enterprise Architectignores these differences

Oracle

Comments cannot be applied to (or changed in)·

Procedures, Sequences or Functions, therefore EnterpriseArchitect ignores these differences

(c) Sparx Systems 2019 Page 331 of 335

Page 332: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

PostgreSQL

Currently Enterprise Architect does not support function·

parameters, therefore any statements (COMMENT ON orDROP) that refer to a function by name will fail becausethey must use a combination of function name andparameters

SQL Lite

Constraints cannot be added to an existing Table; the·

Table must be dropped and created (including the newConstraint in the Create statement)

Comments are not supported on any object type, therefore·

Enterprise Architect ignores all remark differences

(c) Sparx Systems 2019 Page 332 of 335

Page 333: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

Supported DBMSs

Enterprise Architect has built in support for acomprehensive range of database management systems, butit also provides the flexibility to extend the product tosupport other DBMSs. The DDL template editor can be usedto define how to generate DDL for an unsupported DBMS,the transformation templates can be used to define a newtransformation to a physical model for an unsupportedDBMS, and new datatypes can be defined for an existing ornew DBMS.

Enterprise Architect provides the modeling constructs andthe ability to forward and reverse engineer a databaseschema for these Database Management Systems:

DB2·

Firebird·

MS Access 97, 2000, 2003, 2007, 2013·

MS SQL Server from 2005, all editions including Express·

and Azure

MariaDB·

MySQL v4, v5·

Oracle from 9i (all editions)·

PostgreSQL·

SQLite·

Informix (#)·

Ingres (#)·

(c) Sparx Systems 2019 Page 333 of 335

Page 334: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

InterBase (#)·

Sybase Adaptive Server Anywhere (Sybase ASA) (#)·

Sybase Adaptive Server Enterprise (Sybase ASE) (#)·

(#) - No further development will be undertaken on theseDBMSs, due to a general lack of interest in these productsfrom the Enterprise Architect user base. This will allowSparx Systems to concentrate its efforts on the other areas ofDatabase modeling.

Notes

To perform data modeling for a particular DBMS, you·

must have the appropriate data types for that DBMS inyour repository; you can download the most up-to-datedata definitions from the 'Resources' page of the SparxSystems web site

(c) Sparx Systems 2019 Page 334 of 335

Page 335: Database Models...Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database,

User Guide - Database Models 20 January, 2020

(c) Sparx Systems 2019 Page 335 of 335