physical data model - sap

760
Physical Data Model Sybase ® PowerDesigner ® 12.5 Windows

Upload: others

Post on 16-Oct-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Physical Data Model - SAP

Physical Data Model

Sybase® PowerDesigner®

12.5Windows

Page 2: Physical Data Model - SAP

Part number: DC38058-01-1250-01Last modified: April 2007

Copyright © 1991-2007 Sybase, Inc. and its subsidiaries. All rights reserved.

Information in this manual may change without notice and does not represent a commitment on the part of Sybase, Inc. and its subsidiaries.

Sybase, Inc. provides the software described in this manual under a Sybase License Agreement. The software may be used only in accordance withthe terms of the agreement.

No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic, mechanical, manual, optical, orotherwise, without the prior written permission of Sybase, Inc. and its subsidiaries.

Use, duplication, or disclosure by the government is subject to the restrictions set forth in subparagraph (c)(1)(ii) of DFARS 52.227-7013 for theDOD and as set forth in FAR 52.227-19(a)-(d) for civilian agencies.

Sybase, SYBASE (logo), ADA Workbench, Adaptable Windowing Environment, Adaptive Component Architecture, Adaptive Server, AdaptiveServer Anywhere, Adaptive Server Enterprise, Adaptive Server Enterprise Monitor, Adaptive Server Enterprise Replication, Adaptive ServerEverywhere, Advantage Database Server, Afaria, Answers Anywhere, AppModeler, APT Workbench, APT-Build, APT-Edit, APT-Execute,APT-Translator, APT-Library, ASEP, Avaki, Avaki (Arrow Design), Avaki Data Grid, AvantGo, Backup Server, BayCam, Bit-Wise, BizTracker,Certified PowerBuilder Developer, Certified SYBASE Professional, Certified SYBASE Professional Logo, ClearConnect, Client-Library, ClientServices, CodeBank, Column Design, ComponentPack, Connection Manager, Convoy/DM, Copernicus, CSP, Data Pipeline, Data Workbench,DataArchitect, Database Analyzer, DataExpress, DataServer, DataWindow, DataWindow .NET, DB-Library, dbQueue, Dejima, Dejima Direct,Developers Workbench, DirectConnect Anywhere, DirectConnect, Distribution Director, Dynamic Mobility Model, e-ADK, E-Anywhere, e-BizIntegrator, E-Whatever, EC Gateway, ECMAP, ECRTP, eFulfillment Accelerator, EII Plus, Electronic Case Management, Embedded SQL, EMS,Enterprise Application Studio, Enterprise Client/Server, Enterprise Connect, Enterprise Data Studio, Enterprise Manager, Enterprise Portal (logo),Enterprise SQL Server Manager, Enterprise Work Architecture, Enterprise Work Designer, Enterprise Work Modeler, eProcurement Accelerator,eremote, Everything Works Better When Everything Works Together, EWA, ExtendedAssist, Extended Systems, ExtendedView, Financial Fusion,Financial Fusion (and design), Financial Fusion Server, Formula One, Fusion Powered e-Finance, Fusion Powered Financial Destinations, FusionPowered STP, Gateway Manager, GeoPoint, GlobalFIX, iAnywhere, iAnywhere Solutions, ImpactNow, Industry Warehouse Studio, InfoMaker,Information Anywhere, Information Everywhere, InformationConnect, InphoMatch, InstaHelp, Intelligent Self-Care, InternetBuilder, iremote,iScript, Jaguar CTS, jConnect for JDBC, KnowledgeBase, Logical Memory Manager, lrLite, M2M Anywhere, Mach Desktop, Mail AnywhereStudio, Mainframe Connect, Maintenance Express, Manage Anywhere Studio, MAP, M-Business Anywhere, M-Business Channel, M-BusinessNetwork, M-Business Suite, MDI Access Server, MDI Database Gateway, media.splash, Message Anywhere Server, MetaWorks, MethodSet,mFolio, Mirror Activator, ML Query, MobiCATS, Mobil 365, Mobileway, MySupport, Net-Gateway, Net-Library, New Era of Networks, NextGeneration Learning, Next Generation Learning Studio, O DEVICE, OASiS, OASiS logo, ObjectConnect, ObjectCycle, OmniConnect, OmniQ,OmniSQL Access Module, OmniSQL Toolkit, OneBridge, Open Biz, Open Business Interchange, Open Client, Open ClientConnect, OpenClient/Server, Open Client/Server Interfaces, Open Gateway, Open Server, Open ServerConnect, Open Solutions, Optima++, Partnerships thatWork, PB-Gen, PC APT Execute, PC DB-Net, PC Net Library, Pharma Anywhere, PhysicalArchitect, Pocket PowerBuilder, PocketBuilder,Power++, Power Through Knowledge, power.stop, PowerAMC, PowerBuilder, PowerBuilder Foundation Class Library, PowerDesigner,PowerDimensions, PowerDynamo, Powering the New Economy, PowerScript, PowerSite, PowerSocket, Powersoft, PowerStage, PowerStudio,PowerTips, Powersoft Portfolio, Powersoft Professional, PowerWare Desktop, PowerWare Enterprise, ProcessAnalyst, Pylon, Pylon Anywhere,Pylon Application Server, Pylon Conduit, Pylon PIM Server, Pylon Pro, QAnywhere, Rapport, Relational Beans, RepConnector, Report Workbench,Report-Execute, Replication Agent, Replication Driver, Replication Server, Replication Server Manager, Replication Toolkit, Resource Manager,RFID Anywhere, RW-DisplayLib, RW-Library, SAFE, SAFE/PRO, Sales Anywhere, Search Anywhere, SDF, Search Anywhere, Secure SQLServer, Secure SQL Toolset, Security Guardian, ShareSpool, Sharelink SKILS, smart.partners, smart.parts, smart.script, SOA AnywhereTrademark,SQL Advantage, SQL Anywhere, SQL Anywhere Studio, SQL Code Checker, SQL Debug, SQL Edit, SQL Edit/TPU, SQLEverywhere, SQL Modeler, SQL Remote, SQL Server, SQL Server Manager, SQL SMART, SQL Toolset, SQL Server/CFT, SQL Server/DBM,SQL Server SNMP SubAgent, SQL Station, SQLJ, Stage III Engineering, Startup.Com, STEP, SupportNow, S.W.I.F.T. Message Format Libraries,Sybase 365, Sybase Central, Sybase Client/Server Interfaces, Sybase Development Framework, Sybase Financial Server, Sybase Gateways, SybaseIQ, Sybase Learning Connection, Sybase MPP, SyberLearning LIVE, Sybase SQL Desktop, Sybase SQL Lifecycle, Sybase SQL Workgroup,Sybase Synergy Program, Sybase Virtual Server Architecture, Sybase User Workbench, SybaseWare, Syber Financial, SyberAssist, SybFlex,SybMD, SyBooks, System 10, System 11, System XI (logo), SystemTools, Tabular Data Stream, The Enterprise Client/Server Company, TheExtensible Software Platform, The Future Is Wide Open, The Learning Connection, The Model For Client/Server Solutions, The Online InformationCenter, The Power of One, TotalFix, TradeForce, Transact-SQL, Translation Toolkit, Turning Imagination Into Reality, UltraLite, UltraLite.NET,UNIBOM, Unilib, Uninull, Unisep, Unistring, URK Runtime Kit for UniCode, Unwired Accelerator, Unwired Orchestrator,Viafone, Viewer,VisualWriter, VQL, WarehouseArchitect, Warehouse Control Center, Warehouse Studio, Warehouse WORKS, Watcom, Watcom SQL, WatcomSQL Server, Web Deployment Kit, Web.PB, Web.SQL, WebSights, WebViewer, WorkGroup SQL Server, XA-Library, XA-Server, XcelleNet, XPServer, XTNDConnect, and XTNDACCESS are trademarks of Sybase, Inc. or its subsidiaries.

All other trademarks are the property of their respective owners.

ii

Page 3: Physical Data Model - SAP

Contents

I Building Physical Data Models vii

About This Manual ix

1 Physical Data Model Basics 1What is a PDM? . . . . . . . . . . . . . . . . . . . . . . . . . 2Creating a PDM . . . . . . . . . . . . . . . . . . . . . . . . . 5Working with DBMSs . . . . . . . . . . . . . . . . . . . . . . . 12Defining Packages in a PDM . . . . . . . . . . . . . . . . . . 19

2 Building Physical Diagrams 21Physical Diagram Basics . . . . . . . . . . . . . . . . . . . . 22Tables (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . . . 26Columns (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . 33Keys (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42Indexes (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . . 50Defaults (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . . 58Domains (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . 62Sequences (PDM) . . . . . . . . . . . . . . . . . . . . . . . . 71Abstract Data Types (PDM) . . . . . . . . . . . . . . . . . . . 76References (PDM) . . . . . . . . . . . . . . . . . . . . . . . . 86Views (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . . . 101View References (PDM) . . . . . . . . . . . . . . . . . . . . . 118Check Parameters (PDM) . . . . . . . . . . . . . . . . . . . . 122Physical Options . . . . . . . . . . . . . . . . . . . . . . . . . 127

3 Building Multidimensional Diagrams 133Multidimensional Diagram Basics . . . . . . . . . . . . . . . . 134Cubes (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . . . 138Dimensions (PDM) . . . . . . . . . . . . . . . . . . . . . . . . 140Attributes (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . 142Facts (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . . . 145Measures (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . 147Hierarchies (PDM) . . . . . . . . . . . . . . . . . . . . . . . . 149Associations (PDM) . . . . . . . . . . . . . . . . . . . . . . . 151

4 Customizing the PDM Environment 153Defining the PDM Environment . . . . . . . . . . . . . . . . . 154

iii

Page 4: Physical Data Model - SAP

Specifying the PDM DBMS . . . . . . . . . . . . . . . . . . . 155Setting PDM Model Options . . . . . . . . . . . . . . . . . . . 160Setting PDM Display Preferences . . . . . . . . . . . . . . . . 176Working with PDM Extended Model Definitions . . . . . . . . 185Working with PDM Extended Dependencies . . . . . . . . . . 187

5 Building Triggers and Procedures 189Triggers (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . . 190Trigger Templates (PDM) . . . . . . . . . . . . . . . . . . . . 206Trigger Template Items (PDM) . . . . . . . . . . . . . . . . . . 214Stored Procedures and Functions (PDM) . . . . . . . . . . . 222Procedure Templates (PDM) . . . . . . . . . . . . . . . . . . 233SQL Code Definition Toolbars . . . . . . . . . . . . . . . . . . 238Using the SQL/XML Wizard . . . . . . . . . . . . . . . . . . . 240Generating Triggers and Procedures . . . . . . . . . . . . . . 247

6 Building a Database Access Structure 253Introducing database access . . . . . . . . . . . . . . . . . . 254Users (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . . . 255Roles (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . . . 270Groups (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . . 273Synonyms (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . 276

7 Building Web Services 283Introducing Web Services . . . . . . . . . . . . . . . . . . . . 284Web Services (PDM) . . . . . . . . . . . . . . . . . . . . . . . 285Web Operations (PDM) . . . . . . . . . . . . . . . . . . . . . 290Web Parameters (PDM) . . . . . . . . . . . . . . . . . . . . . 295Testing Web Services . . . . . . . . . . . . . . . . . . . . . . 297Generating Web Services . . . . . . . . . . . . . . . . . . . . 298Reverse Engineering Web Services . . . . . . . . . . . . . . 302

8 Working with PDMs 305Checking a PDM . . . . . . . . . . . . . . . . . . . . . . . . . 306Retrieving Multidimensional Objects . . . . . . . . . . . . . . 348Rebuilding Cubes . . . . . . . . . . . . . . . . . . . . . . . . 350Generating Extraction Scripts . . . . . . . . . . . . . . . . . . 353Generating Cube Data . . . . . . . . . . . . . . . . . . . . . . 357Migrating from Version 6 Data Warehouse . . . . . . . . . . . 360Using PowerBuilder Extended Attributes . . . . . . . . . . . . 364

9 Denormalizing a PDM 371Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372Horizontal partitioning . . . . . . . . . . . . . . . . . . . . . . 373

iv

Page 5: Physical Data Model - SAP

Vertical partitioning . . . . . . . . . . . . . . . . . . . . . . . . 380Table collapsing . . . . . . . . . . . . . . . . . . . . . . . . . 388Column denormalization . . . . . . . . . . . . . . . . . . . . . 393

10 Using Business Rules in a PDM 397What is a business rule in a PDM? . . . . . . . . . . . . . . . 398Defining business rules in a PDM . . . . . . . . . . . . . . . . 399Using business rules in a PDM . . . . . . . . . . . . . . . . . 408

11 Generating Other Models from a PDM 411Generation Basics . . . . . . . . . . . . . . . . . . . . . . . . 412Generating a Physical Data Model from a Physical Data Model413Generating a Conceptual Data Model from a Physical Data

Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417Generating an Object-Oriented Model from a Physical Data

Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425Generating an XML Model from a Physical Data Model . . . . 431

II Working with Databases 441

12 Generating a Database from a PDM 443Connecting to a Database . . . . . . . . . . . . . . . . . . . . 444Generating a Database . . . . . . . . . . . . . . . . . . . . . 446Using Test Data . . . . . . . . . . . . . . . . . . . . . . . . . . 480Estimating Database Size . . . . . . . . . . . . . . . . . . . . 508Modifying a Database . . . . . . . . . . . . . . . . . . . . . . 514Accessing a Database . . . . . . . . . . . . . . . . . . . . . . 521

13 Reverse Engineering a Database into a PDM 523Getting Started with Reverse Engineering . . . . . . . . . . . 524Reverse Engineering from Scripts . . . . . . . . . . . . . . . 525Reverse Engineering from a Live Database . . . . . . . . . . 528Reverse Engineering Options . . . . . . . . . . . . . . . . . . 532Reverse Engineering Database Statistics . . . . . . . . . . . 541

14 DBMS-Specific Features 543Working with PowerDesigner’s DBMS-Specific Features . . . 544Logical Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 545IBM DB 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548Informix SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . 556Ingres . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557Interbase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558Microsoft Access . . . . . . . . . . . . . . . . . . . . . . . . . 559

v

Page 6: Physical Data Model - SAP

Microsoft SQL Server 7.x and 2000 . . . . . . . . . . . . . . 560Microsoft SQL Server 2005 . . . . . . . . . . . . . . . . . . . 574MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613NonStop SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . 615Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616PostgreSQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642Red Brick Warehouse . . . . . . . . . . . . . . . . . . . . . . 647Sybase AS Anywhere . . . . . . . . . . . . . . . . . . . . . . 648Sybase AS Enterprise . . . . . . . . . . . . . . . . . . . . . . 654Sybase AS IQ . . . . . . . . . . . . . . . . . . . . . . . . . . 657Sybase SQL Anywhere . . . . . . . . . . . . . . . . . . . . . 671Teradata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673

15 Writing SQL Statements in PowerDesigner 679Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680Writing SQL with the PowerDesigner GTL . . . . . . . . . . . 681Writing SQL with the PDM Variables and Macros . . . . . . . 683PDM Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . 685PDM Variables . . . . . . . . . . . . . . . . . . . . . . . . . . 696PowerDesigner Formatting Variables . . . . . . . . . . . . . . 708

16 Migrating from ERwin to PowerDesigner 709Introducing the ERwin Import Process . . . . . . . . . . . . . 710Preparing to Import your ERwin models . . . . . . . . . . . . 712The Import Process . . . . . . . . . . . . . . . . . . . . . . . 713After Importing . . . . . . . . . . . . . . . . . . . . . . . . . . 715Getting Started Using PowerDesigner . . . . . . . . . . . . . 720

Index 723

vi

Page 7: Physical Data Model - SAP

PART I

BUILDING PHYSICAL DATAMODELS

This part explains how to use PowerDesigner to build physical andmultidimensional diagrams for your Physical Data Models.

Page 8: Physical Data Model - SAP

viii

Page 9: Physical Data Model - SAP

About This Manual

Subject

This book describes the PowerDesigner Physical Data Model data modelingenvironment. It shows you how to do the following:

♦ Build a Physical Data Model (PDM) using Physical andMultidimensional diagrams

♦ Create and use business rules and other model objects

♦ Generate triggers, procedures, scripts, and databases

♦ Generate databases

♦ Reverse engineer existing databases

♦ Generate a Physical Data Model, a Conceptual Data Model and anObject-Oriented data Model from a PDM

Audience

This book is for anyone who will be building data models withPowerDesigner. Although it does not assume you have knowledge about anyparticular topic, having some familiarity with relational databases, SQL, anddesign methodology is helpful. For more information, see the Bibliographysection at the end of this chapter.

Documentation primer

The PowerDesigner modeling environment supports several types of models:

♦ Conceptual Data Model (CDM) to model the overall logical structure ofa database, independent from any software or data storage structureconsiderations

♦ Physical Data Model (PDM) to model the overall physical structure of adatabase, taking into account DBMS software or data storage structureconsiderations

♦ Object Oriented Model (OOM) to model a software system using anobject-oriented approach for Java or other object languages

♦ Business Process Model (BPM) to model the means by which one ormore processes are accomplished in operating business practices

ix

Page 10: Physical Data Model - SAP

♦ XML Model (XSM) to model the structure of an XML file using a DTDor an XML schema

♦ Requirements Model (RQM) to list and document the customer needsthat must be satisfied during a development process

♦ Information Liquidity Model (ILM) to model the replication ofinformation from a source database to one or several remote databasesusing replication engines

♦ Free Model (FEM) to create any kind of chart, diagram, in a context-freeenvironment

This book only explains the Physical Data Model. For information on othermodels or aspects of PowerDesigner, consult the following books:

General Features Guide To get familiar with the PowerDesigner interfacebefore learning how to use any of the models.

Conceptual Data Model User’s Guide To work with a CDM.

Object Oriented Model Getting Started To learn the basics of the OOM.

Object Oriented Model User’s Guide To work with an OOM.

Business Process Model User’s Guide To work with a BPM.

XML Model User’s Guide To work with an XSM.

Information Liquidity Model User’s Guide To work with an ILM.

Requirements Model User’s Guide To work with an RQM.

Reports User’s Guide To create reports for any or all models.

Repository User’s Guide To work in a multi-user environment using acentral repository.

Typographic conventions

PowerDesigner documentation uses specific typefaces to help you readilyidentify specific items:

♦ monospace text (normal and bold)

Used for: Code samples, commands, compiled functions and files,references to variables.

Example: declare user_defined..., the BeforeInsertTriggertemplate.

♦ bold textAny new term.

x

Page 11: Physical Data Model - SAP

Example: A shortcut has a target object.

♦ SMALL CAPS

Any key name.

Example: Press the ENTER key.

Bibliography

Data Modeling Essentials

Graeme Simsion, Van Nostrand Reinhold, 1994, 310 pages; paperbound;ISBN 1850328773

Information engineering

James Martin, Prentice Hall, 1990, three volumes of 178, 497, and 625pages respectively; clothbound, ISBN 0-13-464462-X (vol. 1),0-13-464885-4 (vol. 2), and 0-13-465501-X (vol. 3).

Celko95

Joe Celko, Joe Celko’s SQL for Smarties (Morgan Kaufmann Publishers,Inc., 1995), 467 pages; paperbound; ISBN 1-55860-323-9.

xi

Page 12: Physical Data Model - SAP

xii

Page 13: Physical Data Model - SAP

CHAPTER 1

Physical Data Model Basics

About this chapter This chapter presents the PowerDesigner Physical Data Model, andintroduces the Physical and Multidimensional diagrams.

Contents Topic: page

What is a PDM? 2

Creating a PDM 5

Working with DBMSs 12

Defining Packages in a PDM 19

1

Page 14: Physical Data Model - SAP

What is a PDM?

What is a PDM?A Physical Data Model (PDM) is a database design tool for defining theimplementation of physical structures and data queries.

Depending on the type of database you want to design, you will use differenttypes of diagrams in the PDM.

Database Diagram

Operational Physical diagram to define the physical implementation ofthe database

Date warehouseor Data mart

Physical diagram to store business data

OLAP Multidimensional diagram to define the possible queriesto perform on the operational data

Operational PDM

The physical diagrams of the PDM are used to design the structure of adatabase handling large amounts of operational data. Usually, the physicalanalysis follows the conceptual analysis in data modeling. At the physicalstage, the designer considers the details of actual physical implementation ofdata in a database.

The physical diagrams of the PDM allow to take into account both softwareor data storage structures to suit your performance and physical constraints.

+ For more information, see the Building Physical Diagrams chapter.

2

Page 15: Physical Data Model - SAP

Chapter 1. Physical Data Model Basics

Business Intelligence PDM

You can use a PDM to design the structure of a data warehouse handlingbusiness data. A data warehouse environment is made of:

♦ A data warehouse or data mart database

♦ An OLAP database and tools for sending queries to the database

Data warehouse anddata mart database

Data warehouse and data mart databases store historical business datafrom heterogeneous systems. The data warehouse database gathers all thedata manipulated in a company for example, whereas the data mart focuseson smaller entities in the company.

Data warehouse and data mart databases are populated with data proceedingfrom different operational sources. This data transfer is implemented via arelational to relational mapping, the operational database being the datasource of the data warehouse or data mart database.

+ For more information on relational to relational mapping see sectionMapping objects in a PDM in the Working with PDMs chapter.

The purpose of maintaining such type of database is to gather in a centralarea all the information that may be needed in an OLAP database wherequeries for business analysis and decision making are performed.

You use physical diagrams to design a data warehouse or data mart database.Since these databases usually contain very large amounts of data for storage,you do not need to design them for performance. You may assign types (factand dimension) to the database tables to have a preview of themultidimensional structure in an OLAP database.

OLAP database An OLAP database shows a multidimensional view of business data.Information in an OLAP database is organized to facilitate the queriesperformed by different tools. Business analysts use OLAP databases to sendqueries and retrieve business information from the different dimensionsexisting in the database.

OLAP databases are populated with data usually proceeding from a datawarehouse or data mart database. This data transfer is implemented via arelational to multidimensional mapping, the data warehouse or data martdatabase being the data source of the OLAP database.

However, when there are no large amounts of data, it is possible to have adata transfer directly from the operational database to the OLAP engine. Forclarity purpose, we will not develop the operational to OLAP transfer ofinformation in this book.

3

Page 16: Physical Data Model - SAP

What is a PDM?

+ For more information on relational to multidimensional mapping seesection Mapping objects in a PDM in the Working with PDMs chapter.

You have to use multidimensional diagrams to design the differentdimensions and cubes within the OLAP database.

Logical model

The logical model allows you to design the database structure and performsome database denormalization actions. This model is independent from anyDBMS physical requirement.

In PowerDesigner, you can design a logical model using a PDM with the<Logical Model> DBMS. This PDM is a physical model with standardobjects, and without DBMS specific physical options and generationcapabilities.

+ For more information, see “Logical Model” in the “DBMS-specificFeatures” chapter.

4

Page 17: Physical Data Model - SAP

Chapter 1. Physical Data Model Basics

Creating a PDMYou can create a new PDM from scratch, or reverse engineer the model froman existing database.

+ For information about reverse engineering, see the “ReverseEngineering a Database into a PDM” chapter.

v To create a new PDM

1. Select File ä New to display the New dialog box.

2. Select Physical Data Model in the list of model types.

3. Select one of the following radio buttons:♦ New model – Creates a new, standard, model.

♦ New model from template – Creates a model from a model template. Amodel template is a set of model options, display preferences,extension, or objects saved in a model located in the template folder.You use model templates when you need to reuse preferences andoptions in several models.+ For more information about model templates, see the “Creating amodel” section in the “Managing Models” chapter , in the GeneralFeatures Guide .

4. Type a model name in the Model name box. The code of the model,which may be used for script or code generation, is derived from thisname according to the model naming conventions.

5. Select a DBMS from the list.

DBMSs are defined in dedicated XML files (with a .xdb extension),which are provided as part of your PowerDesigner installation in the

5

Page 18: Physical Data Model - SAP

Creating a PDM

“\Resource Files\DBMS” directory, and contain all the syntax andspecifications for each target DBMS.

6. Select one of the following radio buttons:♦ Share the DBMS definition – use the original DBMS file in the

“Resource Files\DBMS” directory. Any changes made to the DBMSare shared by all linked PDMs.

♦ Copy the DBMS definition in model – make a copy of the originalDBMS file in the “Resource Files\DBMS” directory. The currentDBMS is independent of the original DBMS, so modifications made tothe DBMS in the DBMS directory are not available to the PDM. Thecopied object language is saved with the PDM and cannot be usedwithout it.+ For more information on DBMS properties and customizing aDBMS, see the “DBMS Reference Guide” chapter in the AdvancedUser Documentation .

7. Select the type of the first diagram in the First Diagram list. The first typeof diagram selected remains in memory, and is the default for the nexttime when you create a new PDM.

You can create as many diagrams as you need in the same PDM. They aresorted alphabetically in the Browser, except the diagram specified here,which is always the first in the list.

8. [optional] If you want to attach one or more extended model definitionsto complement the selected DBMS, click the Extended Model Definitionstab, and select the extended model definitions of your choice.

+ For more information on attaching extended model definition to amodel, see the “Extended Model Definitions Reference Guide” chapter inthe Advanced User Documentation .

9. Click OK to create the new PDM in the current Workspace.

Demo exampleSeveral example PDMs are available in the Examples directory.

PDM properties

The Model property sheet displays the definition of the current model. Fromthis property sheet you can modify the model definition.

A PDM has the following model properties:

6

Page 19: Physical Data Model - SAP

Chapter 1. Physical Data Model Basics

Property Description

Name Name for the model

Code Code for the model. This code is generated in database scripts

Comment Descriptive label for the model

File name Location of the model file. This box is empty if the model hasnever been saved

Author Author of the model. You can insert a name, a space, ornothing.

If you insert a space, the Author field in the title box remainsempty.

If you intentionally leave the box empty, the Author field in thetitle box displays the user name from the Version Info tab ofthe model property sheet

Version Version of the model. You can use this box to display therepository version or a user defined version of the model. Thisparameter is defined in the display preferences (Title node)

DBMS Current DBMS for the model. You can open the property sheetfor the DBMS by clicking the Properties tool at the end of thebox

Database Database name for the model. You can define and selectdatabases with new physical properties. If you click the Createtool beside the Database box, a confirmation box asks youto commit object creation, and the database property sheet isdisplayed. You can define the properties of the new databaseand click OK

Defaultdiagram

Diagram displayed by default when you open the model

Models for DB2The Database box does not appear in the models targeted for the DB2family as these models support multiple databases in a single model. Formore information, see section Multiple databases in a model in chapterDBMS-specific Features.

Archiving a PDM

Archived models store all constraint names without making a difference

7

Page 20: Physical Data Model - SAP

Creating a PDM

between user defined and calculated constraints. These models are used withthe modify database feature.

You can archive a PDM with the .apm file extension, using the followingmethods:

♦ Save a PDM as an archived model

♦ Automatically archive PDM after database creation

v To archive a PDM

1. Select File ä Save As, select Archived PDM (bin) or Archived PDM(xml) in the Save As Type list, and click Save.

or

Select Database ä Generate Database, click the Options tab, select theAutomatic Archive check box in the After Generation groupbox, andclick OK.

Creating a database

You can create a database for the model from the model property sheet.

8

Page 21: Physical Data Model - SAP

Chapter 1. Physical Data Model Basics

v To create a database

1. Select Model ä Model Properties to open the model property sheet.

2. Click the Create tool to the right of the Database box.

A database is created and its property sheet is displayed.

3. Enter properties as appropriate, and then click OK to complete thecreation of the database.

Database properties

A database definition includes the following properties:

Property Description

Name Name for the database

Code Code for the database. This code is generated in databasescripts

Comment Descriptive label for the database

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

9

Page 22: Physical Data Model - SAP

Creating a PDM

Property Description

DBMS DBMS for the database

Options Physical options available in the DBMS

Script Begin and end scripts that are inserted at the start and end ofa database creation script

Rules Business rules for the database

Multiple databases in a model

Some DBMSs support multiple databases in a single PDM. This feature isenabled by the EnableManyDatabases entry in the Database category of theDBMS.

+ For more information on DBMS definition, see the “DBMS referenceguide” chapter in the Advanced User Documentation .

When you allow multiple databases in the model, a list of databases isdisplayed in the Model menu, and the Database box disappears from themodel property sheet. A Database category is also displayed in the physicaloptions of your database objects.

Creating a database in a model

In those DBMS that support this feature, you can create as many databasesas you need in you model, the databases appear in a list of objects, availablefrom the Model menu. In other DBMS, you create only one database permodel from the model property sheet.

v To create a database in a model

1. Select Model ä Databases to display the List of Databases.

2. Click the Add a row tool to insert a new database in the list and then clickthe Properties tool to open the property sheet of the new database.

3. Enter the appropriate properties and then click OK.

Using a database in a physical option

The databases can be used as a physical option for the tables, columns,views, keys, and indexes of your model.

10

Page 23: Physical Data Model - SAP

Chapter 1. Physical Data Model Basics

v To use a database in a physical option

1. Open the property sheet of an object with physical options.

2. Click the Options tab, select the in database (. . . ) option and click the>> button.

3. Select a database from the list below the right pane.

4. Click OK.

When you use the in [<tablespace>] physical option, you associate apredefined tablespace with a database using the following syntax:

DBname.TBSPCname

For example, tablespace CUST_DATA belongs to database myBase. In thefollowing example, table Customer will be created in tablespaceCUST_DATA:

You should not define a database together with a tablespace physical optionon the same object, this will raise an error during check model.

The database Dependencies tab displays the list of objects that use thecurrent database in their physical options.

11

Page 24: Physical Data Model - SAP

Working with DBMSs

Working with DBMSsPowerDesigner supports many of the most popular DBMSs. For each ofthese DBMSs, a standard definition file is included and provides an interfacebetween PowerDesigner and the DBMS so as to establish the bestrelationships between them.

CautionYou should never modify the DBMS files shipped with PowerDesigner. Foreach original DBMS you want to modify, you should create a correspondingnew DBMS. To do so, select Tools ä Resources ä DBMS to open the Listof DBMS, click the New tool, specify a name, select the DBMS file tocopy in the Copy From list, and click OK. This allows you to create a newDBMS that is identical to the original file apart from the name.

What is a DBMSdefinition file?

A DBMS definition file is a list of values and settings that representspecifications for a particular Database Management System (DBMS) in aformat understandable by PowerDesigner. As an interface between an actualDBMS and PowerDesigner, it provides PowerDesigner with the syntax andguidelines for generating databases, triggers, and stored proceduresappropriate for a target DBMS. The file itself is in .XML format.

The DBMS definition file is a required component of PowerDesigner whenworking with Physical Data Models (PDM). Each actual DBMS supportedby PowerDesigner has its own DBMS definition.

+ For more information on the DBMS definition file, see chapter DBMSReference Guide in the Advanced User documentation .

What is contained in aDBMS definition?

All DBMS definition files have the same structure made up of a number ofcategories. A category can contain sub-categories, and entries. Theseentries are parameters recognizable by PowerDesigner.

The values for DBMS definition categories and entries vary for each DBMS.Some entries may not exist in the DBMS file if they are not applicable to theparticular DBMS.

+ For more information on the DBMS editor, see chapter The ResourceEditor in the General Feature Guide .

12

Page 25: Physical Data Model - SAP

Chapter 1. Physical Data Model Basics

Not certified resource fileSome resource files are delivered with “Not Certified” in their names.Sybase will perform all possible validation checks, however Sybase doesnot maintain specific environments to fully certify these resource files.Sybase will support the definition by accepting bug reports and willprovide fixes as per standard policy, with the exception that there will beno final environmental validation of the fix. Users are invited to assistSybase by testing fixes of the definition provided by Sybase and report anycontinuing inconsistencies.

PDM options

You can control many of the attributes belonging to your PDM objects usingthe Model Options dialog box available by selecting Model ä ModelOptions. For more information, see the section “Setting PDM ModelOptions” in the Building Physical Diagrams chapter.

Using SQL tools

Generating a PDM produces SQL code for your target DBMS.PowerDesigner provides tools to change and preview SQL code during PDMdevelopment. These tools are:

♦ The SQL editor

♦ The SQL preview

The SQL editor allows you to define queries and the SQL preview allowsyou to see a SQL query script before it is generated.

Defining queries with the SQL Editor

You can use the editing features of the SQL Editor to define a query. TheSQL Editor dialog box is divided into specific panes containing theinformation shown below:

Information Pane location

Objects types Upper left part of the dialog box

Available objects Upper right part of the dialog box

Query script textbox Lower part of the dialog box

The list of available objects depends on the selected object type. You canselect individual objects from the list of available objects for insertion in thequery script textbox.

13

Page 26: Physical Data Model - SAP

Working with DBMSs

You can also define expressions by entering basic arithmetic operators suchas add, subtract, multiply, divide (+, -, *, /) and with the syntax tools shownbelow:

Syntax tool Content

Functions Provides group, number, string, date, conversion and otherfunctions

Operators Provides logical operators

Variables Provides variables for use with operators and functions

Macros Provides macros to accelerate the creation of a templateitem definition

These syntax tools allow greater flexibility in defining complex expressions.

The SQL Editor can be used for the following tasks:

♦ Defining a query for a view, a procedure, a trigger

♦ Defining a computed column

+ For more information on defining views, see Defining a query for a viewin chapter Building Physical Diagrams.

+ For more information on defining computed columns, see Creating acomputed column in chapter Building Physical Diagrams.

v To define a query with the SQL Editor

1. Click the query script textbox where you want to insert the SQL script.

2. Select an object type from the upper left part of the dialog box.

For example, select Tables to display the list of available tables. The listof available objects of this type is displayed in the upper right part of thedialog box.

3. Double-click the available object that you want to add to the script.

The item is added to the query script.

4. Select a function or an operator to add to the script from the Function orOperator lists.

The item is added to the query script.

14

Page 27: Physical Data Model - SAP

Chapter 1. Physical Data Model Basics

5. Click OK.

Previewing SQL statements

The Preview tab shows an SQL query script before it is generated. Thedisplayed script reflects the options selected in the Database Generationdialog box. This script cannot be modified.

+ For more information on database generation options, see theGenerating a Database from a PDM chapter.

The text in the script preview is color coded as follows:

Text color Represents

Blue SQL reserved word

Black Statement body

Red Variable

Green Comment

You can use the following tools and keyboard shortcuts from the Previewtoolbar:

15

Page 28: Physical Data Model - SAP

Working with DBMSs

Tool Description Keyboard shortcut

Editor contextual menu SHIFT + F11

Refresh F5

This tool is available when at least oneextended model definition flagged forgeneration is linked to the model andwhen it contains GeneratedFiles entriesfor the current object. When available,it displays the list of targets for thecurrent object. If you add a generationtarget, the corresponding tab is addedto the Preview tab. If you deselect ageneration target, the corresponding tabdisappears from the Preview tab

CTRL + F6

Show generation options CTRL + W

Ignore generation options CTRL + D

+ For more information on extended model definitions used forgeneration, see chapter Extended Model Definitions Reference Guide in theAdvanced User documentation .

Changing generationoptions

If you click the Change Generation Options tool, the Generation Optionsdialog box is displayed. You can change generation options and previewtheir effect on the code.

Ignore generationoptions

If you click the Ignore Generation Options tool, the preview ignoresgeneration options selected by using the Change generation options tool butuses a predefined set of options.

16

Page 29: Physical Data Model - SAP

Chapter 1. Physical Data Model Basics

Selected tool Effect on generationoptions

Effect on preview

Change generation options You can select genera-tion options

Visible in Preview ifoptions are applicable

Ignore generation options Generation optionscurrently selected areoverridden by prede-fined set of options

Only predefined op-tions are visible inPreview

Change generation options+ Ignore generation options

You can select genera-tion options

Changes ignored inPreview

The predefined set of generation options selects these items:

Generation Option Tab Selected items

Tables and Views All items except drop options

Keys and Indexes All items except options represented dif-ferently in some DBMS. For example, if adatabase is auto indexed, the index optionscorresponding to the keys are not selected

Database All items except drop options

Options All user-defined options are used

SQL script bookmarks In the SQL Editor or SQL Preview tab, you can add and remove bookmarksat specific points in the SQL script and then navigate forwards or backwardsfrom bookmark to bookmark:

Keyboardshortcut

Description

CTRL + F2 Adds a new bookmark. A blue bookmark box is displayed.If you repeat this action from the same position, thebookmark is deleted and the blue marker disappears

F2 Jumps to next bookmark

SHIFT + F2 Jumps to the previous bookmark

Note that bookmarks are not printable and are lost if you use the Refresh,Change Generation or Ignore Generation options.

17

Page 30: Physical Data Model - SAP

Working with DBMSs

v To preview the code of a table

1. Double-click a table in the diagram to display the table property sheet.

2. Click the Preview tab to display the Preview tab.

3. Click OK.

18

Page 31: Physical Data Model - SAP

Chapter 1. Physical Data Model Basics

Defining Packages in a PDMA package is a piece of a model.

When working with a large model, you can split the model into smallersubdivisions to avoid manipulating the entire set of model objects. Packagescan be useful to assign portions of a model, representing different tasks andsubject areas, to different development teams.

Package hierarchy You can create several packages at the same hierarchical level within amodel or decompose a package into other packages and continue thisprocess without limitation in decomposition depth. Each package isdisplayed with a default diagram window. At each level of decompositionyou can create several diagrams.

+ For more information on packages, see the section Defining a packagein the General Features Guide .

Composite view You can expand a package to have a global view of the whole diagramcontent.

To do so, you have to right-click a package and select Composite View fromthe contextual menu. You must resize the composite package symbol tovisualize its content:

To return to the package normal view, re-select the Composite Viewcommand in the contextual menu of the expanded package.

Note that if you double-click the composite view, you automatically open

19

Page 32: Physical Data Model - SAP

Defining Packages in a PDM

the sub-package diagram.

+ For more information on the composite view feature, see sectionExpanding the symbol of a composite object in chapter Model Graphics inthe General Features Guide.

PDM package properties

Packages have properties displayed on property sheets. All packages sharethe following common properties:

Property Description

Name Name that clearly identifies the package

Code Codes are references for packages

Comment Optional label that describes a package and provides additionalinformation

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Default dia-gram

Diagram displayed by default when you open the package

Use parentnamespace

Defines the package as being the area in which the name of anobject must be unique in order to be used

Modifying package display preferences

You can modify the following display preference for packages using theTools ä Display Preferences command:

Preference Description

Show stereotype Displays the stereotype of the package

20

Page 33: Physical Data Model - SAP

CHAPTER 2

Building Physical Diagrams

About this chapter This chapter describes how to build physical diagrams, and how to createand modify the associated objects.

Contents Topic: page

Physical Diagram Basics 22

Tables (PDM) 26

Columns (PDM) 33

Keys (PDM) 42

Indexes (PDM) 50

Defaults (PDM) 58

Domains (PDM) 62

Sequences (PDM) 71

Abstract Data Types (PDM) 76

References (PDM) 86

Views (PDM) 101

View References (PDM) 118

Check Parameters (PDM) 122

Physical Options 127

21

Page 34: Physical Data Model - SAP

Physical Diagram Basics

Physical Diagram BasicsA physical diagram allows you to define a database structure from thephysical implementation point of view. It takes into account the physicalresources: DBMS, data storage structures and software, to describe thestructure of the database.

You build a physical diagram at the end of the data analysis process, beforeyou start the software programming. The physical diagram allows you todefine how data from conceptual model are implemented in the database.

Physical diagram objects

You can create the following objects in a physical diagram:

Object Tool Symbol Description

Table Collection of rows (records) that haveassociated columns (fields). See “Tables(PDM)” on page 26.

Column [none] [none] Data structure that contains an individ-ual data item within a row (record),model equivalent of a database field. See“Columns (PDM)” on page 33.

Primary key [none] [none] Column or columns whose valuesuniquely identify each row in a table,and are designated as the primary identi-fier of each row in the table. See “Keys(PDM)” on page 42.

Alternatekey

[none] [none] Column or columns whose valuesuniquely identify each row in a table,and which is not a primary key. See“Keys (PDM)” on page 42.

Foreign key [none] [none] Column or columns whose values de-pend on and migrate from a primary oralternate key in another table. See “Keys(PDM)” on page 42.

Index [none] [none] Data structure associated with one ormore columns in a table, in which thecolumn values are ordered in such away as to speed up access to data. See“Indexes (PDM)” on page 50.

22

Page 35: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Object Tool Symbol Description

Default [none] [none] [certain DBMSs] A default value fora column. See “Defaults (PDM)” onpage 58.

Domain [none] [none] Defines valid values for a column. See“Domains (PDM)” on page 62.

Sequence [none] [none] [certain DBMSs] Defines the form ofincrementation for a column. See “Se-quences (PDM)” on page 71.

Abstractdata type

[none] [none] [certain DBMSs] User-defined data type.See “Abstract Data Types (PDM)” onpage 76.

Reference Link between a primary or an alternatekey in a parent table, and a foreignkey of a child table. Depending on itsselected properties, a reference can alsolink columns that are independent ofprimary or alternate key columns. See“References (PDM)” on page 86.

View Data structure that results from a SQLquery and that is built from data in oneor more tables. See “Views (PDM)” onpage 101.

View Refer-ence

Link between a table and a view. See“View References (PDM)” on page 118.

Trigger [none] [none] A segment of SQL code associated witha table or a view. See “Trigger Overviewin the Building Triggers and Procedureschapter.

Procedure Precompiled collection of SQL state-ments stored under a name in the databaseand processed as a unit. See “Stored Pro-cedures and Functions” in the BuildingTriggers and Procedures chapter.

Database [none] [none] The database of which the PDM is a rep-resentation. See “Creating a Database” inthe Physical Data Model Basics chapter.

23

Page 36: Physical Data Model - SAP

Physical Diagram Basics

Object Tool Symbol Description

Storage [none] [none] A partition on a storage device. See“Tables spaces and Storages” in theGenerating a Database from a PDMchapter.

Tablespace [none] [none] A partition in a database. See “Tablesspaces and Storages” in the Generating aDatabase from a PDM chapter.

User [none] [none] A person who can log in or connect tothe database. See “Users (PDM)” in theBuilding a Database Access Structurechapter.

Role [none] [none] A predefined user profile. See “Roles(PDM)” in the Building a DatabaseAccess Structure chapter.

Group [none] [none] Defines privileges and permissions fora set of users. See “Groups (PDM)” inthe Building a Database Access Structurechapter.

Synonym [none] [none] An alternative name for various types ofobjects. See “Synonyms (PDM)” in theBuilding a Database Access Structurechapter.

Web service [none] [none] Collection of SQL statements stored ina database to retrieve relational data inHTML, XML, WSDL or plain text for-mat, through HTTP or SOAP requests.See “Web Services (PDM)” in the Build-ing Web Services chapter.

Web opera-tion

[none] [none] Sub-object of a Web service containinga SQL statement and displaying Webparameters and result columns. See“Web Service Operations (PDM)” in theBuilding Web Services chapter.

Creating a physical diagram

You can create a physical diagram in an existing PDM in any of the

24

Page 37: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

following ways:

♦ Right-click the model in the Browser and select New ä Physical Diagramfrom the contextual menu

♦ Right-click the background of any diagram and select Diagram ä NewDiagram ä Physical Diagram from the contextual menu.

To create a new PDM with a physical diagram, select File ä New, choosePhysical Data Model from the Model type list, choose Physical Diagram asthe first diagram, and click OK.

25

Page 38: Physical Data Model - SAP

Tables (PDM)

Tables (PDM)A table represents a collection of data arranged in columns and rows. Tablesmay contain any of the following objects:

♦ Columns are named properties of a table that describe its characteristics(see “Columns (PDM)” on page 33).

♦ Indexes are data structures associated with a table that are logicallyordered by key values (see “Indexes (PDM)” on page 50).

♦ Keys are columns, or combinations of columns, that uniquely identifyrows in a table. Each key can generate a unique index or a uniqueconstraint in a target database (see “Keys (PDM)” on page 42).

♦ Triggers are segments of SQL code associated with tables, and stored in adatabase. They are invoked automatically whenever there is an attempt tomodify data in associated tables (see the Building Triggers andProcedures chapter).

You can use database-specific physical options to specify physicalparameters for tables and many other objects (see “Physical Options” onpage 127).

Creating a table

You can create a table in any of the following ways:

♦ Use the Table tool in the diagram Palette

♦ Select Model ä Tables to access the List of Tables, and click the Add aRow tool

♦ Right-click the model or package in the Browser, and select New ä Table

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Table properties

You can modify an object’s properties from its property sheet. To open atable property sheet, double-click its diagram symbol or its Browser entry inthe Tables folder. The following sections detail the property sheet tabs thatcontain the properties most commonly entered for tables.

Table property sheet General tab

The General tab contains the following properties:

26

Page 39: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Property Description

Name Specifies the name of the item which should be clear andmeaningful, and should convey the item’s purpose to non-technical users

Code Specifies the technical name of the item used for generatingcode or scripts, which may be abbreviated, and should notgenerally include spaces

Comment Specifies a descriptive label for the table

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Owner Specifies the name of the table owner. You choose an ownerfrom a list of users. A table can only have one owner at atime. This is normally the table creator

Number Specifies the estimated number of records in the table in thephysical database, which is used to estimate database size.This box is automatically populated during reverse engi-neering if you select the Statistics check box in the ReverseEngineering dialog box (see “Reverse Engineering from aLive Database” in the “Reverse Engineering a Database intoa PDM” chapter).

You can enter your own value in this field, or refresh itsstatistics (along with those for all of the table’s columns)at any time by right-clicking the table symbol or its entryin the Browser and selecting Update Statistics from thecontextual menu. You can also update the statistics for alltables by selecting Tools ä Update Statistics (see “ReverseEngineering Database Statistics” in the “Reverse Engineeringa Database into a PDM” chapter).

Generate Specifies that the table is generated in the database

Dimensionaltype

Specifies the multidimensional type of the table. You canchoose between:♦ Dimension - see “Dimensions (PDM)” in the Building

Multidimensional Diagrams chapter

♦ Fact - see “Facts (PDM)” in the Building Multidimen-sional Diagrams chapter

27

Page 40: Physical Data Model - SAP

Tables (PDM)

Property Description

Type Specifies the type of the table. You can choose between:♦ Relational

♦ Object - for abstract data types

♦ XML - for storing and retrieving data using an XML for-mat. For more information, see “Creating an XML tableor view” on page 29

Table property sheet Columns tab

The Columns tab lists the columns associated with the table. You can createcolumns directly in this tab, or add already existing columns. For moreinformation, see “Columns (PDM)” on page 33.

Table property sheet Indexes tab

The Indexes tab lists the indexes associated with the table. You can createindexes directly in this tab, or add already existing indexes. For moreinformation, see “Indexes (PDM)” on page 50.

Table property sheet Keys tab

The Keys tab lists the keys associated with the table. You can create keysdirectly in this tab, or add already existing keys . For more information, see“Keys (PDM)” on page 42.

Table property sheet Triggers tab

The Triggers tab lists the triggers associated with the table. You can createtriggers directly in this tab, or add already existing triggers. For moreinformation, see the Building Triggers and Procedures chapter.

Table property sheet Procedures tab

The Procedures tab lists the procedures associated with the table. You cancreate procedures directly in this tab, or add already existing procedures. Formore information, see the Building Triggers and Procedures chapter.

Table property sheet Physical Options tabs

The Physical Options tabs list the physical options associated with the table.For more information, see “Physical Options” on page 127.

28

Page 41: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Table property sheet Preview tab

The Preview tab displays the SQL code associated with the table. For moreinformation, see “Previewing SQL statements” in the Physical Data ModelBasics chapter.

Linking a table to an abstract data type

Some DBMS like Oracle or DB2 Common Server support tables based onabstract data types (ADT). A table based on an ADT uses the properties ofthe ADT and the ADT attributes become table columns.

To link a table to an ADT you have to use the Based On list to select anabstract data type. Not all ADT can be used, only ADT of type Object inOracle, or Structured in DB2 Common Server appear in the Based On list.

+ For more information on abstract data types, see “Abstract Data Types(PDM)” on page 76.

Creating an XML table or view

Some DBMS support tables and views of XML type.

29

Page 42: Physical Data Model - SAP

Tables (PDM)

An XML table is used to store an XML document, it does not containcolumns. It is possible to associate this table with an XML schemaregistered in a relational database, in this case the schema is used to validatethe XML document stored in the table.

If you select the XML type in the Type list, the Column tab disappears andthe following additional properties appear in the table property sheet:

Property Description

Schema Allows you to enter the target namespace or the name of anXML model. The schema must be registered in the database tobe used for validating XML documents. You can:♦ type a user-defined schema name

♦ click the Select a registered schema button to connect to adatabase and select a registered schema

If you select an element from an XML model open in the Pow-erDesigner workspace, the Schema property is automaticallyinitialized with the XML model target namespace. Note thatthis schema must also be registered in the database to be usedfor validating XML documents

Element Allows you to select a root element in the XML document. Youcan:♦ type a user-defined element name

♦ click the Select an element button to select an element fromthe XML models open in the workspace or from the schemaregistered in the database

v To create an XML table

1. Right-click the Table category in the Browser and select New.

The property sheet of a new table is displayed.

2. Type a table name and a table code.

3. In the Type list, select XML.

The Columns tab disappears and the Schema and Element boxes appearin the lower part of the General tab.

4. In the Schema box, type the target namespace or name of an XML modelor use the Select a registered schema button to select among theregistered schema in a selected database.

30

Page 43: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

5. In the Element box, type the name of the root element of the selectedschema.

6. Click OK.

Naming a table constraint

A table constraint is a named check that enforces data requirements of checkparameters.

Whenever you place a data restriction on a table, a constraint is createdautomatically. You have the option of specifying a name for the constraint.If you do not, the database creates a default constraint name automatically.

This name helps you to identify and customize a table constraint in scriptsfor database creation and modification.

v To name a table constraint

1. Double-click a table in the diagram to display its property sheet, and clickthe Check tab.

2. Click the User Defined button to the right of the Constraint Name box,and type changes to the constraint name in the Constraint Name box.

Undo changes to a constraint nameYou can always return to the default constraint name by re-clicking theUser-Defined button.

31

Page 44: Physical Data Model - SAP

Tables (PDM)

3. Click OK.

+ For more information, see “Check Parameters (PDM)” on page 122.

Creating external tables

You can create external tables when you need to access data in a remotetable. The external table has all the properties of the remote table but it doesnot contain any data locally.

External tables are metamodel extensions defined in the profile category ofan extended model definition attached to a PDM. For example, in SybaseASA, external tables are called proxy tables and a specific extended modeldefinition is delivered to let you design these tables.

+ For more information on designing proxy tables in Sybase ASA, seesection Working with proxy tables in Sybase ASA in chapter DBMS-specificFeatures.

+ For more information on designing proxy tables in Sybase ASE, seesection Working with proxy tables in Sybase ASE in chapter DBMS-specificFeatures.

32

Page 45: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Columns (PDM)A column contains an individual data item within a row. It is the modelequivalent of a database column. A column is always defined for a table.When you create a column, it must be assigned a name and code. You canalso select a data type for the column. This can be done directly from a listof available data types, or by attaching the column to a domain.

Creating a column

You can create a column in any of the following ways:

♦ Open the Columns tab in the property sheet of a table, and click the Adda Row tool

♦ Right-click a table in the Browser, and select New ä Column

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Column properties

You can modify an object’s properties from its property sheet. To open acolumn property sheet, double-click its row in the Columns tab of a table orits Browser entry. The following sections detail the property sheet tabs thatcontain the properties most commonly entered for columns.

Column property sheet General tab

The General tab contains the following properties:

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the column

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Table Table which contains column

33

Page 46: Physical Data Model - SAP

Columns (PDM)

Property Description

Data type Form of the data corresponding to the column, such asnumeric, alphanumeric, boolean, or others

Displayed When selected, allows the display of selected column in listof columns, otherwise the column is grayed

Length Maximum length of the data type

Precision Maximum number of places after the decimal point

Identity When selected, indicates that the data is auto-incremented(not available for all DBMS)

Domain Name of the associated domain. You can use the tools to theright of the list to create an object, browse the complete treeof available objects or view the properties of the currentlyselected object

Computed When selected, designates that the column is computed froman expression using values from other columns in the table(not available for all DBMS)

Primary key When selected, designates a column whose values uniquelyidentify a row in the table

Foreign key When selected, designates a column that depends on andmigrates from a primary key column in another table

Mandatory When selected, indicates a column that must be assigned anot null value

With default When selected, indicates if a default value is assigned to thecolumn when a Null value is inserted (not available for allDBMS)

Column property sheet Detail tab

The Detail tab contains the following properties:

Property Description

Null Values Number (or percentage) of column entries which contain nullvalues. You can enter a number or percentage in this fieldor derive its value from database statistics (see “UpdatingColumn Statistics” on page 35).

34

Page 47: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Property Description

Distinct Val-ues

Number (or percentage) of column entries which containdistinct values. You can enter a number or percentage inthis field or derive its value from database statistics (see“Updating Column Statistics” on page 35).

For example, you generate a table with 2 columns and 10rows. You set the percentage of distinct values to 100 % forColumn 1 and to 80% for Column 2. This implies that 10rows will have distinct values in Column 1, and 8 rows inColumn 2.

When you apply a test data profile with a list generationsource to a column with a given percentage of distinct values,PowerDesigner uses the values from the test data profile list.If there are not enough values declared in the list, a warningmessage is displayed in the Output window to inform you thatthe distinct value parameter cannot be enforced due to lack ofdistinct values in the list of values.

AverageLength

Average length of a value. You can enter a number in thisfield or derive its value from database statistics (see “UpdatingColumn Statistics” on page 35).

Profile Test data profile selected from the list. Profiles can usecharacters, numbers or date/time data types.

+ For more information, see the “Using test data” sectionin the Generating a Database from a PDM chapter.

ComputedExpression

Computed expression typed directly in the Computed Expres-sion pane or defined with the SQL Editor (accessed with theEdit tool) which helps you define more complex expressions.

+ For more information, see “Creating a computed column”on page 36.

Updating Column Statistics

You can enter values in the Null Values, Distinct Values and Average Lengthfields. Alternatively, you can automatically populate them during reverseengineering by selecting the Statistics check box in the Reverse Engineeringdialog box (see “Reverse Engineering from a Live Database” in the “ReverseEngineering a Database into a PDM” chapter).

You can refresh the value of these fields (along with those for all of thetable’s columns) at any time by right-clicking the table symbol or its entry inthe Browser and selecting Update Statistics from the contextual menu. You

35

Page 48: Physical Data Model - SAP

Columns (PDM)

can also update the statistics for all tables by selecting Tools ä UpdateStatistics (see “Reverse Engineering Database Statistics” in the “ReverseEngineering a Database into a PDM” chapter).

Creating a computed column

A computed column is a column whose content is computed from anexpression using values from other columns in the table. The computedcolumn is then filled with the results.

Simple computed expressions can be entered directly in the ComputedExpression pane on the Detail tab of the column property sheet. For morecomplex expressions, use the SQL Editor available through the Edit toolfound on the same tab.

Computed columns are not available in all DBMS.

Example Assume that you want to automatically fill a column with the total sales ofwidgets. To do this, you can create a computed column that will use thenumber of widgets multiplied by the widget price:

Column name Contents Action on data

Number of widgets Number of widgets sold —

Widget price Price of widgets when sold —

Widget sales Total widget sales Computed by multiplyingthe first two columns

While our example is very simple, the SQL Editor allows you to define verycomplex computed column expressions.

+ For more information on the SQL Editor, see Using SQL tools inchapter Physical Data Model Basics.

v To create a computed column

1. Double-click a table to open its property sheet, and click the Columns tab.

2. Click the Add a Row tool, and then click the Properties tool to open theproperty sheet for the new column.

3. On the General tab, select the Computed checkbox, and then click theDetail tab.

4. Enter an expression in the Computed Expression box to define thecomputed column. Alternatively,you can click the Edit with SQL Editortool to use the SQL Editor.

36

Page 49: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

In our example, we use the asterisk (*) as an arithmetic operator tomultiply the number of widgets by their price.

5. Click OK to return to the column property sheet.

The expression is displayed in the Computed Expression pane.

6. Click OK in each of the dialog boxes.

Selecting a data type for a column

There are two ways to select a data type for a column:

♦ Attach the column to a domain - The domain dictates a data type, alength, and a level of precision, as well as optional check parameters

♦ Manually select a data type - You select a data type along with alength, a level of precision, and optional check parameters

About check parametersCheck parameters indicate data ranges and validation rules. You can setcheck parameters for domains, tables, and columns.

v To select a data type for a column

1. Double-click a table to open its property sheet, and click the Columns tab.

2. Click the required column entry and then click the Properties tool to openits property sheet.

37

Page 50: Physical Data Model - SAP

Columns (PDM)

3. Select a data type from the Data Type list or click the Question markbutton to open and choose a data type from the Standard Data Typesdialog box .

4. If required, enter a data type length and precision.

Undefined data typeIf you do not want to select a data type immediately, you can choose the<undefined> data type. When you generate the database, this data typeis replaced by the default data type for your database, as defined in theDBMS.

5. Click OK in each of the dialog boxes.

Attaching a column to a domain

If you attach a column to a domain, the domain supplies the data type andrelated data characteristics. It may also indicate check parameters, andbusiness rules.

v To attach a column to a domain

1. Double-click a table to open its property sheet, and click the Columns tab.

2. Click the required column entry and then click the Properties tool to openits property sheet.

38

Page 51: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

3. Select a domain from the Domain list and then click OK.

Copying a column to another table

You can copy a column from one table and add it to another table. If thetable already contains a column with the same name or code as the copiedcolumn, the copied column is renamed. For example, the column PUB_ID isrenamed PUB_ID2 when it is copied to a table which already contains acolumn PUB_ID.

39

Page 52: Physical Data Model - SAP

Columns (PDM)

v To copy a column to another table

1. Double-click a table to open its property sheet, and click the Columns tab.

2. Click the Add Columns tool to open a selection box listing the columnsattached to all other tables in the model.

3. Select one or more columns in the list and then click OK.

The copied columns appear in the list of columns for the current table.

4. Click OK.

Naming a column constraint

A column constraint is a named check that enforces data requirements ofcheck parameters.

Whenever you place a data restriction on a column, it generates a constraintautomatically. You have the option of specifying a name for the constraint.If you do not specify a name for the constraint, PowerDesigner creates adefault constraint name automatically.

This name helps you to identify and customize a column constraint in scriptsfor database creation and modification.

v To name a column constraint

1. Open the property sheet of a column and click the Additional Checks tab.

2. Type changes to the constraint name in the Constraint Name box.

40

Page 53: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

The User-Defined button at the end of the box is pressed automatically.

Undo changes to a constraint nameYou can always return to the default constraint name by clicking theUser-Defined button.

3. Click OK in each of the dialog boxes.

Configuring the display of the list of columns

You can sort the columns in the list in two ways:

♦ By any property that is displayed in the title bar of the property lists

♦ By alphabetical or reverse alphabetical order

The listed order is indicated by an arrow head that is displayed at the end ofthe title bar of the property column. Each time you click a title bar, youchange the listed order for that column, according to the displayed arrow.

Each arrow type corresponds to the following list orders:

Arrow type Listed order

Down arrow Alphabetically

Up arrow Reverse alphabetically

For example, when you click the title bar Name, the columns are listed bycolumn name alphabetically when the down arrow is indicated, and inreverse order when the up arrow is indicated.

v To configure the display of the list of columns

1. Select Model ä Columns to open the List of Columns.

2. Click a property title bar to sort the list by the indicated property.

3. Click OK.

41

Page 54: Physical Data Model - SAP

Keys (PDM)

Keys (PDM)A key is a column, or a combination of columns, that uniquely identifies arow in a table. Each key can generate a unique index or a unique constraintin a target database.

The physical diagram supports the following types of keys:

♦ Primary - Column or combination of columns whose values uniquelyidentify every row in a table. A table can have only one primary key

♦ Alternate - Column or combination of columns (not the same column orcombination of columns as for a primary key) whose values uniquelyidentify every row in a table

♦ Foreign - Column or combination of columns whose values are requiredto match a primary key, or alternate key, in some other table

Example The TITLE table shown below has a primary, alternate and foreign key:

♦ TITLE_ID is the primary key and consists of the column TITLE ISBNwhich identifies each book title in the table

♦ TITLE_NAME is an alternate key containing the columns TITLE NAMEand TITLE TYPE. It allows each title to be identified by its name andtype, The fact that it is an alternate key indicates that there is a constraintthat no two titles of the same type can have the same name

The TITLE table also contains the foreign key column PUBLISHER ID.This column references the primary key column in the Publisher table.

Creating a Key

The method for creating a key depends on the type of key. See theappropriate section:

♦ “Primary keys” on page 43

♦ “Alternate keys” on page 45

♦ “Foreign keys” on page 46

42

Page 55: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Key properties

You can modify an object’s properties from its property sheet. To open a keyproperty sheet, go to the Keys tab of its parent table, or double-click itsBrowser entry. The following sections detail the property sheet tabs thatcontain the properties most commonly entered for keys.

Key property sheet General tab

The General tab contains the following properties:

Property Description

Name The name of the item which should be clear and meaning-ful, and should convey the item’s purpose to non-technicalusers

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive comment for the key

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined oruser-defined

Table Name of the table where the key is defined

Constraintname

Name of the key constraint. PowerDesigner automaticallycreates a constraint name for a key, it is used duringdatabase creation and modification. You can modify thedefault name, you can also cancel these changes and goback to the default name

Primary key Indicates if the key is the primary key of the current table.There must be only one primary key in a table, if youselect the Primary Key check box in a key property sheet, itreplaces an already existing primary key

Cluster Indicates whether the key constraint is a clustered constraint(for those DBMS that support clustered indexes)

Primary keys

A primary key is the primary identifier for a table, and is attached to one or

43

Page 56: Physical Data Model - SAP

Keys (PDM)

more columns whose values uniquely identify every row in the table.

Every table must have a primary key, composed of one or more of itscolumns.

Example Employee number is the primary key for the table Employee. This meansthat each employee must have one unique employee number.

You can define one or more columns as the primary key of a table from thelist of columns.

v To designate a primary key

1. Double-click a table in the diagram to open its property sheet.

2. Click the Columns tab, and select the check box in the P column for oneor more columns in the list.

3. [optional] Click the Keys tab and rename the key or select it and click theProperties tool to access its property sheet.

4. Click OK.

Rebuilding primary keys

Rebuilding primary keys in a physical diagram updates primary keys fortables.

Rebuilding primary keys is useful following the reverse engineering of adatabase in which all of the primary keys could not be reverse engineered, orif you did not select the rebuild option for primary keys when you reverseengineered the database. The rebuild option for primary keys createsprimary keys for tables that have no key and a single unique index.

You can choose to rebuild all primary keys in your model, or select thetables for which you want to rebuild the primary keys.

44

Page 57: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

v To rebuild primary keys

1. Select Tools ä Rebuild Objects ä Rebuild Primary Keys to open theRebuild Primary Keys dialog box, which lists all the tables in the currentmodel.

Rebuilding primary keys in a packageTo rebuild the primary keys in package, select the package from the listat the top of the tab.

To rebuild the primary keys in a sub-package, select the Include Sub-Packages icon next to the list, and then select a sub-package from thedropdown list.

2. Select the tables containing the primary keys that you want to rebuild.

Selecting or clearing all check boxesYou can select all check boxes, or clear all check boxes, by selecting theSelect All tool, or Clear All tool, from the toolbar at the top of the tab.

3. Click OK.

Alternate keys

An alternate key is a key attached to one or more columns whose valuesuniquely identify every row in the table, but which is not a primary key. Analternate key can also be a foreign key. Each alternate key can generate aunique index or a unique constraint in a target database.

45

Page 58: Physical Data Model - SAP

Keys (PDM)

Create key tool You can also select one or several columns and use the Create Key tool inthe Columns tab of the table property sheet.

v To designate an alternate key

1. Double-click a table in the diagram to open its property sheet.

2. Click the Keys tab, which lists all the keys defined for the table.

3. Click the Add a Row tool, and type a name for the newly created key.

Alternate key naming conventionThe naming convention for an alternate key is AK followed by thenumber of the key column code; for example AK1_CUSNAME.

4. [optional] Type a constraint name in the Constraint Name column.If youdo not specify a constraint name, PowerDesigner creates a defaultconstraint name automatically.

Displaying additional property columnsIf you do not see the Constraint Name column, display it with theCustomize Columns and Filter tool. For more information, see the“Defining a filter on a list” section in the General Features Guide.

5. Click the property tool and confirm the object creation in order to openthe property sheet for the new key.

6. Click the columns tab, which lists all the columns to which the key isattached. At key creation, the list is empty.

7. Click the Add Columns tool to open a selection box listing all thecolumns in the table (except those attached to the primary key).

8. Select one or more columns and click OK in each of the dialog boxes.

Foreign keys

A foreign key is a primary key, or an alternate key, that migrates fromanother table. Depending on selected model options, a primary key can beautomatically migrated to a child table as a foreign key at reference creation.

The columns that are defined in a foreign key can also be user-specified atcreation and changed at any time from the Joins tab of the reference propertysheet.

+ For information about the auto-migration of a foreign key, see“Automatic reuse and migration of columns ” on page 87.

46

Page 59: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

+ For more information on defining references, see “References (PDM)”on page 86.

Adding parent table columns to a key

You can add additional columns from the parent table to a primary key or analternate key.

v To add parent table columns to a key

1. Open the key’s property sheet and click the Columns tab.

2. Click the Add Columns tool to open a selection box listing all thecolumns in the table (except those already attached to the primary key).

3. Select one or more columns and click OK in each of the dialog boxes.

Naming key constraints

Naming key constraints helps you to identify and customize key constraintsin scripts for database creation and modification. The constraint name givesyou greater flexibility for modifying keys in subsequent databasegenerations.

If you do not specify a constraint name, PowerDesigner creates a defaultconstraint name automatically.

Naming a primary key constraint

A primary key constraint is a named check that enforces the uniqueness andthe presence of values in a primary key column.

You can use the following variable in the name of a primary key constraint:

Variable Description

%TABLE% Code of the table

+ For a full list of all variables that you can use in PowerDesigner, see theappendix Variables in PowerDesigner.

v To name a primary key constraint

1. Double-click a table in the diagram to open its property sheet.

2. Click the Keys tab, select the primary key, and click the Properties tool toopen its property sheet.

47

Page 60: Physical Data Model - SAP

Keys (PDM)

3. Enter the required name in the Constraint Name box.

The User-Defined button to the right of the Constraint box is pressedautomatically. You can return to the default constraint name byre-clicking the User-Defined button.

4. Click OK in each of the dialog boxes.

Naming an alternate key constraint

You can use the following variable in the name of a alternate key constraint:

Variable Description

%AK% Code of the alternate key

%AKNAME% Name of the alternate key

%TABLE% Code of the table

+ For a full list of all variables that you can use in PowerDesigner, see theappendix Variables in PowerDesigner.

v To name an alternate key constraint

1. Double-click a table in the diagram to open its property sheet.

2. Click the Keys tab, select an alternate key, and click the Properties tool toopen its property sheet.

3. Enter the required name in the Constraint Name box.

The User-Defined button to the right of the Constraint box is pressedautomatically. You can return to the default constraint name byre-clicking the User-Defined button.

4. Click OK in each of the dialog boxes.

Naming a foreign key constraint

You can use the following variable in the name of a foreign key constraint:

48

Page 61: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Variable Description

%REFR-NAME%

Name of the reference

%REFR-CODE%

Code of the reference

%PARENT% Code of the parent table

%CHILD% Code of the child table

+ For a full list of all variables that you can use in PowerDesigner, see theappendix Variables in PowerDesigner.

v To name a foreign key constraint

1. Double-click a reference in the diagram to open its property sheet.

2. Click the Integrity tab and enter the required name in the ConstraintName box.

The User-Defined button to the right of the Constraint box is pressedautomatically. You can return to the default constraint name byre-clicking the User-Defined button.

3. Click OK in each of the dialog boxes.

49

Page 62: Physical Data Model - SAP

Indexes (PDM)

Indexes (PDM)An index is a data structure associated with a table that is logically orderedby the values of a key. It improves database performance and access speed.

You normally create indexes for columns that you access regularly, andwhere response time is important. Indexes are most effective when they areused on columns that contain mostly unique values.

Example In a table called Author, you create indexes for the primary key Author IDand the column Author name, but not for the column City. The values forcity, are not likely to be unique, nor searched regularly, and do not helpreduce query time.

Creating an index

You can create the following types of index:

♦ A user-defined index - Associated with one or more columns

♦ An index linked to a key - Automatically updated when the key columnor columns are modified. An index linked to a key is unique because ituses the same unique set of columns as the key.

♦ A function-based index - [if supported by the DBMS] Precomputes thevalue of a function or expression based on one or more columns andstores it in the index. The function or the expression will replace theindex column in the index definition. Function-based indexes provide anefficient mechanism for evaluating statements that contain functions intheir WHERE clauses.

Index namingconventions

Use the following naming conventions for indexes:

Index Naming convention

Primary key Table code followed by PK; for example EMPLOYEE _PK

Foreign key Table code followed by FK; for example PROJECT _ FK

Alternate key Table code followed by AK; for example EMPLOYEE _ AK

Example A table contains a compound primary key. This is a primary key designatedto more than one column in a table. You create an index and link it to theprimary key. If one of the primary key columns is deleted, the correspondingindex associated with the column is also deleted.

50

Page 63: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

v To create an index

1. Double-click a table symbol to display its property sheet and click theIndexes tab.

2. Click the Add a Row tool and enter an index name and an index code.

3. Click the Properties tool to open the property sheet of the new index.

4. Type or select any appropriate index properties, and then click theColumns tab.

5. To create a user defined index: click the Add Columns tool, selectone or more columns from the list, and then click OK

To create an index linked to a key: select the primary key, analternate key, or foreign key from the Columns definition list

To create a function-based index [if supported by the DBMS]: clickthe Add a Row tool, then click in the Expression column and select theellipsis button to open the SQL Editor. Enter an expression in the editorand then click OK

51

Page 64: Physical Data Model - SAP

Indexes (PDM)

6. Select Ascending or Descending in the Sort column.

7. Click OK in each of the dialog boxes.

Reverse engineeringfunction-based index

An index column with an expression has a LONG data type that cannot beconcatenated in a string statement during reverse engineering. The only wayto bypass this limitation and concatenate this value is to use variables in thequery executed to retrieve the adequate information.

In the Oracle 8i and Oracle 8i2 DBMS, the query SqlListQuery defined inthe Index category contains the following variable used to recover the indexexpression in a column with the LONG data type.

’%SqlExpression.Xpr’||i.table_name||i.index_name||c.column_position||’%’

+ For more information on the use of variables in reverse engineeringqueries, see section Extension mechanism for live database reverseengineering queries, in the DBMS Reference Guide chapter of the AdvancedUser Documentation .

Example Function-based indexes defined on UPPER(column_name) orLOWER(column_name) can facilitate case-insensitive searches.

You want to define an index that will put all names in lowercase on the tableEMPLOYEE in order to ease search. You can define the following index

52

Page 65: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

(syntax for Oracle 8i):

CREATE INDEX low_name_idx ON EMPLOYEE (LOWER(EMPLNAM))

Then the DBMS can use it when processing queries such as:

SELECT * FROM EMPLOYEE WHERE LOWER(EMPLNAM)="brown"

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Index properties

You can modify an object’s properties from its property sheet. To open anindex property sheet, double-click its diagram symbol or its Browser entry.The following sections detail the property sheet tabs that contain theproperties most commonly entered for indexes.

Index property sheet General tab

The General tab contains the following properties:

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the index

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Owner Name of index owner. You choose an owner from a listof users, the index and table owners can be identical ordifferent. An index can only have one owner at a time. Thisis normally the index creator.

Some DBMS allow you to define an index owner, eitheridentical or different from the table owner. If the DBMSof the current model does not support index owners, thetable owner will be automatically assigned to the index afterswitching to a DBMS that supports index owners.

Table Indicate table to index

53

Page 66: Physical Data Model - SAP

Indexes (PDM)

Property Description

Type [Sybase IQ, and Oracle only] Specifies the type of index.You can choose between:♦ Bitmap – [Oracle] In a bitmap index, a bitmap for each

key value is used instead of a list of row Ids

♦ HG – [Sybase IQ] HighGroup indexes are used forGROUP BY, COUNT(DISTINCT) and SELECT DIS-TINCT statements when data has more than 1000 uniquevalues

♦ HNG – [Sybase IQ] HighNonGroup indexes make equal-ity comparisons, SUM and AVG calculations very fastwhen data has more than 1000 unique values. Nonequal-ity comparisons can also be done

♦ LF – [Sybase IQ] LowFast indexes are used for columnsthat have a very low number of unique values. This indexalso facilitates join index processing. It is one of the twoindexes allowed for columns used in join relationships

♦ CMP – [Sybase IQ] Compare indexes are used forcolumns that store the binary comparison (<, >, or =) ofany two distinct columns with identical data types, preci-sion, and scale

♦ WD – [Sybase IQ] Is used to index keywords by treat-ing the contents of a CHAR or VARCHAR column as adelimited list

Unique Specifies whether an index is a unique index

Cluster Specifies that the index is a clustered index. Note that a tablecannot have more than one clustered index.

Index property sheet Columns tab

The property tab lists the columns with which the index is associated. Formore information, see “Creating an index” on page 50.

Rebuilding indexes

Rebuilding indexes in a physical diagram automatically updates any changesthat you have made to primary keys, foreign keys, or alternate keys in yourmodel.

54

Page 67: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

v To rebuild indexes

1. Select Tools ä Rebuild Objects ä Rebuild Indexes to open the RebuildIndexes dialog box.

2. Set the appropriate options.

3. [optional] Click the Selection tab to specify which tables you want torebuild indexes for.

4. Click OK. If you selected the Delete and Rebuild mode, a confirmationbox asks you to confirm your choice. Click Yes to confirm the deletionand rebuild of the selected references.

Rebuilding index options The following options are available when rebuilding indexes:

Option Description

Primary key Rebuilds primary key indexes. The text box shows thenaming convention for primary keys. By default this is%TABLE%_PK

Other keys Rebuilds alternate key indexes. The text box shows thenaming convention for alternate keys. By default this is%AKEY%_AK

Foreign keyindexes

Rebuilds foreign key indexes. The text box shows the namingconvention for foreign keys. By default this is %REFR%_FK

55

Page 68: Physical Data Model - SAP

Indexes (PDM)

Option Description

Foreign keythreshold

Specifies the minimum number of estimated records in atable that are necessary before a foreign key index can becreated. The estimated number of records is defined in theNumber box in the table property sheet. If the table has nospecified number of occurrences, the foreign key indexes aregenerated by default

Mode Specifies the extent of the rebuild. You can select:♦ Delete and Rebuild – deletes and rebuilds all indexes

presently attached to primary, alternate, and foreign keys

♦ Add missing indexes – preserves all indexes presently at-tached to primary, alternate, and foreign keys and addsany that are missing

PK index name variables You can use the following variables in the PK index names fields:

Variable Value

%TABLE% Generated code of the table. This is the table codegenerated in the database. It may be truncated if thecode contains characters not supported by the DBMS

%TNAME% Table name

%TCODE% Table code

%TLABL% Table comment

FK index name variables You can use the following variables in the FK index name field. Thegenerated code of a variable is the code defined in the object property sheet,it may be truncated when generated if the code contains characters notsupported by the DBMS

Variable Value

%REFR% Generated code of the reference

%PARENT% Generated code of the parent table

%PNAME% Parent table name

%PCODE% Parent table code

%CHILD% Generated code of the child

%CNAME% Child table name

56

Page 69: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Variable Value

%CCODE% Child table code

%PQUALI-FIER%

Parent table qualifier

%CQUALI-FIER%

Child table qualifier

%REFRNAME% Reference name

%REFRCODE% Reference code

Indexes in query tables

You can create an index associated with the columns of a query table, whichis a special type of view available in Oracle and DB2. These indexes arecalled view indexes. Query table indexes behave like indexes defined ontables, they are data structures that improve database performance andaccess speed. You normally create indexes for columns that you accessregularly, and where response time is important.

For more information about query tables, see “Creating a query table” onpage 112.

57

Page 70: Physical Data Model - SAP

Defaults (PDM)

Defaults (PDM)A default is a value that can be assigned to a column or a domain in theDBMS of the Sybase Adaptive Server Enterprise and Microsoft SQL Serverfamilies.

You select a default from the Default list in the Check Parameters tab of acolumn or domain property sheet.

Example The default object citydflt is used to assign the same default value to allcolumns of type city.

Creating a default

You can create a default in any of the following ways:

♦ Select Model ä Defaults to access the List of Defaults, and click the Adda Row tool.

♦ Right-click the model or package in the Browser, and select New ä

Default.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Default properties

You can modify an object’s properties from its property sheet. To open adefault property sheet, double-click its diagram symbol or its Browser entryin the Defaults folder. The following sections detail the property sheet tabsthat contain the properties most commonly entered for defaults.

Default property sheet General tab

The General tab contains the following properties:

58

Page 71: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Owner Name of default owner. You choose an owner from a list ofusers

Value Value of default object that will be generated

Default property sheet Preview tab

You can view the default creation order in the Preview tab of the defaultproperty sheet.

create default CITYDFLTas ’Dublin’

Assigning a default to a column or a domain

You can select a default from the list of defaults and assign it to a column ora domain from the Standard Checks tab of the column or domain propertysheet.

+ For more information on check parameters, see “Check Parameters(PDM)” on page 122.

If you only type a value in the Default list of a domain property sheet, it willnot be generated as a default object in the database. It is highlyrecommended to use the Rebuild Default feature to create the default objectcorresponding to this value.

+ For more information, see section “Rebuilding defaults” on page 60.

59

Page 72: Physical Data Model - SAP

Defaults (PDM)

v To assign a default to a column or a domain

1. Open the property sheet of a column or a domain, and click the StandardChecks tab.

2. Select a default in the Default list in the Value groupbox.

Alternatively, you can type a default value in the listbox; this does notcreate a default object in the model, it only assigns a default value for thecurrent column or domain. If you type a name that already exists in thelist, the default object is attached to the column or domain.

3. Click OK in each of the dialog boxes.

Rebuilding defaults

You can generate defaults from domains and columns having default values.The Default Rebuild feature uses the default values to create default objectsand attaches them to the appropriate domains and/or columns.

Upgrading modelsWhen you open a model containing domains with default values and savedin a previous version of PowerDesigner, default objects corresponding tothe default values are created in the model.

Default objects are also created when you change the DBMS of a modelcontaining domains with default values, to a DBMS that supports defaultobjects. The opposite process occurs when you switch to a DBMS that doesnot support default objects: default objects are converted into default values.

Default name template You can define a template for the generated default names. This template hasthe D_%.U:VALUE% value and supports the following variables:

♦ DOMAIN for the code of the domain using the default

♦ COLUMN for the code of the column using the default

♦ TABLE for the code of the table that contains the column with a default

You can define one template for domain defaults and one for columndefaults.

v To rebuild defaults

1. Select Tools ä Rebuild Objects ä Rebuild Defaults to open the DefaultRebuild dialog box.

2. Specify a default name template in the Domain and Column boxes.

60

Page 73: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

3. [optional] Select the Reuse default with identical value check box – thisoption will reuse default objects with identical value among columns anddomains. If you do not select this option, rebuild creates one default perobject.

4. [optional] Select the Delete and rebuild check box – this option detachesthe default objects attached to selected objects and deletes them if theyare not used. If you select all objects, this option allows you to clean upthe model from all existing defaults and recreate new default objects.

5. [optional] Click the Selection tab to specify domains and tables fordefault generation.

6. Click OK.

The defaults are automatically created and attached to the domains and/orcolumns.

61

Page 74: Physical Data Model - SAP

Domains (PDM)

Domains (PDM)Domains help you identify the types of information in your model. Theydefine the set of values for which a column is valid. Applying domains tocolumns makes it easier to standardize data characteristics for columns indifferent tables.

In a Physical diagram, you can associate the following information with adomain:

♦ Data type, length, and precision

♦ Check parameters

♦ Business rules

♦ Mandatory property

Creating a domain

You can create a domain as follows:

♦ Select Model ä Domains to access the List of Domains, and click theAdd a Row tool

♦ Right-click the model or package in the Browser, and select New ä

Domain

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Domain properties

You can modify an object’s properties from its property sheet. To open adomain property sheet, double-click its Browser entry in the Domains folder.The following sections detail the property sheet tabs that contain theproperties most commonly entered for domains.

Domain property sheet General tab

The General tab contains the following properties:

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users

62

Page 75: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Property Description

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the domain

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Owner Name of domain owner. You choose an owner from a list ofusers. A domain can only have one owner at a time. This isnormally the domain creator

Data type Form of the data corresponding to the domain, such asnumeric, alphanumeric, Boolean, or others

Length Maximum number of characters

Precision Number of places after the decimal point, for data values thatcan take a decimal point

Mandatory Domain values are mandatory for all columns using thatdomain

Identity (For Adaptive Server Enterprise, MS SQL Server and thoseDBMS that support it). When selected, indicates that thedata is auto-incremented for columns using that domain

With default (For those DBMS that support it). When selected, indicatesif a default value is assigned to a column using the domain,when a Null value is inserted

Profile Test Data profile assigned to the domain

Specifying a domain’s data type, length, and precision

The data types that you can select in a Physical diagram depend on yourcurrent DBMS. Depending on the data type, you may have to also specify amaximum or fixed length and the level of decimal precision.

In the list of data types, a variable indicates that you have to type a length orprecision, as follows:

63

Page 76: Physical Data Model - SAP

Domains (PDM)

Variable Replace with

%n Length

%s Length with precision

%p Decimal precision

For example, if you are using Sybase Adaptive Server Anywhere and youchoose the data type char(%n), you can choose a length of ten by typingchar(10).

v To specify a data type for a domain from the list of domains

1. Select Model ä Domains to open the List of Domains.

2. Click the domain that you want to define.

3. Select a data type from the list in the Data Type column and, if necessary,enter a length and precision.

4. Click OK.

v To select a data type for a domain from its property sheet

1. Select Model ä Domains to display the List of Domains.

2. Click the domain that you want to define and then click the Propertiestool to open its property sheet.

3. Select a data type from the Data Type list or click the question markbutton to the right of this list to open the list of standard data types.

4. If necessary, enter values in the Length and Precision boxes.

5. Click OK.

List of standard data types

You can open the list of Standard Data Types by clicking the question markbutton to the left of the list of Data Types on the General Tab of a domainproperty sheet.

64

Page 77: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

This is the same list that is available in the PowerDesigner Conceptual DataModel, and any data type selected in this list will be automatically mappedto the appropriate physical data type in your DBMS.

Numeric data types The following numeric data types are available:

Standarddata type

DBMS-specificphysical data type

Content Length

Integer int / INTEGER 32-bit integer —

Short Integer smallint / SMALL-INT

16-bit integer —

Long Integer int / INTEGER 32-bit integer —

Byte tinyint / SMALL-INT

256 values —

Number numeric / NUM-BER

Numbers with a fixeddecimal point

Fixed

Decimal decimal / NUM-BER

Numbers with a fixeddecimal point

Fixed

Float float / FLOAT 32-bit floating point num-bers

Fixed

65

Page 78: Physical Data Model - SAP

Domains (PDM)

Standarddata type

DBMS-specificphysical data type

Content Length

Short Float real / FLOAT Less than 32-bit pointdecimal number

Long Float double precision /BINARY DOUBLE

64-bit floating point num-bers

Money money / NUMBER Numbers with a fixeddecimal point

Fixed

Serial numeric / NUM-BER

Automatically incre-mented numbers

Fixed

Boolean bit / SMALLINT Two opposing values(true/false; yes/no; 1/0)

Character data types The following character data types are available:

Standarddata type

DBMS-specificphysical data type

Content Length

Characters char / CHAR Character strings Fixed

VariableCharacters

varchar / VAR-CHAR2

Character strings Maximum

Long Charac-ters

varchar / CLOB Character strings Maximum

Long VarCharacters

text / CLOB Character strings Maximum

Text text / CLOB Character strings Maximum

Multibyte nchar / NCHAR Multibyte characterstrings

Fixed

VariableMultibyte

nvarchar / NVAR-CHAR2

Multibyte characterstrings

Maximum

Time data types The following time data types are available:

66

Page 79: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Standarddata type

DBMS-specificphysical data type

Content Length

Date date / DATE Day, month, year —

Time time / DATE Hour, minute, and second —

Date & Time datetime / DATE Date and time —

Timestamp timestamp /TIMESTAMP

System date and time —

Other data types The following other data types are available:

Standarddata type

DBMS-specificphysical data type

Content Length

Binary binary / RAW Binary strings Maximum

Long Binary image / BLOB Binary strings Maximum

Bitmap image / BLOB Images in bitmap format(BMP)

Maximum

Image image / BLOB Images Maximum

OLE image / BLOB OLE links Maximum

Other — User-defined data type —

Undefined undefined Undefined. Replaced bythe default data type atgeneration.

Cascading updates to columns associated with the domain

When you modify data types associated with a domain, an updateconfirmation box is displayed asking if you want to modify the columnscurrently using the domain.

v To modify domain properties in a PDM

1. Open the property sheet of a domain and edit its properties as required.

2. Click OK.

If the domain is used by one or more columns, an update confirmationbox is displayed asking if you want to modify domain properties for thecolumns using the domain.

67

Page 80: Physical Data Model - SAP

Domains (PDM)

The Data Type check box is selected or not according to the options set toenforce non-divergence from a domain ().

3. Select any other properties that you want to update (Check, Rules,Mandatory, Profile) for all columns using the domain.

4. Click one of the following buttons:♦ Yes - The columns currently using the domain are modified according

to the update

♦ No - The columns currently using the domain are not modifiedaccording to the update but the current modification is accepted ifdomain divergence is allowed in the model options (see “Enforcingnon-divergence from a domain in a PDM” on page 68).

♦ Cancel - The update is cancelled and nothing is changed

Enforcing non-divergence from a domain in a PDM

You can enforce non-divergence between a domain and the columns that usethe domain.

68

Page 81: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

v To enforce domain non-divergence in a PDM

1. Select Tools ä Model Options to open the Model Options dialog box andclick the Column and Domain sub-category in the left-hand Categorypane:

2. Select the check boxes of the column properties that are not permitted todiverge from the domain definition. You can specify any or all of:

♦ Data type - data type, length, and precision

♦ Check - check parameters such as minimum and maximum values

♦ Rules – business rules

♦ Mandatory – mandatory property of the column

♦ Profile - test data profileIf you subsequently modify in your domain any of the propertiesspecified as non-divergent here, then the corresponding properties of thecolumns attached to that domain are automatically updated.

Column properties specified as non-divergent appear dimmed and arenon-editable in the List of Columns and Column property sheets. If youwant to modify a non-divergent column property, you must detach thecolumn from its domain.

3. Click OK to close the Model Options dialog box.

4. When you set the Enforce non-divergence options, you are asked if youwant to apply domain properties to columns currently attached to the

69

Page 82: Physical Data Model - SAP

Domains (PDM)

domain. If you click OK, the column properties are modified in order tobe consistent with the properties of the domain to which they belong.

70

Page 83: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Sequences (PDM)If your DBMS supports sequences, then you can create a sequence for acolumn.

A sequence is like an advanced form of an auto-incremented column. Wherethe latter is a column whose values automatically increment by 1, sequencesallow you to define a more complex list of numbers. For example, you coulddefine a list of numbers ranging between two values with an increment byany number (integer) you want.

Once you define a sequence, you can apply and enable it to a column. Thedata type for the column receiving the sequence must be a numeric datatype. Such auto-incremented columns can be used in a key for a PDM table.

+ For more information on data types, see “Selecting a data type for acolumn” on page 37.

Example Assume that you want to create a column listing the months of the yearwhen quarterly reports are published: March, June, September, andDecember. The first report is published on the third month, the second on thesixth, the third on the ninth and the last on the twelfth.

You can define the proper sequence by typing the following values forsequence option parameters:

Parameter name Description Value

Start with March is the third month of the year 3

Increment by Look three months ahead to identify thenext month in the list

3

Maxvalue Stop when you have reached the lastmonth of the year

12

The sequence created with these parameter settings allows you toautomatically create the list of months in a year when quarterly reports arepublished.

Creating a Sequence

There are two steps to using sequences:

♦ Create a sequence (including defining sequence options)

♦ Apply and enable a sequence to a column

71

Page 84: Physical Data Model - SAP

Sequences (PDM)

v To create a sequence

1. Select Model ä Sequences to open the List of Sequences.

2. Click the Add a Row tool and type a name for the new sequence.

3. Double-click the arrow to the left of the new sequence to display itsproperty sheet.

4. Click the Physical Options tab and enter any appropriate parameters.These options are DBMS-specific. For more information on using thistab, see “Physical Options” on page 127.

The above example shows the options and values to create a sequence ofmonths in a year when quarterly reports are published.

5. [optional] Click the Apply To button to open a selection list and specifyother sequences to which these same options will apply.

72

Page 85: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

6. Click OK in each of the dialog boxes.

v To apply and enable a sequence on a column

1. Open the property sheet of the column to which you want to apply thesequence.

2. On the General tab, select a sequence from the Sequence list.

3. Click OK to close the property sheet.

4. Select Tools ä Rebuild Objects ä Rebuild Triggers to open the RebuildTriggers dialog box.

5. Click the Selection tab and select the table or tables containing thecolumn to which you want to attach a sequence.

6. Click OK.

The triggers are rebuilt and the sequence is enabled on the column.

+ For more information on rebuilding triggers, see the Building Triggersand Procedures chapter.

Sequence properties

You can modify an object’s properties from its property sheet. To open asequence property sheet, double-click its Browser entry in the Sequencesfolder or its line in the List of Sequences. The following sections detail theproperty sheet tabs that contain the properties most commonly entered forsequences.

73

Page 86: Physical Data Model - SAP

Sequences (PDM)

Sequence property sheet General tab

The General tab contains the following properties:

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the sequence

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Owner Name of sequence owner. You choose an owner from a list ofusers. A column can only have one owner at a time. This isnormally the column creator

Sequence property sheet Physical Options tab

The Physical Options tab lists the physical options associated with thesequence. For information about these options, see your DBMSdocumentation. For general information about using this tab, see “PhysicalOptions” on page 127.

Changing the DBMS of a model which contains sequences andauto-incremented columns

If you create a sequence attached to a column in a DBMS supportingsequences, such as Oracle 8 and higher, Interbase or PostgreSQL, or createan auto-incremented column in a DBMS supporting this feature, and thendecide to change the target DBMS, the following effects occur:

74

Page 87: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

DBMS change Defined in origi-nal DBMS

Effect on sequence objects andauto-incremented columns

DBMS supportingsequences to aDBMS supportingauto-incrementedcolumns

Sequence at-tached to a col-umn

The sequence disappears and thecolumn to which it was attached be-comes an auto-incremented columnin the DBMS

DBMS supportingauto-incrementedcolumns to aDBMS support-ing sequences

Auto-incremented col-umn

The auto-incremented column isdeleted and replaced by a sequenceobject called S_TABLENAMEwhich is attached to the originalcolumn

Sequences and intermodel generation

When a CDM or an OOM is generated from a PDM, the data type of a tablecolumn attached to a sequence is translated to a numeric data type in the newmodel:

PDM gener-ated to

Sequence is converted to

CDM A serial data type for an entity property. The data typehas the format NO%n where %n is a number indicating thelength of the data type

OOM A serial data type for a class attribute. The data type has theformat NO%n, where %n is a number indicating the lengthof the data type

75

Page 88: Physical Data Model - SAP

Abstract Data Types (PDM)

Abstract Data Types (PDM)An abstract data type (ADT) is a user-defined data type which canencapsulate a range of data values and functions. The functions can be bothdefined on, and operate on the set of values.

Abstract data types can be used in the following ways in a Physical diagram:

Abstractdata typeis

Description

Created You can create an abstract data type of any kind supportedby your DBMS.

If you create an abstract data type of type JAVA, you canlink it to a Java class in an OOM to access the Java classproperties (see “Linking an abstract data type to a Java class”on page 81).

Reverse engi-neered

An abstract data type in a database can be reverse engineeredinto a PDM.

If you also reverse engineer the JAVA classes into an OOM,then the abstract data types of the type JAVA in the PDMare automatically linked to the Java classes in the OOM(see “Reverse-engineering a PDM linked to an OOM” onpage 85)

+ For more information on reverse engineering a database into a PDM, seechapter Reverse Engineering.

+ For more information on creating and reverse engineering Java classesinto a PowerDesigner Object-Oriented Model, see the Object-OrientedModel User’s Guide .

Depending on the current DBMS, the following kinds of abstract data typescan be created in PowerDesigner:

76

Page 89: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Type Description Example

Array Fixed length collection ofelements

VARRAY (Oracle 8 and higher)

List Unfixed length collectionof objects

TABLE (Oracle 8 and higher)

Java Java class JAVA (Adaptive Server Any-where, and Adaptive Server En-terprise)

Object Contains a list of at-tributes and a list of pro-cedures

OBJECT (Oracle 8 and higher)

SQLJ Object Contains a list of at-tributes and a list of pro-cedures

SQLJ OBJECT (Oracle 9i andhigher)

Structured Contains a list of at-tributes

NAMED ROW TYPE (Informix9.x, and IBM DB2 5.2)

Example An abstract data type for the Gregorian calendar which has functions definedto do the following:

♦ Read and write roman numerals

♦ Convert dates from the Julian calendar to the Gregorian calendar

♦ Convert dates from the Gregorian calendar to the Julian calendar

Creating an abstract data type

You can create an abstract data type in any of the following ways:

♦ Select Model ä Abstract Data Types to access the List of Abstract DataTypes, and click the Add a Row tool.

♦ Right-click the model or package in the Browser, and select New ä

Abstract Data Type.

+ See also “Creating object and SQLJ object abstract data types” onpage 79.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Abstract data type properties

You can modify an object’s properties from its property sheet. To open an

77

Page 90: Physical Data Model - SAP

Abstract Data Types (PDM)

abstract data type property sheet, double-click its Browser entry in theAbstract Data Types folder. The following sections detail the property sheettabs that contain the properties most commonly entered for abstract datatypes.

Abstract data type property sheet General tab

The General tab contains the following properties:

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Owner Name of abstract data type owner. You choose an owner from alist of users

Type Defining group that includes the abstract data type

Depending on its type, an abstract data type definition can also include thefollowing properties:

♦ Data type, Length, and Precision

♦ Size (for arrays)

♦ Linked class name (for Java types)

♦ File name and path, which contains the declaration of the class

♦ Authorization (for objects): Invoker Right attribute used for DDLgeneration

♦ Supertype (for objects): Parent abstract data type from which the currentabstract data type can inherit the procedures

♦ Final and Abstract (for objects): When Final is checked, the currentabstract data type cannot be used as supertype by another abstract datatype. When Abstract is checked, the current abstract data type cannot beinstantiated. Final and Abstract are mutually exclusive

78

Page 91: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

♦ Java class (for SQLJ objects): Name of an external Java class to whichthe SQLJ object points. Beside the Java class box, there is a list to selecta mapping interface (CustomDatum, OraData or SQLData)

Creating object and SQLJ object abstract data types

If you select the OBJECT (or SQLJ OBJECT) type for an abstract data type,two additional tabs are displayed in the property sheet:

♦ The Attributes tab allows you to specify an object (or SQLJ object) with anumber of attributes to which are assigned appropriate data types

♦ The Procedures tab allows you to specify an object (or SQLJ object) witha number of procedures to which are assigned appropriate parameters

Procedure inheritance An object abstract data type with a supertype can inherit non-finalprocedures. You can use the Inherit Procedure tool in the Procedures tab ofthe abstract data type to select a non-final procedure from a parent abstractdata type. Inheritance only applies to non-finale procedures.

Object example For example, you want to create an Address object with Street, City, andZipCode attributes, and a Location procedure.

v To specify attributes and procedures for an object (or SQLJ ob-ject) abstract data type

1. Open the property sheet of the abstract data type and select eitherOBJECT or SQLJ_OBJECT from the type list.

The Attributes and Procedures tabs are displayed.

2. Click the Attributes tab.

79

Page 92: Physical Data Model - SAP

Abstract Data Types (PDM)

3. For each attribute, click the Add a Row tool, and:♦ enter a Name and Code

♦ select a data type class from the Data Type list

♦ [optional] Select the Mandatory (M) checkbox

4. Click the Procedures tab:

80

Page 93: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

5. For each procedure, click the Add a Row tool, and:♦ enter a Name and Code

♦ [optional] Select the Final (F), Static (S) and/or Abstract (A) columns

6. Click OK in each of the dialog boxes.

Linking an abstract data type to a Java class

You can specify a Java class in the PDM, and then link it to a Java class in anOOM. The OOM must be open in the current Workspace to be available forlinking.

When you link an abstract data type to a Java class, a shortcut is createdwhich allows you to access the properties of the Java class from within thePDM.

81

Page 94: Physical Data Model - SAP

Abstract Data Types (PDM)

v To link an abstract data type to a Java class

1. Create an abstract data type and select Java from the Type list on theGeneral tab of its property sheet.

2. Click the Ellipsis button to the right of the Class box to open a Java classselection box, which lists all the Java classes that are available in theOOMs currently open in the Workspace.

82

Page 95: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

3. Select a Java class and click OK.

The abstract data type is now linked to the Java class, and the class nameis displayed in the Class box.

4. Click the Properties button at the end of the Class box to open theproperty sheet of the Java class.

If the related OOM is closed, then a shortcut property sheet for the Javaclass is displayed, and you must click the Properties button to the right ofthe Name box to display its actual property sheet..

83

Page 96: Physical Data Model - SAP

Abstract Data Types (PDM)

If the related OOM is open, then the class property sheet is openeddirectly:

5. Click OK in each of the dialog boxes.

84

Page 97: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Reverse-engineering a PDM linked to an OOM

You can reverse engineer a PDM from a database that contains Java classesand also reverse the Java classes into an OOM. The Java abstract data typesin the PDM are automatically linked to the Java classes in the OOM asfollows:

♦ You should reverse engineer the Java classes in the database that are usedas data types for the columns and domains in an OOM

♦ Then reverse engineer the database into a PDM

♦ PowerDesigner automatically searches the open OOM for the Javaclasses that correspond to the JAVA abstract data types in the PDM andmakes the corresponding links

The Java classes that are reverse engineered into the PDM are createdautomatically as abstract data types of type JAVA.

You can access the properties of these Java classes from the property sheetsof the corresponding abstract data types in the PDM. For more information,see “Linking an abstract data type to a Java class” on page 81.

85

Page 98: Physical Data Model - SAP

References (PDM)

References (PDM)A reference is a link between a parent table and a child table. It defines areferential integrity constraint between column pairs for a primary key, oralternate key, and a foreign key, or between user specified columns in bothtables.

When column pairs are linked by a reference, each value in the child tablecolumn refers to an equivalent value in the parent table column.

Within a reference, each column pair is linked by a join. Depending on thenumber of columns in the primary key, or alternate key, or the number ofspecified columns, a reference can contain one or more joins.

A reference normally links primary key, or alternate key, columns to foreignkey columns.

Example The two tables SALE and STORE are linked by a reference. STORE is theparent table and SALE is the child table. The reference contains a join whichlinks the primary key column STORE ID (the referenced column) to theforeign key column STORE ID (the referencing column).

Creating a reference

You can create a reference that links a primary key, or alternate key, to aforeign key, or user-specified columns in both parent and child tables.

Depending on its properties, a reference can link a parent table and a childtable in one of two ways:

Reference links Description

Primary key, alternatekey and foreign keys

Primary or alternate key in the parent table is linkedto a foreign key in the child table

User specifiedcolumns

One or more columns in the parent table are linked tocorresponding columns in the child table. The linkedcolumns in both tables are specified by the user, andare linked independently of primary key, alternatekey, and foreign key columns

86

Page 99: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

You can create a reference in any of the following ways:

♦ Use the Reference tool in the diagram Palette.

♦ Select Model ä References to access the List of References, and click theAdd a Row tool.

♦ Right-click the model or package in the Browser, and select New ä

Reference.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Automatic reuse and migration of columns

When you create a reference, PowerDesigner can automatically:

♦ Reuse an appropriate existing column in the child table as the foreign keycolumn

♦ Migrate the primary key column in the parent table to create a foreign keycolumn in the child table

v To auto-reuse and/or auto-migrate columns

1. Select Tools ä Model Options to open the Model Options dialog box.

2. Select the Reference sub-category in the left-hand Category pane todisplay the Reference tab.

87

Page 100: Physical Data Model - SAP

References (PDM)

3. Specify your choices for column reuse and migration as follows:♦ To auto-reuse existing columns in child tables as foreign key

columns when creating references - select the Auto-reuse columnscheck box. Note that the column in the child table must have the samecode as the migrating primary key column, and cannot already be aforeign key column for it to be suitable for reuse. If you want to reusea child table column that is already a foreign key column, you must dothis manually from the Joins tab of the reference property sheet.

♦ To auto-migrate primary key columns in parent tables for use asforeign key columns in child tables - select the Auto-migratecolumns check box. This will also enable the column properties checkboxes, allowing you to specify which of the parent column propertiesto migrate.

♦ To auto-migrate the properties of parent table primary keycolumns - select the appropriate check boxes:

• Domains• Check (check parameters)• Rules (business rules)• Last position (migrated columns should be added at the end of the

table column list. If the Last position option is not selected, migratedcolumns are inserted between key columns and other columns whichimplies that a child table must be dropped and recreated each timeyou add a reference and modify an existing database.)

Note that, during intermodel generation, whether or not the Auto-migratecolumns check box is selected, any selected column property is migratedfrom the PK to the FK.

4. Ensure that the Default link on creation option is set to Primary key.

5. Click OK to close the Model Options dialog box.

Examples

The following examples illustrate how using the auto-reuse columns andauto-migrate columns options affects the creation of references.

Matching child tablecolumn exists

The following table shows the results of migrating primary key columns to achild table that contains a matching column for one of the primary keycolumns. The original two tables are also shown below:

88

Page 101: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Auto-reuse Auto-migrate

Result Description ofchild table

Selected Selected Col_1 is reusedand Col_2 is cre-ated

Not selected Selected T1_Col_1 is cre-ated and Col_2 iscreated

Selected Not selected Col_1 is reusedand Col_2 is notcreated

Not selected Not selected No column isreused and nocolumn is created

Matching child tablecolumn is already a FKcolumn

The following table shows the results of migrating primary key columns to achild table that contains a matching child table column that is already aforeign key column for another table. The original two tables are also shownbelow:

Auto-reuse Auto-migrate

Result Description ofchild table

Selected Selected T1_Col_1 is cre-ated and Col_2 iscreated

Not selected Selected T1_Col_1 is cre-ated and Col_2 iscreated

Selected Not selected No columns arereused or created

Not selected Not selected No columns arereused or created

Notes:

89

Page 102: Physical Data Model - SAP

References (PDM)

♦ By default, only the properties of the primary key column are migrated tothe foreign key. If the primary key column is attached to a domain, thedomain will not be migrated to the new foreign key column unless theEnforce non-divergence option model option is selected (see ““Enforcingnon-divergence from a domain in a PDM” on page 68”).

♦ The following table shows the results of changing references when youhave selected the auto-migrate columns option:

Action Result

Modify referenceattach point

Migrate primary key in parent table to foreign keyin child table

Delete unused foreign key columns

Modify reference join

Delete primary key Delete corresponding foreign key and referencejoin

Migrate primary key in parent table to foreign key in child table

Delete unused foreign key columns

Modify reference join

Action Result

Modify referenceattach point

Migrate primary key in parent table to foreign key inchild table

Delete unused foreign key columns

Modify reference join

Delete primary key Delete corresponding foreign key and reference join

+ For more information on other model options for references, see the“Setting PDM Model Options” section in the “Customizing the PDMEnvironment” chapter.

Reference properties

You can modify an object’s properties from its property sheet. To open areference property sheet, double-click its diagram symbol or its Browserentry in the References folder. The following sections detail the propertysheet tabs that contain the properties most commonly entered for references.

Reference property sheet General tab

The General tab contains the following properties:

90

Page 103: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the reference

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Parent table Parent table of the reference. This table contains the primarykey, or alternate key, linked by the reference. You can usethe tools to the right of the list to create an object, browsethe complete tree of available objects or view the propertiesof the currently selected object

Parent role Role of the parent table in the reference. The text is displayedin the diagram, near the parent table

Child table Child table of the reference. This table contains the foreignkey linked by the reference

Child role Role of the child table in the reference. The text is displayedin the diagram, near the child table

Generate When selected, indicates to generate the reference in thedatabase

Reference property sheet Joins tab

A join is a link between a column in a parent table and a column in a childtable (column pair) that is defined within a reference.

A join can link primary key, or alternate key, and foreign key columns, oruser specified columns in the parent and child tables that are independent ofkey columns.

Default joins at referencecreation

Join creation is determined by the following Model Options:

91

Page 104: Physical Data Model - SAP

References (PDM)

Default Link onCreation

Auto-migrateColumns

Result

Primary Key Selected Joins created between primary andforeign key columns

Not selected Joins are created that are linked toprimary key columns, but are incom-plete. Foreign key columns must bespecified manually

User-defined Selected No joins created. Parent and childtable column pairs must be specifiedmanually

Not selected No joins created. Parent and childtable column pairs must be specifiedmanually

Linking columns in aprimary or alternate key

For any reference you can choose to link a primary key, or alternate key, to acorresponding foreign key. When you select a key from the Joins tab of thereference property sheet, all the key columns are linked to matching foreignkey columns in the child table.

Changing a foreign key column linkA foreign key column can also be changed to link to another parent tablecolumn, either within the key relationship, or independent of it.

Reuse and Migrationoption for a selectedreference

You can use the following buttons on the Joins tab to reuse or migratecolumns linked by joins.

Button Name Description

Reuse Columns Reuse existing child columns with same codeas parent table columns

Migrate Columns Migrate key columns to foreign key columns.If columns do not exist they are created

Cancel Migration Delete any migrated columns in child table

Auto arrange join order The join order can be established automatically or manually by using theAuto Arrange Join Order check box. The Auto Arrange Join Order checkbox is grayed if the reference is not joined to a key.

Selecting or clearing the Auto arrange join order check box has thefollowing effects:

92

Page 105: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Auto ArrangeJoin Order

Effect

Checked Sorts the list according to the key column order (the movebuttons are not available)

Cleared Allows you to manually sort the join order with the movebuttons (the move buttons are available)

v To define joins in a reference

1. Double-click a reference in the diagram to display its property sheet andclick the Joins tab.

2. Select a key from the Parent Key list to create joins between primary key,or alternate key, and foreign key columns.

or

Select <NONE> from the Parent Key list to create joins betweenuser-specified columns. If you select <NONE>, the column lists areempty.

The columns linked by the joins are listed in the Parent Table and ChildTable columns. A Joins tab with a selected Parent Key is shown below:

93

Page 106: Physical Data Model - SAP

References (PDM)

Changing a foreign key column linked by a joinYou can change the foreign key column linked by a join by clicking thecolumn in the Child Table list, and selecting another column from thelist.

3. [Optional] If you selected <NONE> from the Parent Key list, click theParent Table Column and select a column from the list, then click theChild Table Column and select a child column.

4. [Optional] Select or clear the Auto arrange join order check box.

A Joins tab with a selected parent key and selected Auto arrange joinorder check box is shown below:

94

Page 107: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Enabling the Auto arrange join order check boxTo enable this check box, add an EnableChangeJoinOrder item tothe Reference category in the DBMS definition file and set the value toYES.

5. Click OK.

For information on adding an item to the Reference category, see chapterDBMS Reference Guide in the Advanced User Documentation .

Reference property sheet Integrity tab

Referential integrity is a collection of rules that govern data consistencybetween primary keys, alternate keys and foreign keys. It dictates whathappens when you update or delete a value in a referenced column in theparent table, and when you delete a row containing a referenced columnfrom the parent table.

The Integrity tab contains the following properties:

95

Page 108: Physical Data Model - SAP

References (PDM)

Property Description

Constraintname

Name of the referential integrity constraint. Maximumlength is 254 characters

Implementation Specifies how referential integrity will be implemented.You can choose between:♦ Declarative- Referential integrity constraints are de-

fined for particular references. When the reference isgenerated the target DBMS evaluates the reference va-lidity and generates appropriate error messages

♦ Trigger - Referential integrity constraints are imple-mented by triggers based on the integrity constraintsdefined in the reference property sheet. The triggerevaluates reference validity and generates appropriateuser-defined error messages

Cardinality Indicates the minimum and maximum number of instancesin a child table permitted for each corresponding instancein the parent table. The following values are available bydefault:♦ 0..* - A parent can have zero or more children. There

is no maximum.

♦ 0..1 - A parent can have zero or one children.

♦ 1..* - A parent can have one or more children. There isno maximum.

♦ 1..1 – A parent must have exactly one childAlternately, you can enter your own integer values in oneof the following formats:♦ x..y - A parent can have between x and y children.

♦ x - A parent can have exactly x children.

♦ x..y, a..b - A parent can have between x and y or be-tween a and b children.

You can use * or n to represent no limit.

Examples:♦ 2..n – There must be at least 2 children.

♦ 10 - There must be exactly 10 children.

♦ 1..2, 4..n – There must be one, two, four or more chil-dren.

User-defined Indicates a user-defined constraint name

96

Page 109: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Property Description

Update con-straint

How updating a key value, in the parent table affects theforeign key value in the child table. Depending on theimplementation and DBMS, you can choose between:♦ None - Update or deletion of a value in the parent table

has no effect on the child table.

♦ Restrict - A value in the parent table cannot be updatedor deleted if one or more matching child values exists

♦ Cascade - Update or deletion of a value in the parenttable causes an update or delete of matching values inthe child table

♦ Set null - Update or deletion of a value in the parenttable sets matching values in the child table to NULL

♦ Set default - Update or deletion of a value in the par-ent table sets matching values in the child table to thedefault value

Delete con-straint

How deleting a row in the parent table affects the childtable

Mandatory par-ent

Each foreign key value in the child table must have acorresponding key value, in the parent table

Change parentallowed

A foreign key value can change to select another value inthe referenced key in the parent table

Check on com-mit

[Sybase SQL Anywhere 5.0 and 5.5 only] Verifies refer-ential integrity only on the commit, instead of verifyingit after row insertion. You can use this feature to controlcircular dependencies

Cluster Indicates whether the reference constraint is a clusteredconstraint (for those DBMS that support clustered indexes)

Rebuilding references

You can rebuild references to create default references between PK columnsin one table and columns with identical code and data type in another table.Note that rebuilding is not possible between two tables with PK columns.

Rebuilding references is useful following the reverse engineering of adatabase in which all of the references could not be reverse engineered.

97

Page 110: Physical Data Model - SAP

References (PDM)

v To rebuild references

1. Select Tools ä Rebuild Objects ä Rebuild References to open theRebuild References dialog box.

2. Select a mode:♦ Delete and Rebuild - All existing references are deleted, and new

references built based on matching key columns

♦ Preserve - All existing references are kept, and new references are builtbased on new matching key columns

3. [optional] Click the Selection tab and specify the tables for which youwant to rebuild references. By default, all tables are selected.

Rebuilding references in a packageTo rebuild references between tables in a package, select the packagefrom the list at the top of the tab.

To rebuild references between tables in a sub-package, select the IncludeSub-Packages icon next to the list, and then select a sub-package fromthe dropdown list.

4. Click OK. If you selected the Delete and Rebuild mode, a confirmationbox asks you to confirm your choice. Click Yes to confirm the deletionand rebuild of the selected references.

98

Page 111: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Changing a table at either end of a reference

After reference creation you can change one table, or both of the tables,linked by a reference, using one of the following methods:

♦ Click the reference and hold down CTRL as you drag one of its attachpoints to a different table.

♦ Double-click a reference in the diagram to display its property sheet andchoose a different parent or child table from the lists.

♦ Select Model ä References to open the list of references, and choose adifferent parent or child table from the lists.

Modifying a reference graphically

You can modify a reference symbol as follows:

v To bend a reference symbol

1. Select Symbol ä Format to open the Symbol Format dialog box.

2. Click the Line Style tab and select the jagged line symbol from theCorners list.

3. Click OK to return to the diagram.

4. Press and hold CTRL while clicking the point on the reference where youwant to insert an angle.

A handle is added to the reference at the point clicked.

5. Release CTRL. You can now drag the handle to create the desired angle.

v To straighten a reference symbol

1. Click a reference symbol that has one or more angles to make its handlesappear.

2. Press and hold CTRL while clicking a handle to remove the handle andangle.

99

Page 112: Physical Data Model - SAP

References (PDM)

v To drag a reference to a different table

1. Click a reference symbol.

2. Press and hold CTRL while dragging one of the symbol ends to a newtable.

You can set the global display mode for references by clicking Tools ä

Model Options and selecting a notation from the list. PowerDesignersupports Relational, CODASYL, Conceptual and IDEF1X notations.

100

Page 113: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Views (PDM)A view is an alternative way of looking at the data in one or more tables. It ismade up of a subset of columns from one or more tables.

You define a SQL query for each view.

Creating a view

You can create a view in any of the following ways:

♦ Use the View tool in the diagram Palette.

♦ Select Model ä Views to access the List of Views, and click the Add aRow tool.

♦ Right-click the model or package in the Browser, and select New ä View.

♦ Select Tools ä Create View. For more details, see “Creating a view fromthe Tools menu” on page 105. You can, optionally, pre-select one or moretables and views in the diagram to create a view automatically populatedwith their columns.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

View properties

You can modify an object’s properties from its property sheet. To open aview property sheet, double-click its diagram symbol or its Browser entry inthe Views folder. The following sections detail the property sheet tabs thatcontain the properties most commonly entered for views.

View property sheet General tab

The General tab contains the following properties:

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the view

101

Page 114: Physical Data Model - SAP

Views (PDM)

Property Description

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Owner Name of view owner. You choose an owner from a list ofusers. A view can only have one owner at a time. This isnormally the view creator

Usage Defines the use of the view: Query only defines a viewfor consultation only, view cannot update tables; Updatabledefines a view for consultation and update, view can updatetables; and With Check options implements controls on viewinsertions

Dimensionaltype

Indicates the multidimensional type of the view, that isDimension or Fact

Type For those DBMS that support it, allows you to define thetype of a view. You can select materialized query table,materialized view, summary table, or XML

Generate Includes view generation as part of database generationscript

User-defined When selected, makes sure the view query is not parsed byPowerDesigner internal parser. This protects the view queryfrom any update using model objects and keeps its syntaxas defined by user. Otherwise, the view query is parsed andmodified according to model values

+ For more information on materialized views, materialized query tables,and summary tables, see “Creating a query table” on page 112.

+ For more information on XML views, see “Creating an XML table orview” on page 29.

View property sheet Columns tab

The Columns tab in a view property sheet displays the list of columns in theview. This list of columns reflects the SELECT orders from the queries ofthe current view. The only way to add or remove columns from this list is tomodify the query of the view.

+ For more information on how to define the query of a view, see“Creating, editing, and deleting queries associated with views” on page 106.

102

Page 115: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

If the view was created from one or several tables or views The name,code, description and data type of the view column are those of thecorresponding column in the linked table or view.

If the view is user-defined It implies the view is not linked to anotherobject. The name and code of the view column comes from the columnname in the first query in the view definition. For example, MyView isdefined by the following queries:

select Name, Commentfrom Propertyunionselect Signature, Bodyfrom Method

Only the two columns of the first query are used to create the correspondingview columns:

In this case, if you modify the view column code, the view creation scriptwill reflect the change. In our example, if you rename Name in ClientName,the view creation script is the following:

create view MYVIEW (ClientName, "Comment") asselect Name, Commentfrom Property

View column properties When you select a column in the list of view columns and click theProperties tool in the toolbar, the view column property sheet is displayed.You can define the following properties from the view column propertysheet:

103

Page 116: Physical Data Model - SAP

Views (PDM)

Property Description

Name Name of the view column. This name is automaticallycalculated. If you choose to modify the default name, theUser-defined button is selected and the Custom Name columndisplays the user-defined name. You can recover the defaultname by clicking again the User-defined button

Code Code of the view column. The code is automatically cal-culated. If you choose to modify the default code, theUser-defined button is selected and the Custom Code columndisplays the user-defined code. You can recover the defaultcode by clicking again the User-defined button

Comment Comment of the view column. This comment is automaticallycalculated from the column comment in the original table orview. If you choose to modify the default comment, theUser-defined button is selected. You can recover the defaultcomment by clicking again the User-defined button

Stereotype View column stereotype

Data Type View column data type. This data type is automaticallycalculated from the column data type in the original tableor view. If you choose to modify the default data type, theUser-defined button is selected. You can recover the defaultdata type by clicking again the User-defined button

Length Maximum length of the data type

Precision Maximum number of places after the decimal point

You can also define notes and business rules on a view column.

User-defined name orcode

You can modify the name and the code of a view column from the list. Ifyou need to recover the name or code default value, you have to clear thecorresponding cell in the list, the default name or code is automaticallyrestored.

View property sheet SQL Query tab

The SQL Query tab displays the SQL code for all the queries associatedwith the view. You can edit this code directly in this tab or access theproperty sheets of individual queries. For more information, see “Creating,editing, and deleting queries associated with views” on page 106.

104

Page 117: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

View property sheet Triggers tab

The Triggers tab is only displayed if your DBMS supports triggers on views.

View triggers can make the view behave like a table. You can define a triggerto fire when one or more attributes of a table view column are modified.

v To create a trigger on a view

1. Open the view property sheet and click the Triggers tab.

2. Click the Add a Row tool, and then click the Properties tool to open theproperty sheet of the newly-created trigger.

3. Click the Definition tab. The trigger time type will be set to “instead of”.

4. Write a trigger from scratch or select a trigger template. For more detailsabout writing triggers, see the chapter “Building Triggers andProcedures”

View property sheet Preview tab

The Preview tab displays the SQL code associated with the view. For moreinformation, see “Previewing SQL statements” in the Physical Data ModelBasics chapter.

Creating a view from the Tools menu

You can create a view from the Tools menu. This method allows you toautomatically populate the view with columns from tables and other views

v To create a view from the Tools menu

1. [optional] Select one or more tables and views in the diagram. You canselect multiple objects by holding down the SHIFT key while you selectthem.

2. Select Tools ä Create View.

If you have not selected any tables or views, then a selection box opens,allowing you to select the objects to be included in the view.

105

Page 118: Physical Data Model - SAP

Views (PDM)

Select the appropriate objects and then click OK.

A view symbol is displayed in the diagram. It displays all the columns ineach of the tables and views selected for the view. The names for thetables and views appear at the bottom of the view symbol.

Creating, editing, and deleting queries associated with views

You can edit queries associated with a view from the SQL Query tab of theview property sheet.

106

Page 119: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Any number of queries may be associated with a view, and the totality oftheir SQL statements is shown in this tab, linked by any of the standard SQLconstructs, such as Union, etc.

Editing query code in the SQL Query tab

You can edit the code shown in the SQL Query tab in any of the followingways:

♦ Edit the code directly in the tab

♦ Click the Edit with SQL Editor tool to open the code in PowerDesigner’sbuilt-in SQL Editor. The SQL Editor provides a more complete querydefinition environment than the SQL query tab, including access tostandard SQL constructs and syntax tools for functions and operators (see“Defining queries with the SQL Editor” in the Physical data ModelBasics chapter).

♦ Click the Edit with tool (CTRL+E) to open the code in your favoriteeditor

Any edits you make in the SQL Query tab will propagate to the propertysheets of the associated individual queries (see “Opening the property sheetof a query” on page 108).

Query list The individual queries associated with the view are available from the Query

107

Page 120: Physical Data Model - SAP

Views (PDM)

list at the bottom of the SQL Query tab. You can create and delete queriesusing the tools at the bottom of the tab.

v To create a new query in the Query list

1. Click the Add a query tool to the right of the Query list (you can specifythe way in which the new query will be linked with the other queries byclicking the arrow to the right of the tool and selecting one of theconstructs listed below).

The new query’s property sheet opens.

2. Enter the query code and click OK.

The new query is added to the Query list in the View property sheet SQLQuery tab, and its code is added to the tab.

The following SQL constructs are available for linking queries inPowerDesigner (depending on your DBMS):

Construct Result Example

Union [de-fault]

Displays all the data retrieved by both thequeries, except where results are repeated.

SELECT 1: ABCSELECT 2: BCDResult: ABCD

Union All Displays all the data retrieved by both thequeries, including repeated results.

SELECT 1: ABCSELECT 2: BCDResult: ABCBCD

Intersect Displays only the data retrieved by boththe queries.

SELECT 1: ABCSELECT 2: BCDResult: BC

Minus Displays only the data retrieved by one orother of the queries, but not by both.

SELECT 1: ABCSELECT 2: BCDResult: AD

v To delete a query from the Query list

1. Select the query in the Query list.

2. Click the Delete tool to the right of the Query list.

The query is removed from the Query list and its code deleted from thetab.

Opening the property sheet of a query

Each query associated with a view has its own property sheet, whichcontains the following tabs:

108

Page 121: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

♦ SQL (see “Query property sheet SQL tab” on page 109)

♦ Tables (see “Query property sheet Tables tab” on page 109)

♦ Columns (see “Query property sheet Columns tab” on page 110)

♦ Where (see “Query property sheet Where tab” on page 110)

♦ Group By (see “Query property sheet Group By tab” on page 111)

♦ Having (see “Query property sheet Having tab” on page 111)

♦ Order By (see “Query property sheet Order By tab” on page 112)

You can manipulate each of these clauses using the lists in these tabs, andany changes you make will propagate to the other tabs and the SQL Querytab of the parent view (see “Editing query code in the SQL Query tab” onpage 107).

v To open a query’s property sheet from the Query list

1. Select the query in the Query list.

2. Click the Properties tool to the right of the Query list.

Query property sheet SQL tab

This tab displays the SQL code for the query.

You can edit the code of an individual query in its SQL tab in any of thefollowing ways:

♦ Edit the code directly in the tab

♦ Click the Edit with SQL Editor tool to open the code in PowerDesigner’sbuilt-in SQL Editor (see “Defining queries with the SQL Editor” in thePhysical data Model Basics chapter).

♦ Click the Edit with tool (CTRL+E) to open the code in your favoriteeditor

Any edits you make in the SQL tab will propagate to the query’s “clause”tabs and the SQL Query tab of the parent view (see “Editing query code inthe SQL Query tab” on page 107).

Query property sheet Tables tab

This tab lists the tables in the FROM clause, which specify where the querydata will be drawn from.

109

Page 122: Physical Data Model - SAP

Views (PDM)

You can add or delete tables as appropriate, and reorder the tables in the listusing the arrows at the bottom of the tab.Any changes you make willpropagate to the query’s SQL tab and to the SQL Query tab of the parentview.

v To add a table

1. Click in the first empty row in the list.

2. Select a table from the list. To enter a more complex expression via theSQL Editor, click the ellipsis button to the right of the list.

3. [optional] Enter an alias for the table in the Alias column.

Query property sheet Columns tab

This tab lists the columns in the SELECT clause, which specify what datawill be displayed in the query.

You can add or delete columns as appropriate, and reorder the columns inthe list using the arrows at the bottom of the tab. Any changes you make willpropagate to the query’s SQL tab and to the SQL Query tab of the parentview.

v To add a column

1. Click in the first empty row in the list.

2. Select a column from the list. You can add all the columns in a table byselecting a list entry with the table name followed by an asterisk. To entera more complex expression via the SQL Editor, click the ellipsis button tothe right of the list.

3. [optional] Enter an alias for the column in the Alias column.

Query property sheet Where tab

This tab lists the expressions in the WHERE clause, which restrict the dataretrieved by the query.

You can add or delete expressions as appropriate, and reorder theexpressions in the list using the arrows at the bottom of the tab. Any changesyou make will propagate to the query’s SQL tab and to the SQL Query tab ofthe parent view.

110

Page 123: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

v To add an expression

1. Click in the first empty row in the list.

2. [optional] Enter a prefix in the Prefix column.

3. In the first Expression column, select a column from the list. To enter amore complex expression via the SQL Editor, click the ellipsis button tothe right of the list.

4. In the Operator column, select an operator from the list.

5. In the second Expression column, select a column from the list. To entera more complex expression via the SQL Editor, click the ellipsis button tothe right of the list.

6. [optional] Enter a suffix in the Suffix column.

Query property sheet Group By tab

This tab lists the columns in the GROUP BY clause, which control how thedata retrieved by the query will be grouped.

You can add or delete columns as appropriate, and reorder the columns inthe list using the arrows at the bottom of the tab. Any changes you make willpropagate to the query’s SQL tab and to the SQL Query tab of the parentview.

v To add a column

1. Click in the first empty row in the list.

2. Select a column from the list. To enter a more complex expression via theSQL Editor, click the ellipsis button to the right of the list.

Query property sheet Having tab

This tab lists the expressions in the HAVING clause, which restrict the datareturned by a query with a GROUP BY clause.

You can add or delete expressions as appropriate, and reorder theexpressions in the list using the arrows at the bottom of the tab. Any changesyou make will propagate to the query’s SQL tab and to the SQL Query tab ofthe parent view.

111

Page 124: Physical Data Model - SAP

Views (PDM)

v To add an expression

1. Click in the first empty row in the list.

2. [optional] Enter a prefix in the Prefix column.

3. In the first Expression column, select a column from the list. To enter amore complex expression via the SQL Editor, click the ellipsis button tothe right of the list.

4. In the Operator column, select an operator from the list.

5. In the second Expression column, select a column from the list. To entera more complex expression via the SQL Editor, click the ellipsis button tothe right of the list.

6. [optional] Enter a suffix in the Suffix column.

Query property sheet Order By tab

This tab lists the columns in the ORDER BY clause, which control the wayin which the data retrieved by the query will be sorted.

You can add or delete columns as appropriate, and reorder the columns inthe list using the arrows at the bottom of the tab. Any changes you make willpropagate to the query’s SQL tab and to the SQL Query tab of the parentview.

v To add a column

1. Click in the first empty row in the list.

2. In the Column column, select a column from the list. To enter a morecomplex expression via the SQL Editor, click the ellipsis button to theright of the list.

3. In the Sort Direction column, select either ASC or DESC.

Creating a query table

A query table is a table whose data proceeds from the result of a query. InPowerDesigner, you design a query table using a view with a specific type,depending on the DBMS.

DB2 In DB2 CS7, you design a query table using a view with the summary tabletype. In later versions of DB2, you should use the materialized query tabletype.

112

Page 125: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

+ For more information on summary tables and materialized views, seeDB2 documentation.

Oracle In Oracle, you design a query table using a view with the materialized viewtype. Materialized view is the new recommended name for snapshots thatwere used before version 8i.

+ For more information on materialized views and snapshots, see Oracledocumentation.

You define a view as a query table by selecting the query table ormaterialized view type in the view property sheet.

The query creation order of DB2 summary table is of type:

create summary table VIEW_1 as...

The query creation order of DB2 materialized query table is of type:

create table VIEW_1 as...

The query creation order of Oracle materialized view is of type:

create materialized view VIEW_1 as...

113

Page 126: Physical Data Model - SAP

Views (PDM)

The query creation order of an Oracle snapshot is of type:

create snapshot VIEW_1 as...

If you change the DBMS of a model containing query tables, these areconverted into regular views.

Physical options Query tables support physical options. When you select a query table type inthe view property sheet, the Options tab automatically is displayed to let youdefine physical options for view generation.

Using extended dependencies for views

Extended dependencies are links between physical diagram objects. Theselinks help to make object relationships clearer between model objects but arenot interpreted and checked by PowerDesigner as they are meant to be usedfor documentation purposes only.

You can complement these links by applying stereotypes.

You can type stereotypes directly in the Stereotype column of the objectproperty sheet or select a value from the list if you have previously definedstereotypes in an embedded or imported extended model definition (.XEM).

You can use extended dependencies between a view and tables links in themodel.

Example A view identified as Book Sales can have two extended dependenciesindicating that the view depends on the Title and Sale tables. The diagramdisplays their extended dependencies and stereotypes.

114

Page 127: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

For more information on extended model definitions, see Extended ModelDefinitions in chapter Physical Data Model Basics.

+ For more information on extended dependencies, see Using ExtendedDependencies in the General Features Guide.

Defining a generation order for views

You can use extended dependencies to define an order in the generation ofviews.

Extended dependencies are free links between PDM objects. These linkshelp to make object relationships clearer between model objects. Usually,these links are not interpreted and checked by PowerDesigner as they aremeant to be used for documentation purposes only. However, if you assignthe <<DBCreateAfter>> stereotype to an extended dependency betweenviews, it will be analyzed during generation.

The view from which you start the extended dependency is the dependentview and the view at the other end of the link is the influent view. Theinfluent view will be generated before the dependent view.

Circular extendeddependencies

If you create a reflexive and/or circular set of extended dependencies withthe <<DBCreateAfter>> stereotype, an error message is displayed

115

Page 128: Physical Data Model - SAP

Views (PDM)

during the check model. If you choose to ignore this error, the views will begenerated in alphabetical order, without taking into account the generationorder, which could cause errors in the creation of views in the database.

Example You create the view DEPARTMENT STORE from the table STORE. Theview retrieves information from the table as you can check in the SQL Querytab of the view property sheet:

You decide to create another view called COMPUTER COUNTER to showonly part of the department store offer. This view is created from the viewDEPARTMENT STORE, and retrieves information from it.

By default views are generated in alphabetical order, so the generation ofCOMPUTER COUNTER will fail since the view DEPARTMENT STOREfrom which it depends is not generated. To bypass this problem, you cancreate a extended dependency with the <<DBCreateAfter>> stereotypefrom COMPUTER COUNTER to DEPARTMENT STORE.

This allows you to set an order in the generation of views: DEPARTMENTSTORE will be generated before COMPUTER COUNTER.

116

Page 129: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

You can create an extended dependency between views from the list ofviews or from the diagram.

+ For more information on how to create views from a list, see the“Defining a generation order for stored procedures” section in the BuildingTriggers and Procedures chapter.

v To define a generation order for views from the diagram

1. Select the Extended Dependencies tool in the palette.

2. Click inside the dependent view and while holding down the mousebutton, drag the cursor into the influent view. Release the mouse button.

3. Double-click the extended dependency link.

The dependent view property sheet opens to the Extended Dependenciestab. you can check that the influent view is displayed in the InfluentObject column of the list of extended dependencies.

4. Click inside the Stereotype column, click the down arrow and select<<DBCreateAfter>> in the list.

5. Click OK.

+ For more information on extended dependencies, see Using ExtendedDependencies in the General Features Guide .

117

Page 130: Physical Data Model - SAP

View References (PDM)

View References (PDM)A view reference is a link between a parent table or view and a child tableor view. It is used to define a set of predefined joins between the columns ofthe parent and the child table or view.

View references are not generated in the database.

Example Table Orders is the parent of view Customer_Order.

Creating a view reference

You can create a view reference between two views or between a table and aview. A view reference cannot link two tables.

You can create a view reference in any of the following ways:

♦ Use the Reference tool in the diagram Palette.

♦ Select Model ä View References to access the List of View References,and click the Add a Row tool.

♦ Right-click the model or package in the Browser, and select New ä ViewReference.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

+ For more information about manipulating view references, see“Changing a table at either end of a reference” on page 99 and “Modifying areference graphically” on page 99.

View reference properties

You can modify an object’s properties from its property sheet. To open aview reference property sheet, double-click its diagram symbol or itsBrowser entry in the View References folder. The following sections detail

118

Page 131: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

the property sheet tabs that contain the properties most commonly enteredfor view references.

View reference property sheet General tab

The General tab contains the following properties:

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the view reference

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Parent Parent table or view of the view reference. You can use thetools to the right of the list to create an object, browse thecomplete tree of available objects or view the properties ofthe currently selected object

Parent role Role of the parent table or view in the view reference. Thetext is displayed in the diagram, near the parent table or view

Child Child table or view of the view reference. You can use thetools to the right of the list to create an object, browse thecomplete tree of available objects or view the properties ofthe currently selected object

Child role Role of the child table or view in the view reference. Thetext is displayed in the diagram, near the child table or view

A view reference also includes joins, that are links between parent columnsand child columns.

Defining view reference joins

A join is a link between a column in a parent table or view and a column in achild table or view that is defined within a view reference.

If you create a new view from existing views, the joins defined on theseviews influence the WHERE statement in the SQL query of the new view.

119

Page 132: Physical Data Model - SAP

View References (PDM)

Example

French_Store is a view of table Store. You define a join between Store_ID inthe table and STORE_STORE_ID in the view.

Customer_Orders is a view of table Orders. You define a join betweenOrder_No in the table and ORDER_ORDER_N in the view.

You create a view reference between French_Store and Customer_Order inwhich you define a join between ORDER_ORDER_STORE andSTORE_STORE_ID. This is to establish a correspondence between the storeID and the store where the order is sent.

If you create a view from French_Store and Customer_Orders, you cancheck in the SQL query tab of the view that the SELECT order takes intoaccount the join defined between the views. The SELECT statement willretrieve orders sent to French stores only.

In the Joins tab of a view reference property sheet, you can use the ReuseColumns tool to reuse existing child columns with same code as parentcolumns.

120

Page 133: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

v To define joins in a view reference

1. Double-click a view reference in the diagram to display the viewreference property sheet.

2. Click the Joins tab to display the Joins tab.

3. Click the Reuse Columns tool to reuse existing child columns with samecode as parent columns.

or

Click the Add a Row tool.

A join is created but you have to define the parent and child columns.

4. Click in the Parent Column column and select a column in the list.

5. Click in the Child Column column and select a column in the list.

6. Click OK.

121

Page 134: Physical Data Model - SAP

Check Parameters (PDM)

Check Parameters (PDM)Check parameters are set of conditions which data must satisfy to remainvalid.

There are three types of check parameters:

Parametertype

Description Can be at-tached to

Standardcheck pa-rameters

Common data constraints which define adata range. For example minimum andmaximum values for a column

Columns

Domains

Additionalcheck param-eters

SQL expression defining a data constraintusing the %MINMAX%, %LISTVAL%, and%RULES% variables that are instantiatedwith standard parameter values

Columns

Domains

Validationrule

Business rule that is defined as a serverexpression, and is attached to one of thefollowing listed objects

Tables

Columns

Domains

Setting standard check parameters for objects in a PDM

Standard parameters indicate common data constraints. The following tablelists standard parameters:

Parameter Description

Minimum Lowest acceptable numeric value

Maximum Highest acceptable numeric value

Default Value selected from a list of default values or typedin the listbox. The list of values is defined in theScript\Keywords\ReservedDefault entry of the DBMSdefinition file

Format Data format (for example, 9999.99)

Unit Standard measure

Lowercase Forces all alphabetical characters to lowercase

Uppercase Forces all alphabetical characters to uppercase

Cannot Modify Protects from changes, results in a non-modifiable columnin the table when generated in the database

122

Page 135: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Parameter Description

List of Values Authorized values

Label String that identifies an authorized value in the list

+ For more information on defaults, see “Defaults (PDM)” on page 58.

v To set standard parameters

1. Open the property sheet of a domain or column and click the StandardChecks tab.

2. Enter the appropriate standard parameters, and then click OK.

+ See also “Managing quotation marks around values” on page 125.

Defining additional check parameters for objects in a PDM

You define additional check parameters for data constraints where standardcheck parameters are not sufficient.

Example A table in a data model for a clothing shop may contain check parametersdefined for a column SIZE, which depend on the check parameters defined

123

Page 136: Physical Data Model - SAP

Check Parameters (PDM)

on another column CLOTHING TYPE, as clothing size for a skirt in onecountry may be different from the same size in another country.

In this case an expression is required to create a constraint which uses checkparameters defined for both columns.

v To define additional check parameters

1. Open the property sheet of a domain or column and click the AdditionalChecks tab.

2. Type a SQL expression, which may include any of the followingvariables:

♦ %MINMAX% - Minimum and maximum values defined in Valuesgroupbox on Standard Checks tab

♦ %LISTVAL% - Customized values defined in List Values groupbox onStandard Checks tab

♦ %RULES% - Validation rule expression defined on Expression tab ofthe Rules property sheet

3. Click OK.

Using a validation rule in check parameters in a PDM

A validation rule is a rule that validates data based on a corresponding

124

Page 137: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

business rule. A validation rule can be generated as a check parameter whenthe following conditions apply:

♦ Validation rule is attached to a table, column, or domain

♦ Validation rule is defined as a server expression

At generation, validation rule variables are instantiated with the followingvalues:

Variable Value

%COLUMN% Code of the column to which the business rule applies

%DOMAIN% Code of the domain to which the business rule applies

%TABLE% Code of the table to which the business rule applies

%MINMAX% Minimum and maximum values for the column ordomain

%LISTVAL% List values for the column or domain

%RULES% Server validation rules for the column or domain

+ For more information on defining business rules, see the Using BusinessRules in a PDM chapter.

v To use a validation rule in check parameters

1. Open the property sheet of a table, domain, or column, and click theRules tab.

2. Click the Add Objects button to open a selection box, and select abusiness rule in the list.

3. Click OK in each of the dialog boxes.

Validation rule expressionsYou must click the Rules button to modify the expression attached to avalidation rule. You can also modify validation rule expressions fromthe list of business rules, by clicking the Define button.

Managing quotation marks around values

For a domain or a column, standard parameters can indicate minimum,maximum, and default values as well as a list of values.

In general, if the data type of domain or column is a string data type,quotation marks surround its values in the generated script. The generationof single or double quotation marks depends on the target DBMS.

125

Page 138: Physical Data Model - SAP

Check Parameters (PDM)

However, quotation marks are not generated in the following cases:

♦ You define a data type that is not recognized as a string data type byPowerDesigner

♦ Value is surrounded by tilde characters

♦ Value is a keyword defined in the DBMS (for example, NULL)

In addition, if the value is already surrounded by quotation marks additionalquotation marks are not generated.

The following table shows the way a value for a string data type is generatedin a script:

Value for string data type Result in script

Active ‘Active’

‘Active’ ‘Active’

”Active” ‘”Active”’

~Active~ Active

NULL NULL

126

Page 139: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Physical OptionsA physical option is a parameter (included at the end of a Create statement)that defines how an object is optimized or stored in a database. Physicaloptions are not supported by all databases, and vary by DBMS. In ASA 6,for example, you can define physical options for tables, columns, indexes,tablespaces, and databases. Other DBMSs provide options for keys,storages, and sequences.

The syntax for a physical option depends on the DBMS. For example:

DBMS Tablespace option syntax

Oracle 6.0 or higher Tablespace

Sybase Adaptive Server Any-where

In

+ For more information about the syntax of physical options and how theyare controlled in the DBMS resource file, see “Physical Options” in theDBMS Reference Guide chapter of the Advanced User Documentation .

When you change DBMS, the physical option settings are applied as far aspossible to the new DBMS. If a specific physical option was selected in themodel, the default value is preserved for the option in the new DBMS.Unselected physical options are reset with the new DBMS default values.

PowerDesigner allows you to set:

♦ Default physical options for all the objects in the model (see “Definingdefault physical options” on page 127)

♦ Physical options for a specific object, which override the default physicaloption values (see “Defining physical options for individual objects” onpage 130)

Defining default physical options

Default physical options define physical options for all the objects of aparticular type in the model. The default physical options are stored in theDBMS definition file (see the “Physical Data Model Basics” chapter).

The values you assign for default physical options can be included in adatabase creation script that you generate from a PDM, or can be directlygenerated in the target database. You select the appropriate default physicaloptions from the Selection tab of the Database Generation dialog box.Physical option default values can also be reverse engineered from adatabase into a PDM.

127

Page 140: Physical Data Model - SAP

Physical Options

You can view the script for a physical option in the Preview tab for theobject for which it is defined.

v To define default physical options

1. Select Database ä Default Physical Options to display the DefaultPhysical Options dialog box. There is a tab for each kind of object thatsupports physical options. The Table tab opens by default:

2. The Syntax tab in the left pane lists the physical options available in theDBMS, and the right pane contains the physical options that have beenselected for the object.

3. To add an option for the object, select it in the list in the Syntax pane andclick the Add tool between the panes to copy it to the Items pane. To addonly a sub-parameter for the option, expand the option in the Syntaxpane, select the required parameter and then click the Add tool.

4. To set a value for a physical option parameter, select the parameter in thelist in Items pane and enter or select the appropriate value in the field thatis displayed below the pane. The entered value will then be displayedagainst the parameter in the Items list.

128

Page 141: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

5. Repeat the above steps as many times as necessary to specified all yourrequired physical options. By default, these options will be applied to alltables in the model. To specify that the options should apply to onlycertain of the existing tables, click the Apply to button to display aselection dialog. Select the tables that you want to apply the options tofrom the list and then click OK.

6. Select the other tabs to specify physical options for other option types.(Note that the Apply to button is not available on the Database tab).

7. Click OK to close the Default Physical Options dialog box.

The following tools are available for adding and removing physical optionsto an object:

Tool Action when clicked

Adds physical option selected in Syntax tab (left pane) to Items tab(right pane)

Aligns a selected physical option in the Items tab with the corre-sponding physical option in the Syntax tab

Removes physical option selected in Items tab

129

Page 142: Physical Data Model - SAP

Physical Options

Defining physical options for individual objects

+ You can set physical options for selected objects to override the defaultphysical options (see ““Defining default physical options” on page 127”).

+ There are two different interfaces for specifying physical options forindividual objects, both of which are accessible through tabs on the object’sproperty sheet:

♦ Physical Options (Common) – this tab is displayed by default (alongwith the Partition tab, if applicable), and lists the most commonly-usedphysical options in the format of a standard property sheet tab. You canenter values for the necessary option parameters and click OK

♦ Physical Options (All) – this tab is hidden by default, and lists all theavailable physical options for the object in a tree format. To display thistab, click the Property Sheet Menu button and select Customize FavoriteTabs ä Physical Options (All). You should follow the procedure in“Defining default physical options” on page 127, to modify theappropriate options.

+ Changes made on either of these tabs will be reflected on the other.

Tablespace and storage optionsYou can choose a tablespace or storage already defined in the model asa value for a tablespace or storage that you define for a table. These arelisted in a list below the right pane in the Options tab. In DB2 OS/390,tablespaces are, by default, prefixed by the name of the database attached tothe model (see the DBMS-Specific Features chapter). For more informationon defining tablespaces and storages, see the Generating a Database from aPDM chapter.

DBMS-specific information

The following table lists the objects for which physical options are availablewhen working with a particular DBMS:

130

Page 143: Physical Data Model - SAP

Chapter 2. Building Physical Diagrams

Database Objects supporting physical options

Sybase AS Anywhere Table, Index, Database, Tablespace

Sybase AS Enterprise Table, Index, Key, Database

IBM DB2 for CommonServer

Table, Column, Index, View, Storage, Tablespace

IBM DB2 for OS/390 Table, Column, Index, Database, Storage, Ta-blespace

Microsoft SQL Server Table, Index, Key, Database

Oracle Table, Key, Index, View, Join Index, Sequence,Database, Tablespace, Storage

For information about these options, see your database documentation.

131

Page 144: Physical Data Model - SAP
Page 145: Physical Data Model - SAP

CHAPTER 3

Building Multidimensional Diagrams

About this chapter This chapter describes how to build multidimensional diagrams, and how tocreate and modify the associated objects.

.

Contents Topic: page

Multidimensional Diagram Basics 134

Cubes (PDM) 138

Dimensions (PDM) 140

Attributes (PDM) 142

Facts (PDM) 145

Measures (PDM) 147

Hierarchies (PDM) 149

Associations (PDM) 151

133

Page 146: Physical Data Model - SAP

Multidimensional Diagram Basics

Multidimensional Diagram BasicsA multidimensional diagram is a model of business activities in terms ofcubes and dimensions. It organizes business data into one or other of thesecategories. Numeric values or measures such as sales total, budget limits, arethe facts of the business. The area covered by a business, in terms ofgeography, time, or products are the dimensions of the business.

The multidimensional diagram is used to design the cubes in an OLAPengine, together with the different analysis dimensions.

Business analysts use OLAP databases to send queries and retrieve businessinformation from the different dimensions existing in the database.

OLAP databases are populated with data from a data warehouse or data martdatabase. This data transfer is implemented via a relational tomultidimensional mapping, the data warehouse or data mart database beingthe data source of the OLAP database. The OLAP cube is designed tosupport multidimensional analysis queries, it is organized according touser-defined dimensions.

Multidimensional analysis queries usually involve calculated lists, such asgrowth and decline rates and time-based comparisons. They aim at detectingtrends and relationships. These types of queries are supported by an OLAPdatabase, but not by an operational database.

+ For more information on the relational to multidimensional mapping,see the “Defining a relational to relational mapping” section in the Workingwith PDMs chapter.

Example Sales data can have the dimensions product, region, customer, and store.Facts, for example, the sales totals, are viewed through the user-defineddimensions. When you retrieve the sales total of a particular product for aparticular region, you are viewing the sales total through the product andregion dimensions. The most common dimension is time because thepurpose of multidimensional analytical queries is to find trends.

134

Page 147: Physical Data Model - SAP

Chapter 3. Building Multidimensional Diagrams

135

Page 148: Physical Data Model - SAP

Multidimensional Diagram Basics

Multidimensional diagram objects

You can create the following objects in a multidimensional diagram:

Object Tool Symbol Description

Cube Collection of measures related to as-pects of the business and used to carryout a decision support investigation.See “Cubes (PDM)” on page 138.

Dimension Axis of investigation of a cube (time,product, geography). See “Dimen-sions (PDM)” on page 140.

Attribute [none] [none] Used to qualify a dimension. For ex-ample, attribute Year qualifies the Datedimension. See “Attributes (PDM)”on page 142.

Fact [none] [none] Group of measures used among cubes.See “Facts (PDM)” on page 145.

Measure [none] [none] Variable linked to a fact, used as thefocus of a decision support investi-gation. See “Measures (PDM)” onpage 147.

Hierarchy [none] [none] Organizational structure that describesa traversal pattern though a dimen-sion. See “Hierarchies (PDM)” onpage 149.

Association Association that relates a cube to adimension. See “Associations (PDM)”on page 151.

Creating a multidimensional diagram

You can create a multidimensional diagram in an existing PDM in any of thefollowing ways:

♦ Right-click the model in the Browser and select New ä MultidimensionalDiagram from the contextual menu

♦ Right-click the background of any diagram and select Diagram ä NewDiagram ä Multidimensional Diagram from the contextual menu.

136

Page 149: Physical Data Model - SAP

Chapter 3. Building Multidimensional Diagrams

To create a new PDM with a multidimensional diagram, select File ä New,choose Physical Data Model from the Model type list, chooseMultidimensional Diagram as the first diagram, and click OK.

137

Page 150: Physical Data Model - SAP

Cubes (PDM)

Cubes (PDM)A cube is a collection of measures (see “Measures (PDM)” on page 147)corresponding to values stored into each of its data cells. The measures areorganized into dimensions (see “Dimensions (PDM)” on page 140) toprovide for faster retrieval and drill-down.

Usually a cube is associated with a fact that allows to define and sharemeasures among cubes.

In a multidimensional diagram, the cube represents an OLAP cube. Cubesneed to be created and populated via a text file in the OLAP engine. Thistext file contains a query used to extract data from a data warehouse oroperational database to fill the cubes in the OLAP engine, and is defined inthe Query tab of the cube’s property sheet.

Creating a cube

You can create a cube in any of the following ways:

♦ Use the Cube tool in the diagram Palette.

♦ Select Model ä Cubes to access the List of Cubes, and click the Add aRow tool.

♦ Right-click the model or package in the Browser, and select New ä Cube.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Cube properties

You can modify an object’s properties from its property sheet. To open acube property sheet, double-click its diagram symbol or its Browser entry inthe Cubes folder. The following sections detail the property sheet tabs thatcontain the properties most commonly entered for cubes.

Cube property sheet General tab

The General tab contains the following properties:

138

Page 151: Physical Data Model - SAP

Chapter 3. Building Multidimensional Diagrams

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the cube

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Fact Fact used by the cube. You can use the tools to the right of thelist to create an object, browse the complete tree of availableobjects or view the properties of the currently selected object

Cube property sheet Fact Measures tab

The Fact Measures tab lists the Measures linked to the fact used by the cube.For more information, see “Measures (PDM)” on page 147.

Cube property sheet Queries tab

The Queries tab displays the SQL statement required to generate the cubedata text file that is used to populate the OLAP cube.

139

Page 152: Physical Data Model - SAP

Dimensions (PDM)

Dimensions (PDM)A dimension is an axis of analysis in a multidimensional structure.

The dimension is made of an ordered list of attributes that share a commonsemantic meaning in the domain being modeled. Each attribute designates aunique position along the axis.

The dimension can be mapped to tables or views: this mapping allows totransfer operational data to the dimension.

+ For more information on object mapping, see “Mapping objects in aPDM” in the Working with PDMs chapter.

A dimension may have one or more hierarchies representing attribute sets.

Creating a dimension

You can create a dimension in any of the following ways:

♦ Use the Dimension tool in the diagram Palette.

♦ Select Model ä Dimensions to access the List of Dimensions, and clickthe Add a Row tool.

♦ Right-click the model or package in the Browser, and select New ä

Dimension.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Dimension properties

You can modify an object’s properties from its property sheet. To open adimension property sheet, double-click its diagram symbol or its Browserentry in the Dimensions folder. The following sections detail the propertysheet tabs that contain the properties most commonly entered fordimensions.

Dimension property sheet General tab

The General tab contains the following properties:

140

Page 153: Physical Data Model - SAP

Chapter 3. Building Multidimensional Diagrams

Property Description

Name The name of the item which should be clear and meaning-ful, and should convey the item’s purpose to non-technicalusers

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the dimension

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined oruser-defined

Default Hierar-chy

Dimension hierarchy used by default for a cube to performits consolidation calculations. The hierarchy used by thecube is defined on the cube dimension association

Dimension property sheet Attributes tab

The Attributes tab lists the attributes that qualify the dimension. For moreinformation, see “Attributes (PDM)” on page 142.

Dimension property sheet Hierarchies tab

The Hierarchies tab lists the hierarchies used to organize the dimensionattributes. For more information, see “Hierarchies (PDM)” on page 149.

Dimension property sheet Mapping tab

The Mapping tab defines the mapping between the current dimension and atable or a view in a data source.

141

Page 154: Physical Data Model - SAP

Attributes (PDM)

Attributes (PDM)An attribute is used to qualify dimensions (see “Dimensions (PDM)” onpage 140) used in queries. For example, the Time dimension can containattributes Year, Quarter, Month, and Week.

Attributes can be organized in hierarchies (see “Hierarchies (PDM)” onpage 149).

Creating an attribute

You can create an attribute in any of the following ways:

♦ Open the Attributes tab in the property sheet of a dimension, and click theAdd a Row tool.

♦ Right-click a dimension in the Browser, and select New ä Attribute.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Attribute properties

You can modify an object’s properties from its property sheet. To open anattribute property sheet, double-click its Browser entry. The followingsections detail the property sheet tabs that contain the properties mostcommonly entered for attributes.

Attribute property sheet General tab

The General tab contains the following properties:

142

Page 155: Physical Data Model - SAP

Chapter 3. Building Multidimensional Diagrams

Property Description

Name The name of the item which should be clear and meaning-ful, and should convey the item’s purpose to non-technicalusers

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the attribute

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined oruser-defined

Dimension Parent dimension of the attribute

Attribute property sheet Detail Attributes tab

A detail attribute participates in the definition of an attribute.

Detail attributes appear in the list of dimension attributes, but you can usethem to further define a given attribute. For example, attributes Cust_Nameand Cust_Address appear in the list of dimension attributes, however theyare used as detail attributes of attribute Cust_ID.

143

Page 156: Physical Data Model - SAP

Attributes (PDM)

v To define a detail attribute

1. Open the property sheet of a dimension, and click the Attributes tab.

2. Select an attribute in the list, click the Properties tool to open its propertysheet, and then click the Detail Attributes tab.

3. Click the Add Detail Attributes tool to open a Selection dialog listing theattributes available in the model, select one or more, and then click OK.

4. Click Apply.

144

Page 157: Physical Data Model - SAP

Chapter 3. Building Multidimensional Diagrams

Facts (PDM)A fact corresponds to the focus of a decision support investigation. It is a setof measures (see “Measures (PDM)” on page 147) manipulated by a cube(see “Cubes (PDM)” on page 138). For example, Sale, Revenue, Budgetcould be facts.

Facts can be reused among different cubes.

Creating a fact

You can create a fact in any of the following ways:

♦ Select Model ä Facts to access the List of Facts, and click the Add a Rowtool.

♦ Right-click the model or package in the Browser, and select New ä Fact.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Fact properties

You can modify an object’s properties from its property sheet. To open a factproperty sheet, double-click its Browser entry in the Facts folder. Thefollowing sections detail the property sheet tabs that contain the propertiesmost commonly entered for facts.

Fact property sheet General tab

The General tab contains the following properties:

145

Page 158: Physical Data Model - SAP

Facts (PDM)

Property Description

Name The name of the item which should be clear and meaning-ful, and should convey the item’s purpose to non-technicalusers

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the fact

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined oruser-defined

Fact property sheet Measures tab

The Measures tab lists the measures manipulated by the cube with which thefact is associated. See “Measures (PDM)” on page 147.

Fact property sheet Mapping tab

The Mapping tab contains the mapping between the fact and a table or aview in a data source.

146

Page 159: Physical Data Model - SAP

Chapter 3. Building Multidimensional Diagrams

Measures (PDM)A measure is a variable that corresponds to the focus of an investigation.Measures describe the meaning of the analytical values stored in each datacell of a cube (see “Cubes (PDM)” on page 138).

Measures are most of the time numeric values like for example Price orTotal.

Measures can also be the result of an operation or calculation as indicated inthe formula box of the measure property sheet.

Creating a measure

You can create a measure in any of the following ways:

♦ Open the Measures tab in the property sheet of a fact, and click the Add aRow tool.

♦ Right-click a fact in the Browser, and select New ä Measure.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Measure properties

You can modify an object’s properties from its property sheet. To open ameasure property sheet, double-click its diagram symbol or its Browserentry. The following sections detail the property sheet tabs that contain theproperties most commonly entered for measures.

Measure property sheet General tab

The General tab contains the following properties:

147

Page 160: Physical Data Model - SAP

Measures (PDM)

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the measure

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Fact Parent fact of the measure

Formula Indicates if the measure is a computed expression and allowsto define this expression

148

Page 161: Physical Data Model - SAP

Chapter 3. Building Multidimensional Diagrams

Hierarchies (PDM)A hierarchy defines one of two paths through a dimension (see“Dimensions (PDM)” on page 140):

♦ an organizational path - describes a traversal pattern through adimension, from the most general to the most specific attribute of thedimension. It is an ordered subset of the attributes.

♦ a consolidation path - represents a consolidation of attributes. Forexample, a Time dimension with a base periodicity of days might have ahierarchy specifying the consolidation of days into weeks, weeks intomonths, months into quarters, and quarters into years.

Creating a hierarchy

You can create a hierarchy in any of the following ways:

♦ Open the Hierarchies tab in the property sheet of a dimension, and clickthe Add a Row tool.

♦ Open the Attributes tab in the property sheet of a dimension, and click theCreate Hierarchy tool.

♦ Right-click a dimension in the Browser, and select New ä Hierarchy.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Hierarchy properties

You can modify an object’s properties from its property sheet. To open ahierarchy property sheet, double-click its Browser entry. The followingsections detail the property sheet tabs that contain the properties mostcommonly entered for hierarchies.

Hierarchy property sheet General tab

The General tab contains the following properties:

149

Page 162: Physical Data Model - SAP

Hierarchies (PDM)

Property Description

Name The name of the item which should be clear and meaning-ful, and should convey the item’s purpose to non-technicalusers

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the hierarchy

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined oruser-defined

Dimension Parent dimension of the hierarchy

Hierarchy property sheet Attributes tab

The Attributes tab lists the attributes associated with the hierarchy. For moreinformation, see “Attributes (PDM)” on page 142.

150

Page 163: Physical Data Model - SAP

Chapter 3. Building Multidimensional Diagrams

Associations (PDM)An association relates a cube (see “Cubes (PDM)” on page 138) to thedimension (see “Dimensions (PDM)” on page 140) that defines it. It showsthe axis of investigation of the dimension in the cube.

For example, the Sale cube is linked to the Time dimension by the Sale -Time association to analyze sales through the time dimension.

There can be only one association between a cube and a dimension.

Creating an association

You can create an association in any of the following ways:

♦ Use the Association tool in the diagram Palette.

♦ Select Model ä Associations to access the List of Associations, and clickthe Add a Row tool.

♦ Right-click the model or package in the Browser, and select New ä

Association.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Association properties

You can modify an object’s properties from its property sheet. To open anassociation property sheet, double-click its diagram symbol or its Browserentry in the Associations folder. The following sections detail the propertysheet tabs that contain the properties most commonly entered forassociations.

Association property sheet General tab

The General tab contains the following properties:

151

Page 164: Physical Data Model - SAP

Associations (PDM)

Property Description

Cube Cube origin of the association. You can click the Propertiestool to view the properties of the currently selected object

Dimension Destination dimension of the association. You can use thetools to the right of the list to create an object, browse thecomplete tree of available objects or view the properties ofthe currently selected object

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Hierarchy Hierarchy used by the cube for the consolidation calculation.You can click the Properties tool to view the properties of thecurrently selected object

152

Page 165: Physical Data Model - SAP

CHAPTER 4

Customizing the PDM Environment

About this chapter This chapter explains how you can customize the environment in which youbuild your Physical Data Model.

Contents Topic: page

Defining the PDM Environment 154

Specifying the PDM DBMS 155

Setting PDM Model Options 160

Setting PDM Display Preferences 176

Working with PDM Extended Model Definitions 185

Working with PDM Extended Dependencies 187

153

Page 166: Physical Data Model - SAP

Defining the PDM Environment

Defining the PDM EnvironmentThe PDM environment includes a set of parameters and configurationoptions that define various aspects of the model content and behavior. Youcan set these parameters:

♦ At model creation

♦ After creating a model with default options and parameters

♦ When creating a model template

154

Page 167: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

Specifying the PDM DBMSPowerDesigner can be used with many different DBMS. For each of theseDBMS, a standard definition file is included and provides an interfacebetween PowerDesigner and the DBMS so as to establish the bestrelationships between them.

CautionYou should never modify the DBMS files shipped with PowerDesigner. Foreach original DBMS you want to modify, you should create a correspondingnew DBMS. To do so you have to create a new DBMS from the List ofDBMS, define a name and select the original file in the Copy From list.This allows you to create a new DBMS that is identical to the original fileapart from the name.

What is a DBMSdefinition file?

A DBMS definition file is a list of values and settings that representspecifications for a particular Database Management System (DBMS) in aformat understandable by PowerDesigner. As an interface between an actualDBMS and PowerDesigner, it provides PowerDesigner with the syntax andguidelines for generating databases, triggers, and stored proceduresappropriate for a target DBMS. The file itself is in .XML format.

The DBMS definition file is a required component of PowerDesigner whenworking with Physical Data Models (PDM). Each actual DBMS supportedby PowerDesigner has its own DBMS definition.

+ For more information on the DBMS definition file, see chapter DBMSReference Guide in the Advanced User documentation .

What is contained in aDBMS definition?

All DBMS definition files have the same structure made up of a number ofcategories. A category can contain sub-categories, and entries. Theseentries are parameters recognizable by PowerDesigner.

The values for DBMS definition categories and entries vary for each DBMS.Some entries may not exist in the DBMS file if they are not applicable to theparticular DBMS.

+ For more information on the DBMS editor, see chapter The ResourceEditor in the General Feature Guide .

155

Page 168: Physical Data Model - SAP

Specifying the PDM DBMS

Not certified resource fileSome resource files are delivered with “Not Certified” in their names.Sybase will perform all possible validation checks, however Sybase doesnot maintain specific environments to fully certify these resource files.Sybase will support the definition by accepting bug reports and willprovide fixes as per standard policy, with the exception that there will beno final environmental validation of the fix. Users are invited to assistSybase by testing fixes of the definition provided by Sybase and report anycontinuing inconsistencies.

Changing the target DBMS

When you create a PDM, you select a target DBMS (see “Creating a PDM”in the Physical Data Model Basics chapter). You can change the DBMS of amodel at any time.

You may be required to change the DBMS if you open a PDM and theassociated DBMS file has been deprecated, or is otherwise unavailable. Inthis case the Choose DBMS dialog box will open, inviting you to select aDBMS from the list.

If you change target DBMS, the PDM may be altered to be made compatiblewith the new DBMS.

Data type change Changing the DBMS of a PDM may affect the data types of the model. EachDBMS family supports different sets of data types. When you change thetarget DBMS of a PDM, and select a DBMS from another family, thefollowing process occurs:

♦ First, all data types of the model are converted into conceptual data types

♦ Then, the conceptual data types are automatically converted back intophysical data types according to the data type translation table defined inthe new target DBMS

+ For more information on data type conversions, see Extensionmechanism for live database reverse engineering queries in chapter DBMSReference Guide in the Advanced User Documentation .

Non supported objects Some objects exist only in certain DBMS. For example, sequences exist inOracle 8 but not in Sybase AS Enterprise, join indexes exist in Sybase AS IQbut not in MS Access. The same occurs for triggers and stored procedures.

When you change the DBMS of a model containing such objects, and if thenew target DBMS does not support them, these objects are destroyed.

Preservation options When you change DBMS, depending on which objects are supported by theold and new target DBMS, you can choose to preserve, or to lose, the values

156

Page 169: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

associated with the following database objects:

♦ Triggers and stored procedures

♦ Physical options on the databases, tables, indexes, primary and alternatekeys, default options, tablespaces, databases and storages

♦ Database objects: databases, storages, tablespaces, abstract data types,sequences

♦ Extended attributes

If a database object is not supported by the old or new target DBMS, thepreserve option for that object is grayed and cannot be selected. If the newtarget DBMS does not support an object, you will lose the values associatedwith that object when you change target DBMS.

Triggers are rebuilt when a change in DBMS family is madeIf you change the target DBMS family, for example from Sybase to Oracleor IBM DB2, triggers are automatically rebuilt.

Syntax incompatibility When you change target DBMS there can be a syntax incompatibilitybetween physical options.

If there is a syntax incompatibility, you lose the values for the physicaloption that is not recognized by the new target database, even if you haveselected the check box to preserve that physical option.

Example If you are using physical option in while using Sybase Adaptive ServerAnywhere, and you change target database to Oracle 7 which does notrecognize the option in , you will lose all the values associated with thatoption in your model.

Share and Copy to themodel DBMS

When you change the current DBMS, you can choose to connect to a targetDBMS in one of the following ways:

DBMS Description

Share Current DBMS for the PDM constantly refers to the DBMSdefinition file stored in the DBMS library. Any modificationsmade to the DBMS are shared by the PDM

Copy Current DBMS for the PDM is a unique copy of the DBMSdefinition file stored in the DBMS library. The currentDBMS is independent of the original DBMS definition file somodifications made to the DBMS definition file in the DBMSlibrary are not available to the PDM. The copied DBMSdefinition is saved with the PDM and can not be used withoutit

157

Page 170: Physical Data Model - SAP

Specifying the PDM DBMS

v To change the target database for a PDM

1. Select Database ä Change Current DBMS to open the Change the TargetDBMS dialog box:

2. Select a target DBMS from the list.

3. Select one of the following radio buttons:♦ Share the DBMS definition – use the original DBMS file in the

“Resource Files\DBMS” directory. Any changes made to the DBMSare shared by all linked PDMs.

♦ Copy the DBMS definition in model – make a copy of the originalDBMS file in the “Resource Files\DBMS” directory. The currentDBMS is independent of the original DBMS, so modifications made tothe DBMS in the DBMS directory are not available to the PDM. Thecopied object language is saved with the PDM and cannot be usedwithout it.+ For more information on DBMS properties and customizing aDBMS, see the “DBMS Reference Guide” chapter in the AdvancedUser Documentation .

4. Click the DBMS Preserve Options tab, which displays options fordatabase objects that can be preserved or lost when the target DBMS ischanged:

158

Page 171: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

5. Select check boxes for the objects and options that you want to preserve.

Preserve options selected by defaultIf you are changing target database within a database family, for examplebetween Sybase ASE 12.5 and 15, all preserve options available areselected by default. The database objects not supported by the old andnew target databases are disabled.

6. Click OK.

A message box opens to tell you that the target database has beenchanged.

7. Click OK to return to the model with the new DBMS.

159

Page 172: Physical Data Model - SAP

Setting PDM Model Options

Setting PDM Model OptionsThis section explains how to set global options for the objects in your PDM.For information about controlling the naming conventions of your models,see the chapter Managing Models in the General features Guide .

Setting Model Settings

To set Model Settings, select Tools ä Model Options or right-click thediagram background and select Model Options from the contextual menu.

The options on this tab affect all the objects in the model, including thosealready created, while changes to the object-specific options on thesub-category tabs only affect objects created subsequently.

You can set the following options on this tab:

160

Page 173: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

Option Function

Name/Codecase sensitive

Specifies that the names and codes for all objects are casesensitive, allowing you to have two objects with identicalnames or codes but different cases in the same model.

If you change case sensitivity during the design process,we recommend that you check your model (Tools ä CheckModel) to verify that your model does not contain anyduplicate objects.

Enable links torequirements

Displays a Requirements tab in the property sheet of everyobject in the model.

Requirements are descriptions of customer needs that mustbe satisfied during the development process, and are definedin requirements models. The Requirements tab allows youto attach requirements to objects in your model. Theseattached requirements are kept synchronized with yourrequirements model.

For more information on requirements, see the Require-ments Model User’s Guide .

161

Page 174: Physical Data Model - SAP

Setting PDM Model Options

Option Function

Notation Specifies the use of one of the following notation types forthe model:♦ Relational - Arrow pointing to primary key. This option

is the default, and is used in this manual

♦ CODASYL - Arrow pointing to foreign key

♦ Conceptual - Cardinality displayed in IE format (crow’sfeet)

♦ IDEF1X - Cardinality and mandatory status displayedon reference, primary columns in separate containersand dependent tables with rounded rectangles

When you change notation, all symbols in all diagramsare updated accordingly. If you switch from Merise toIDEF1X, all associations are converted to relationships.

Table and view model options

To set model options for tables and views, select Tools ä Model Options,and select the Table & View sub-category in the left-hand Category pane.

162

Page 175: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

163

Page 176: Physical Data Model - SAP

Setting PDM Model Options

You can set the following options on this tab:

Option Function

Table: Defaultowner

Specifies a default owner for the tables in your model fromthe list of users (see the section “Creating a user” in theManaging Database Users chapter). To create a User, clickon the ellipsis button to open the List of Users, and clickthe Add a Row tool.

If the user specified is subsequently deleted, this option(and the ownership of all associated objects) will be resetto none.

View: Defaultowner

Specifies a default owner for the views in your model fromthe list of users (see the section “Creating a user” in theManaging Database Users chapter). To create a User, clickon the ellipsis button to open the List of Users, and clickthe Add a Row tool.

If the user specified is subsequently deleted, this option(and the ownership of all associated objects) will be resetto none.

Ignore identi-fying owner

Specifies that the owner of a table or view is ignoredfor identification purposes. Since, by default, both thename/code and the owner are considered during a unique-ness check, this option enables you to enforce distinctnames for these objects.

For example, if a model contains a table called “Table_1”,which belongs to User_1, and another table, also called“Table_1”, which belongs to User_2, it will, by default,pass a uniqueness check because of the different owners.

Column and domain model options

To set model options for columns and domains, select Tools ä ModelOptions, and select the Column & Domain sub-category in the left-handCategory pane.

164

Page 177: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

You can set the following options on this tab:

Option Function

Enforce non-divergence

Specifies that columns attached to a domain must remainsynchronized with the selected properties, any or all of:Data type, Check, Rules, Mandatory, and Profile.

Default datatype

Specifies a default data type to be applied to columns anddomains.

Column:Mandatory bydefault

Specifies that columns are created, by default, as manda-tory.

Domain:Mandatory bydefault

Specifies that domains are created, by default, as manda-tory.

Reference model options

To set model options for references, select Tools ä Model Options, andselect the Reference sub-category in the left-hand Category pane.

165

Page 178: Physical Data Model - SAP

Setting PDM Model Options

You can set the following options on this tab:

Option Function

Unique code Requires that references have unique codes. If this optionis not selected then different references can have the samecode (except when two references share the same childtable).

Auto-reusecolumns

Enables the reuse of columns in a child table as foreign keycolumns if the following conditions are satisfied:♦ Child column has same code as migrating primary key

column

♦ Child column is not already a foreign key column

♦ Data types are compatibleFor more information, see “Automatic reuse and migrationof columns” in the Building Physical Diagrams chapter.

166

Page 179: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

Option Function

Auto-migratecolumns

Enables the automatic migration of primary key columnsfrom the parent table as foreign key columns to the childtable. If you select both Auto-migrate columns and anyof the following sub-options, then the relevant columnproperty of the PK will also be migrated to the FK atreference creation:♦ Domain

♦ Check

♦ Rules

♦ Last positionFor more information, see “Automatic reuse and migrationof columns” in the Building Physical Diagrams chapter.

Mandatoryparent

Specifies that the relationship between child and parenttables is, by default, mandatory, i.e., each foreign key valuein the child table must have a corresponding key value, inthe parent table.

Change parentallowed

Specifies that a foreign key value can change to selectanother value in the referenced key in the parent table.

Check on com-mit

Specifies that referential integrity is checked only on com-mit, rather than immediately after row insertion. Thisfeature can be useful when working with circular depen-dencies. Not available with all DBMSs.

Propagate col-umn properties

Propagates changes made to the name, code, or data type ofa parent table column to the corresponding child column.

Default link oncreation

Specifies how reference links are created. You can selecteither:♦ Primary key – automatically create links from primary

key to foreign key columns at creation

♦ User-defined – manually create your own links

Default imple-mentation

Specifies how referential integrity is implemented in thereference. You can select either:♦ Declarative – referential integrity is defined by con-

straint in foreign declarations

♦ Trigger – referential integrity is implemented by triggersFor more information on referential integrity, see “Refer-ence property sheet Integrity tab” in the Building PhysicalDiagrams chapter.

167

Page 180: Physical Data Model - SAP

Setting PDM Model Options

Option Function

Default Con-straints: Up-date

Controls how updating a key value in the parent table will,by default, affect the foreign key value in the child table.Depending on your DBMS, you can choose from some orall of the following settings:♦ None – no effect

♦ Restrict – cannot update parent value if one or morematching child values exist (no effect)

♦ Cascade - update matching child values

♦ Set null - set matching child values to NULL

♦ Set default – set matching child values to default value

Default Con-straints: Delete

Controls how deleting a key value in the parent table will,by default, affect the foreign key value in the child table.Depending on your DBMS, you can choose from some orall of the following settings:♦ None – no effect

♦ Restrict – cannot delete parent value if one or morematching child values exist (no effect)

♦ Cascade - delete matching child values

♦ Set null - set matching child values to NULL

♦ Set default – set matching child values to default value

Sequence model options

To set model options for sequences, select Tools ä Model Options, andselect the Sequence sub-category in the left-hand Category pane.

168

Page 181: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

You can set the following options on this tab:

Option Function

DefaultOwner

Specifies a default owner for the sequences in your modelfrom the list of users (see the section “Creating a user” in theManaging Database Users chapter). To create a User, clickon the ellipsis button to open the List of Users, and click theAdd a Row tool.

If the user specified is subsequently deleted, this option (andthe ownership of all associated objects) will be reset to none.

Index model options

To set model options for indexes, select Tools ä Model Options, and selectthe Index sub-category in the left-hand Category pane.

169

Page 182: Physical Data Model - SAP

Setting PDM Model Options

You can set the following options on this tab:

Option Function

Table: De-fault Owner

Specifies a default owner for the table indexes in your modelfrom the list of users (see the section “Creating a user” in theManaging Database Users chapter). To create a User, clickon the ellipsis button to open the List of Users, and click theAdd a Row tool.

If no default user is specified here, then the owner of theparent table is used by default.

If the user specified is subsequently deleted, this option (andthe ownership of all associated objects) will be reset to none.

View: De-fault Owner

Specifies a default owner for the view indexes in your modelfrom the list of users (see the section “Creating a user” in theManaging Database Users chapter). To create a User, clickon the ellipsis button to open the List of Users, and click theAdd a Row tool.

If no default user is specified here, then the owner of theparent view is used by default.

If the user specified is subsequently deleted, this option (andthe ownership of all associated objects) will be reset to none.

170

Page 183: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

Join index model options

To set model options for join indexes, select Tools ä Model Options, andselect the Join Index sub-category in the left-hand Category pane.

You can set the following options on this tab:

Option Function

Defaultowner

Specifies a default owner for the join indexes in your modelfrom the list of users (see the section “Creating a user” in theManaging Database Users chapter). To create a User, clickon the ellipsis button to open the List of Users, and click theAdd a Row tool.

If the user specified is subsequently deleted, this option (andthe ownership of all associated objects) will be reset to none.

Procedure model options

To set model options for procedures, select Tools ä Model Options, andselect the Procedure sub-category in the left-hand Category pane.

171

Page 184: Physical Data Model - SAP

Setting PDM Model Options

You can set the following options on this tab:

Option Function

Defaultowner

Specifies a default owner for the procedures in your modelfrom the list of users (see the section “Creating a user” in theManaging Database Users chapter). To create a User, clickon the ellipsis button to open the List of Users, and click theAdd a Row tool.

If the user specified is subsequently deleted, this option (andthe ownership of all associated objects) will be reset to none.

Trigger model options

To set model options for triggers, select Tools ä Model Options, and selectthe Trigger sub-category in the left-hand Category pane.

172

Page 185: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

You can set the following options on this tab:

Option Function

Table: De-fault Owner

Specifies a default owner for the table triggers in your modelfrom the list of users (see the section “Creating a user” in theManaging Database Users chapter). To create a User, clickon the ellipsis button to open the List of Users, and click theAdd a Row tool.

If no default user is specified here, then the owner of theparent table is used by default.

If the user specified is subsequently deleted, this option (andthe ownership of all associated objects) will be reset to none.

View: De-fault Owner

Specifies a default owner for the view triggers in your modelfrom the list of users (see the section “Creating a user” in theManaging Database Users chapter). To create a User, clickon the ellipsis button to open the List of Users, and click theAdd a Row tool.

If no default user is specified here, then the owner of theparent view is used by default.

If the user specified is subsequently deleted, this option (andthe ownership of all associated objects) will be reset to none.

173

Page 186: Physical Data Model - SAP

Setting PDM Model Options

Option Function

Rebuild au-tomaticallytriggers

Automatically rebuilds the triggers on the child and parenttables of a reference when you:♦ change the implementation of a reference

♦ change the referential integrity rules of a reference imple-mented by a trigger

♦ change the child or parent table of a reference imple-mented by a trigger (new and old)

♦ create or delete a reference implemented by a trigger

♦ change the maximum cardinality of the referencesNote: If this option is not selected, you can manually instructPowerDesigner to rebuild triggers at any time by selectingTools ä Rebuild Objects ä Rebuild Triggers.

Database package model options

To set model options for database packages, select Tools ä Model Options,and select the Database Package sub-category in the left-hand Categorypane.

174

Page 187: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

You can set the following options on this tab:

Option Function

Defaultowner

Specifies a default owner for the database packages in yourmodel from the list of users (see the section “Creating auser” in the Managing Database Users chapter). To create aUser, click on the ellipsis button to open the List of Users,and click the Add a Row tool.

If the user specified is subsequently deleted, this option (andthe ownership of all associated objects) will be reset to none.

175

Page 188: Physical Data Model - SAP

Setting PDM Display Preferences

Setting PDM Display PreferencesPowerDesigner display preferences allow you to customize the format ofobject symbols, and the information that is displayed on them.

To set PDM display preferences, select Tools ä Display Preferences orright-click the diagram background and select Display Preferences from thecontextual menu.

For information about changing the format of symbols, see the “Selectingformat display preferences” section in the “Model Graphics” chapter in theGeneral Features Guide. The following sections list the options available tocustomize the information displayed on PDM object symbols. Note that theobjects available to be customized in the Display Preferences window aredependant upon the current diagram type.

Association display preferences

To set display preferences for associations, select Tools ä DisplayPreferences, and select the Association sub-category in the left-handCategory pane.

176

Page 189: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

Preference Description

Name Displays the name of the association.

Hierarchy Displays the name of the hierarchy used to compute the cube

Stereotype Displays the stereotype of the association.

Cube display preferences

To set display preferences for cubes, select Tools ä Display Preferences, andselect the Cube sub-category in the left-hand Category pane.

Preference Description

Fact Mea-sures

Displays fact measures. When selected, you can additionallyspecify whether to display all fact measures, or to limit themto a given number.

Fact Displays cube facts.

Stereotype Displays the stereotype of the cub. You can also display thestereotype of the cube measures and facts.

Dimension display preferences

To set display preferences for dimensions, select Tools ä DisplayPreferences, and select the Dimension sub-category in the left-handCategory pane.

Preference Description

Attributes Displays the dimension attributes. When selected, you canadditionally specify whether to display all attributes, or tolimit them to a given number.

Hierarchies Displays dimension hierarchies. When selected, you canalso specify whether to display <Default> beside the defaulthierarchy in dimension symbols.

Stereotype Displays the stereotypes of dimensions. You can also displaythe stereotype of the dimension attributes and hierarchies.

Dimension Attributes The following display preferences are available for dimension attributes:

177

Page 190: Physical Data Model - SAP

Setting PDM Display Preferences

Preference Description

Indicators ofHierarchy

Displays the hierarchies indicators of dimension attributes.When selected, you can also specify whether to display thehierarchy level of dimension attributes.

Default optionsClick the Default button to display default dimension display preferences.Click the Set As Default button to set current display preferences as defaultselections.

Procedure display preferences

To set display preferences for procedures, select Tools ä DisplayPreferences, and select the Procedure sub-category in the left-hand Categorypane.

Preference Description

Owner Displays the names of procedure owners

Stereotype Displays the stereotypes of procedures

Reference display preferences

To set display preferences for dimensions, select Tools ä DisplayPreferences, and select the Reference sub-category in the left-hand Categorypane.

Preference Description

Name Displays the name or code of the reference*

Constraintname

Displays the referential integrity constraint name

Join Displays the statement of linked columns between the twotables

178

Page 191: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

Preference Description

Referentialintegrity

Displays the update and delete referential integrity con-straints as follows:♦ upd() - Update

♦ del() - Delete

♦ cpa - Change Parent AllowedA letter between the parentheses indicates the type of con-straint, as follows:♦ ( ) - None

♦ (R) - Restrict

♦ (C) - Cascade

♦ (N) - Set null

♦ (D) - Set defaultThe referential integrity label shown below indicates thefollowing:♦ Cascade on update

♦ Set null on delete

♦ Cardinality is 0..n (any number of children is accept-able).

Stereotype Displays the stereotypes of references

Role names Displays the role names for parent and child tables ofreferences

Cardinality Displays the minimum and maximum number of instances ina child table that can appear for each corresponding instancein the parent table.

The default cardinality labels for PowerDesigner indicate theminimum and maximum number of children as follows:

[minimum ..maximum]

For example, the cardinality label [0..n] indicates thatany number of children is acceptable.

Implementa-tion

Displays the implementation mode of referential integrity,declarative or by triggers

*Displayed text depends on whether the Name or Code radio button is

179

Page 192: Physical Data Model - SAP

Setting PDM Display Preferences

selected.

Reference display mode + For information about changing the notation of references, see “SettingModel Settings” on page 160.

Moving text on a reference symbolWhen a reference symbol displays text, the text position is based on theposition of handles. You can add a handle on the reference symbol bypressing CTRL while you click the symbol.

Table display preferences

To set display preferences for tables, select Tools ä Display Preferences, andselect the Table sub-category in the left-hand Category pane.

Preference Description

Columns Displays table columns. When selected, you can choosebetween displaying all columns, only primary key columns,only key columns, or limit the number of columns displayedto a given number.

Indexes Displays all indexes defined for table columns

Keys Displays all keys defined on table

Triggers Displays all triggers defined for table

Owner Displays name of table owner

Stereotype Displays stereotype of the table. You can also display thestereotype of columns, keys, indexes, and triggers

Comment Displays comment of the table. When selected, all othercheck boxes are deselected, except for Stereotype

Table Columns display You can display information about columns in each table.

Keys and indexes are represented by indicators in the table symbol. Eachkey and index indicator is assigned a number. You can use these numbers tokeep track of the different groups of alternate keys, foreign keys, and indexesin your model.

You can display the following column information in a table symbol:

180

Page 193: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

Preference Displays Example

Data types Data type for each column

Replace bydomains

Domain codes for each columnattached to a domain

Domains Domain of an attribute in the table.This display option interacts withthe selection for Data types. Asa result, there are four displayoptions

See Display domainand data type for op-tions and examples

Key Indica-tors

<pk>, <fk>, and <ak> indica-tors next to primary key, foreignkey, and alternate key columnsrespectively. When the Keys pref-erence is also selected, the keynames are listed at the bottom ofthe table symbol

Index indica-tors

<i(number )> indicator next toindexed columns. When the In-dexes preference is also selected,the index names and correspondingnumbers are listed at the bottom ofthe table symbol

NULL/NOTNULL

Column indicator: null, not null,identity, or with default (DBMS-dependent)

181

Page 194: Physical Data Model - SAP

Setting PDM Display Preferences

Displaying foreign key indicator numbersYou can display foreign key numbers next to their corresponding foreignkey names on the references links between the appropriate parent and childtables.

+ For information on displaying text with a reference symbol, see section“Reference display preferences” on page 178.

Display domain and datatype

You can display the domain of an attribute in the symbol of a table. Thereare four display options available:

Preference Displays Example

Data types Only the data type, if itexists

Domains Only the domain, if it exists

Data types

Domains

Both data type and domain,if they exist

Data types

Replace bydomains

If domain exists and datatype does not exist, thendisplays domain.

If domain does not existand data type exists, thendisplays data type.

Default optionsClick the Default button to display default table display preferences. Clickthe Set As Default button to set current display preferences as defaultselections.

Table notation + For information about changing the notation of tables, see “SettingModel Settings” on page 160.

View display preferences

To set display preferences for views, select Tools ä Display Preferences, and

182

Page 195: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

select the View sub-category in the left-hand Category pane.

Preference Description

Columns Displays the columns in the view. When selected, you canchoose between displaying all the columns, or to limit themto a given number.

Tables Displays the tables in the view.

Indexes For those DBMS that support query tables, displays theindexes in the views of type materialized view, summarytable or snapshot.

Owner Displays the names of view owners.

Stereotype Displays the stereotypes of views.

Comment Displays the comments associated with views. When se-lected, all other check boxes except for Stereotype aredeselected.

View column displaypreferences

The following display preferences are available for view columns:

Preference Description

Name Displays the view column names.

Expression Displays the SQL expressions for view columns.

Data types Displays the data type for view columns.

Index indica-tor

For those DBMS that support query tables, displays theindicator next to indexed columns.

View reference display preferences

To set display preferences for views, select Tools ä Display Preferences, andselect the View reference sub-category in the left-hand Category pane.

Preference Description

Name Displays the name or code of view references.

Join Displays the statement of linked columns between the twotables or views.

Stereotype Displays the stereotype of view references

Role names Displays the role names for parent and child tables or viewsof view references.

183

Page 196: Physical Data Model - SAP

Setting PDM Display Preferences

View reference displaymode

+ For information about changing the notation of view references, see“Setting Model Settings” on page 160.

184

Page 197: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

Working with PDM Extended Model DefinitionsExtended model definitions (.XEM files) provide means for customizing andextending PowerDesigner metaclasses, parameters and generation. Extendedmodel definitions are typed like models in PowerDesigner. You create anextended model definition for a specific type of model and you cannot sharethese files between heterogeneous models.

Extended model definitions may contain:

♦ Extended attributes for applicable objects in order to further define theirproperties

♦ Stereotypes to define extended dependencies established between modelobjects

+ For more information on extended dependencies, see “Working withPDM Extended Dependencies” on page 187.

♦ Generation targets and commands to complement the generation of anobject model, or to perform an extended generation

When you create a new PDM, or when you reverse engineer into a newPDM, you can select one or several extended model definitions and attachthem to the model from the Extended Model Definitions tab of the Newdialog box.

You can choose one of the following options:

185

Page 198: Physical Data Model - SAP

Working with PDM Extended Model Definitions

Option Definition

Share Current extended model definition constantly refers to the ex-tended model definition stored in the Resource Files\ExtendedModel Definitions directory. Any changes made to the extendedmodel definition are shared by all linked XEM

Copy Current extended model definition is a unique copy of the ex-tended model definition stored in the Resource Files\ExtendedModel Definitions directory. The current extended model defi-nition is independent of the original one, so modifications madeto the extended model definition in the Resource Files\ExtendedModel Definitions directory are not available to the copied XEM.This one is saved with the PDM and cannot be used without it

+ For more information on extended model definitions, see chapterExtended Model Definitions Reference Guide, in the Advanced UserDocumentation.

186

Page 199: Physical Data Model - SAP

Chapter 4. Customizing the PDM Environment

Working with PDM Extended DependenciesExtended dependencies are links between PDM objects. These links help tomake object relationships clearer but are not interpreted and checked byPowerDesigner as they are meant to be used for documentation purposesonly.

You can complement these links by applying stereotypes. Stereotypes areused to define extended dependencies between objects in the PDM.

You can type stereotypes directly in the Stereotype column of the objectproperty sheet or select a value from the list if you have previously definedstereotypes in an embedded or imported extended model definition (.XEM).

+ For more information on extended model definitions, see chapterExtended Model Definitions Reference Guide in the Advanced UserDocumentation.

187

Page 200: Physical Data Model - SAP
Page 201: Physical Data Model - SAP

CHAPTER 5

Building Triggers and Procedures

About this chapter This chapter presents triggers and procedures used to generate databaseconstraints.

Contents Topic: page

Triggers (PDM) 190

Trigger Templates (PDM) 206

Trigger Template Items (PDM) 214

Stored Procedures and Functions (PDM) 222

Procedure Templates (PDM) 233

SQL Code Definition Toolbars 238

Using the SQL/XML Wizard 240

Generating Triggers and Procedures 247

189

Page 202: Physical Data Model - SAP

Triggers (PDM)

Triggers (PDM)A trigger is a segment of SQL code associated with a table or a view, andstored in a database. It is invoked automatically whenever there is an attemptto modify data in the associated table with an insert, delete, or updatecommand.

Triggers enhance the security, efficiency, and standardization of databases.

You can use triggers to enforce referential integrity, where declarativeconstraints are not sufficient. You can also use triggers to implementsequences for columns.

Trigger templates andtemplate items

A trigger template is a pre-defined form for creating triggers.PowerDesigner ships templates for each supported DBMS. Depending onthe current DBMS, there are pre-defined templates for insert, update, anddelete trigger types.

A template item is a reusable block of SQL script that can implementreferential integrity, or do any other work on database tables. PowerDesignerships template items for each supported DBMS. A template item is insertedinto a trigger template script, or a trigger script. The template item calls acorresponding SQL macro which can implement an insert, update, delete, orerror message constraint on one or more tables in the database.

You can use the PowerDesigner templates and template items, copy and editthem, or create your own from scratch. For more information, see “TriggerTemplates (PDM)” on page 206.

Creating Triggers for Referential Integrity

You can create triggers automatically for one or more tables in a model,when you specify that triggers are to be used to implement referentialintegrity and for columns where the values depend on a sequence.

v To implement referential integrity between tables by triggers

1. Create a reference between two tables, and then double click thereference symbol to open its property sheet.

2. Click the Integrity tab, and then select Trigger from the Implementationlist.

3. Specify the form of Update and Delete constraints using the radiobuttons, and then click OK to return to the diagram.

4. If you have set the Automatically rebuild triggers model option, thentriggers will have been created automatically in the parent and child

190

Page 203: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

tables. To verify this, double-click the table symbol to open its propertysheet, and then click the Triggers tab. If the triggers are not present„ youwill need to rebuild your triggers manually.

+ For more information about the Automatically rebuild triggers modeloption and rebuilding triggers manually, see ““Rebuilding Triggers” onpage 195”.

+ For more information about selecting referential integrity optionsfrom the Reference property sheet, see section Defining referentialintegrity in chapter Building Physical Diagrams.

You can instruct PowerDesigner to implement referential integrity betweentables using triggers by default.

v To implement referential integrity between tables by triggers bydefault

1. Select Tools Model Options and click Reference under Model Settings inthe Category list.

2. Select Trigger from the Default implementation list, and then click OK.

From now, when you create a reference between tables, referentialintegrity will be implemented using triggers by default.

Creating Other Triggers

You can create your own triggers from the property sheet of a table (or view,if supported by your DBMS).

You can write a trigger from scratch directly in its property sheet, but werecommend that you use a trigger template and/or trigger template items todefine the trigger code. These allow you to create triggers in a modularfashion, to make re-use of your trigger code easier and give your triggersmore portability.

+ For more information, see ““Trigger Templates (PDM)” on page 206”.

Creating a trigger from a template

You can create a trigger based on one of the PowerDesigner templates or ona template of your own.

v To create a trigger from a template

1. Double-click a table symbol to open its property sheet, and then click theTriggers tab.

191

Page 204: Physical Data Model - SAP

Triggers (PDM)

2. Click the Add a Row tool to create a new trigger, and type a name andcode.

3. Click Apply to commit the creation of the new trigger, and then click theProperties tool to open its property sheet.

4. Click the Definition tab, and select a trigger template from the Templatelist.

The time and event fields will be set and the template code copied intothe definition box.

5. [optional] Modify the trigger definition code. You can add triggertemplate items, use PDM variables and macros and various other toolsavailable from the toolbar (see “SQL Code Definition Toolbars” onpage 238).

If you edit the code, then the trigger will be marked as user-defined andwill be excluded from most forms of rebuilding (see “RebuildingTriggers” on page 195).

6. You can also modify the trigger’s other properties. For a full list of theproperties available, see “Trigger properties” on page 194.

7. Click OK in each of the dialog boxes.

Creating a trigger from scratch

You can create a trigger without basing it on a template. However, werecommend that you use a template as this will simplify reuse of your codeand make your triggers more portable.

192

Page 205: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

v To create a trigger from scratch

1. Double-click a table symbol to open its property sheet, and then click theTriggers tab.

2. Click the Add a Row tool to create a new trigger, and type a name andcode.

3. Click Apply to commit the creation of the new trigger, and then click theProperties tool to open its property sheet.

4. Click the Definition tab.

5. Enter the trigger definition code. You can add trigger template items, usePDM variables and macros and various other tools available from thetoolbar (see “SQL Code Definition Toolbars” on page 238).

The trigger will be marked as user-defined and will be excluded frommost forms of rebuilding (see “Rebuilding Triggers” on page 195).

6. You can also modify the trigger’s other properties. For a full list of theproperties available, see “Trigger properties” on page 194.

7. Click OK in each of the dialog boxes.

Editing triggers in EclipseWhen using the PowerDesigner Eclipse plug-in, you can right-click atrigger in the Browser and select Edit in SQL Editor from the contextualmenu to open it in the Eclipse SQL Editor. You can optionally connectto your database in order to obtain auto-completion for table names. Thetrigger definition is added as a .SQL file to the Generated SQL Files list inthe Workspace Navigator.

193

Page 206: Physical Data Model - SAP

Triggers (PDM)

Trigger properties

You can modify an object’s properties from its property sheet. To open atrigger property sheet, double-click its Browser entry in the Triggers folder.The following sections detail the property sheet tabs that contain theproperties most commonly entered for triggers.

Trigger property sheet General tab

The General tab contains the following properties:

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the trigger

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Owner Name of trigger owner. You choose an owner from a list ofusers. A trigger can only have one owner at a time. This isnormally the trigger creator

Table Table attached to trigger

Generate Indicates to generate trigger

User-defined [Read-only] Indicates that the trigger definition is modifiedby user. You modify a trigger definition when you change thetrigger template script in the Definition tab of the trigger

Trigger property sheet Definition tab

The Definition tab allows you to enter code for the trigger. It contains thefollowing properties:

194

Page 207: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

Property Description

Template Template on which the trigger is based

User-defined This button is automatically depressed when you modify thedefinition of a trigger, that is to say the trigger template code.You can click the User-Defined button to restore the triggerdefinition as it is provided in the template

Time Time attribute of the template. The content of the list dependson the DBMS

Event Event attribute of the template. The content of the list dependson the DBMS

Order Firing order of trigger

Time and event You can customize the trigger time and event, and you can also handlemultiple events on a single trigger.

The time and event lists are filled with the values defined in the triggertemplate and the values defined in the Time and Event entries in the Triggercategory of the DBMS editor. For example, if you define Select as an eventin the DBMS definition file, it will appear in the list of events.

For more information about triggers with multiple event, see “Definingtriggers with multiple events” on page 205.

For information about the Definition tab toolbar, see “SQL Code DefinitionToolbars” on page 238.

Trigger property sheet Preview tab

The Preview tab displays the SQL code associated with the trigger. For moreinformation, see “Previewing SQL statements” in the Physical Data ModelBasics chapter.

Trigger property sheet Template Items tab

The Template Items tab lists the trigger template items available for use inthe trigger definition. For more information, see “Trigger Template Items(PDM)” on page 214.

Rebuilding Triggers

You rebuild triggers in order to ensure that:

♦ They are attached to all tables joined by a reference where referentialintegrity is implemented by a trigger

195

Page 208: Physical Data Model - SAP

Triggers (PDM)

♦ Any changes to a trigger template or trigger template item are cascadeddown to all associated triggers

PowerDesigner can rebuild triggers either:

♦ Automatically, whenever a relevant change is made, if you have enabledthe Automatically rebuild triggers model option

♦ Manually, when you select Tools ä Rebuild Objects ä Rebuild Triggers

The Rebuild Triggers function creates new triggers based on template itemsthat correspond to trigger referential integrity defined for references andsequence implementation for columns.

The Rebuild Triggers function does not use pre-defined template itemswhich are not applicable to trigger referential integrity or sequenceimplementation.

+ For information about rebuilding dependencies between triggers andother objects, see “Tracing Trigger and Procedure Dependencies” onpage 224.

Rebuilding triggers automatically

PowerDesigner can automatically rebuild your triggers whenever a relevantchange is made.

v To enable the automatically rebuild triggers option

1. Select Tools ä Model Options to open the Model Options window.

2. In the Category pane, click on Trigger under the Model Settings node togo to the Trigger model options

3. Select the Automatically rebuild triggers checkbox, and click OK.

PowerDesigner will rebuild all triggers and will, from now on, rebuildtriggers whenever you make a relevant change in the model.

Rebuilding triggers manually

You can rebuild triggers manually at any time.

v To rebuild triggers manually

1. Select Tools ä Rebuild Objects ä Rebuild Triggers to open the TriggerRebuild window.

2. Specify a rebuild mode. You can choose between the following options:

196

Page 209: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

♦ Delete and Rebuild – all triggers attached to templates are deleted andrebuilt, including those to which you have made modifications

♦ Preserve – only those triggers attached to templates that have not beenmodified are deleted and rebuilt. Any triggers that you have modifiedare preserved.

3. The Trigger selection box shows an expandable tree view of trigger types.There are three levels in this tree:

♦ All trigger types supported by the current DBMS

♦ All trigger templates corresponding to the trigger types

♦ All template items defined for each trigger templateFor example, in the list below, the two template itemsInsertChildParentExist and InsertTooManyChildren are usedin the BeforeInsertTrigger template that is, in turn, used in alltriggers with a time of Before and an event type of Insert:

You can select which trigger types, trigger templates, and template itemswill be rebuilt by expanding the appropriate nodes and selecting orclearing the check boxes as required.

4. [optional] Click the Error Messages tab to define the types of errormessages to generate. For more information about this tab, see the““Creating and generating user-defined error messages” on page 250”section.

197

Page 210: Physical Data Model - SAP

Triggers (PDM)

5. [optional] Click the Selection tab. to specify which tables to rebuild thetriggers for.

6. Click OK to begin the rebuild process.

Progress is shown in the Output window. You can view the triggers thathave been created from the Triggers tab of the table property sheet, orfrom the List of Triggers.

Which Triggers are Rebuilt?

Whether you use the automatic model option or rebuild triggers manually,all triggers that are based on a trigger template are rebuilt. These include:

♦ The default PowerDesigner triggers that are used to maintain referentialintegrity between tables

♦ Any other triggers that you have created via a user-defined triggertemplate

Triggers are rebuilt when a change in the DBMS family is madeIf you change the target DBMS family, for example from Sybase to Oracleor IBM DB2, triggers are automatically rebuilt.

User-defined triggers When a trigger based on a trigger template is modified, it becomesuser-defined. The Rebuild Triggers function does not create a triggercorresponding to a trigger template attached to a user-defined trigger if youselect the “Preserve” mode.

If you wish to recreate a trigger based on the same trigger template you can:

♦ Click the User-defined button in the Definition tab of the trigger propertysheet to reset your edits. This removes the changes performed on thetrigger and reapplies the trigger template

♦ Select <None> in the trigger template list in the Definition tab of thetrigger property sheet. This detaches the trigger template from theuser-defined trigger. The next time you will rebuild triggers, a new triggerbased on the previously mentioned trigger template will be created

For example, Trigger1 is based on template TrigTpl1. You modify Trigger1so PowerDesigner turns it into a user-defined trigger. If you want to recreatea trigger based on TrigTpl1 you can click the User-defined button in theDefinition tab of the Trigger1 property sheet: you restore the triggertemplate code, but you lose the modifications on the trigger. You can alsokeep the changes performed on the trigger by selecting <None> in thetrigger template list in the Definition tab of the trigger property sheet. The

198

Page 211: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

trigger template is detached from the trigger and a new trigger based on thistrigger template will be created the next time you rebuild triggers.

Modifying Triggers

PowerDesigner provides various methods for editing a trigger. You can:

♦ Edit the code directly in the Definition tab of its property sheet.

♦ Attach a predefined trigger template or create and attach your ownreusable trigger templates

♦ Insert predefined trigger template item code or create your own reusabletrigger template items

Always work on a copy of your DBMS definition fileIf you modify the definition of a DBMS trigger template or template item,you are modifying the DBMS definition file. We recommend that you onlyever work on a copy of the original DBMS definition file.

v To modify a trigger

1. Open the trigger property sheet in one of the following ways:♦ Open the relevant table property sheet click the Triggers tab, select the

trigger from the list, and then click the Properties tool

♦ Select Model ä Triggers ä Triggers to open the List of Triggers, selectthe trigger from the list, and then click the Properties tool

♦ In the Browser, find the entry for the trigger, right-click it, and selectProperties from the contextual menu

2. Click the Definition tab to display the trigger code.

199

Page 212: Physical Data Model - SAP

Triggers (PDM)

3. Enter the trigger definition code. You can attach a trigger template, addtemplate items, use PDM variables and macros and various other toolsavailable from the toolbar (see “SQL Code Definition Toolbars” onpage 238).

The trigger will be marked as user-defined and will be excluded frommost forms of rebuilding (see ““Rebuilding Triggers” on page 195”), ifyou select the “Preserve” mode.

4. You can also modify the trigger’s other properties. For a full list of theproperties available, see “Trigger properties” on page 194.

5. Click OK in each of the dialog boxes.

Inserting a template item into a trigger or trigger template

Template items are inserted in a trigger or trigger template definition using adot followed by the template item name. For example, the following scriptcontains two template items InsertChildParentExist andInsertTooManyChildren:

/* Before insert trigger "%TRIGGER%" for table"[%QUALIFIER%]%TABLE%" */

create trigger %TRIGGER% before insert order %ORDER% on[%QUALIFIER%]%TABLE%

referencing new as new_ins for each rowbegin

declare user_defined_exception exception for SQLSTATE’99999’;

declare found integer;.InsertChildParentExist.InsertTooManyChildren

end/

v To add a template item to a trigger or trigger template

1. Open the property sheet of the trigger or trigger template that you want tomodify, and then click the Definition tab.

2. Click at the point in the code where you want to insert the triggertemplate item, and then click one of the following tools:

♦ Add Trigger Item From DBMS – to open a selection box containing alist of trigger template items defined in the DBMS definition file

♦ Add Trigger Item From Model – to open a selection box containing alist of trigger template items defined in the model

200

Page 213: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

3. Select the item to insert and then click OK to return to the definition tab.

The trigger template item will be inserted in your code. It will alsoappear in the list on the Template Items tab.

Declaring a template item in a trigger definition

Certain DBMS require that a cursor and variables are declared for eachtemplate item before the template item name is used in the script. This canbe a statement that calls a corresponding procedure. You can use thefollowing format to declare a template item: Decl template item name.

201

Page 214: Physical Data Model - SAP

Triggers (PDM)

For example, the trigger definition for Oracle 8 contains the.DeclInsertChildParentExist statement which declares the following.InsertChildParentExist template item:

-- Before insert trigger "[%QUALIFIER%]%TRIGGER%" for table"[%QUALIFIER%]%TABLE%"

create trigger [%QUALIFIER%]%TRIGGER% before inserton [%QUALIFIER%]%TABLE% for each rowdeclare

integrity_error exception;errno integer;errmsg char(200);dummy integer;found boolean;.DeclInsertChildParentExist

begin.InsertChildParentExist

-- Errors handlingexception

when integrity_error thenraise_application_error(errno, errmsg);

end;/

In a generated trigger script, .DeclInsertChildExist corresponds to thefollowing definition:

.FOREACH_PARENT()-- Declaration of InsertChildParentExist constraint for the

parent "[%PQUALIFIER%]%PARENT%".DEFINE "CURSOR" "cpk%REFNO%_%.25L:TABLE%"cursor %CURSOR%(.JOIN("var_%.L26:FK% %.L:COLTYPE%", "", ",", ")

is")select 1from [%PQUALIFIER%]%PARENT%where .JOIN("%PK% = var_%.L26:FK%", "and ")and .JOIN("var_%.L26:FK% is not null", "and ", "", ";")

.ENDFOR

Trigger naming conventions

The pre-defined trigger templates that ship with PowerDesigner indicatenaming conventions for the trigger scripts that it generates. The namingconvention consists of a prefix indicating the trigger type followed by thetable code.

The default naming conventions include a variable (%L:TABLE). The nameof the resulting trigger script replaces this variable with a lower-case tablecode. For example, a resulting trigger script may have the name ti_employee.

You can change the trigger naming convention in PowerDesigner

202

Page 215: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

pre-defined DBMS trigger templates from the Trigger Templates tab of theDBMS property sheet.

v To change trigger naming conventions in a DBMS trigger tem-plate

1. Select Database ä Edit Current DBMS to open the DBMS definition filein the Resource Editor, and then click the Trigger Template tab.

2. Click a trigger template in the list, and then click the Properties tool toopen its property sheet .

3. Type a new trigger name in the Trigger Name text box at the bottom ofthe tab.

For example, mytempl_%TABLE%

4. Click OK in each of the dialog boxes.

Calling a related procedure in a trigger template

Some target databases do not accept code within a trigger statement. Forthese databases, a trigger template can call a related procedure as aparameter, which is defined in a procedure template. In these cases,procedure templates are listed in the list of trigger templates.

Example Informix does not accept code in trigger templates. The templateInsertTrigger calls the procedure in the form of the variable %PROC%, asfollows:

-- Insert trigger "[%QUALIFIER%]%TRIGGER%" for table"[%QUALIFIER%]%TABLE%"

create trigger [%QUALIFIER%]%TRIGGER% insert on[%QUALIFIER%]%TABLE%

referencing new as new_insfor each row (execute procedure %PROC%(.FKCOLN("new_

ins.%COLUMN%", "", ",", "));")/

The template InsertProc defines the procedure, as follows:

203

Page 216: Physical Data Model - SAP

Triggers (PDM)

-- Insert procedure "%PROC%" for table "[%QUALIFIER%]%TABLE%"create procedure %PROC%(.FKCOLN("new_%.14L:COLUMN% %COLTYPE%",

"", ",", ")").DeclInsertChildParentExist.DeclInsertTooManyChildrendefine errno integer;define errmsg char(255);define numrows integer;

.InsertChildParentExist

.InsertTooManyChildren

end procedure;/

Multiple triggers

Some DBMSs allow you to have multiple triggers of the same type (timeand event) defined for any given table. Triggers of the same type are triggersthat are invoked for the same insert, update, or delete event.

Example A company is considering large numbers of candidates for new positions invarious posts. You want to ensure that all new employees will have a salarythat is within the range of others working in the same field, and less than hisor her prospective manager.

On an EMPLOYEE table, you create two BeforeInsert triggers ,tibTestSalry1_EMPLOYEE to verify that a proposed salary falls withinthe correct range, and tibTestSalry2_EMPLOYEE to verify that theproposed salary is less than that of the prospective manager.

create trigger tibTestSalry1 before insert order 1 on EMPLOYEEreferencing new as new_ins for each rowbegin

[Trigger code]

end

create trigger tibTestSalry2 before insert order 2 on EMPLOYEEbegin

[Trigger code]

end

For a specified table, you can indicate the order that a trigger executes, orfires, within a group of triggers of the same type.

204

Page 217: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

v To indicate trigger order

1. Click the Definition tab from the trigger property sheet.

2. Select a number from the Order dropdown list box to indicates theposition in the firing order that the trigger fires.

3. Click OK in each of the dialog boxes.

Defining triggers with multiple events

Some DBMSs support multiple events on triggers. If such is the case, theEllipsis button to the right of the Event box on the trigger definition tab isavailable.

You can click the Ellipsis button to open the Multiple Events Selection box.If you select several events and click OK, the different events will bedisplayed in the Event box, separated by the appropriate delimiter.

205

Page 218: Physical Data Model - SAP

Trigger Templates (PDM)

Trigger Templates (PDM)PowerDesigner trigger templates and template items allow you to createtriggers in a modular reusable fashion.

PowerDesigner uses pre-defined trigger templates to create triggers toimplement referential integrity between tables. Trigger templates exist foreach type of trigger supported by the DBMS. Each template specifies:

♦ a Time – relevant to an event. One of:• After

• Before

♦ an Event – that can occur to a table row. One of:• Delete

• Insert

• Update

♦ Code – that performs the trigger action. The code may contain referencesto trigger template items, which are re-usable blocks of script.

You can create trigger templates and trigger template items in your DBMSdefinition file or in your model. These elements will be available as follows:

Trigger template or templateitem created in:

Available to

DBMS (shared definitionfile)

All models sharing the DBMS

DBMS (copied definition file Current model only

Model Current model only

+ For more information on the DBMS share and copied definition files,see the “Generating a Database from a PDM” chapter.

Modifying DBMS template itemsBy modifying a DBMS template item, you modify the template itemdefinition in the current DBMS. You should only modify a DBMS that is acopy of the DBMS shipped with PowerDesigner.

+ For more information on creating and copying a DBMS, see the “TheResource Editor” chapter in the General Features Guide .

206

Page 219: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

Creating a trigger template

You can create a new trigger template in your DBMS definition file or aspart of your model. You can begin by copying an existing template or writeone from scratch.two types of trigger templates:

v To create a trigger template

1. To create a DBMS trigger template: select Database ä Edit CurrentDBMS to open the DBMS definition file in the resource editor, and thenclick the Trigger Templates tab:

or

To create a model trigger template: select Model ä Triggers ä TriggerTemplates to open the List of User-Defined Trigger Templates:

207

Page 220: Physical Data Model - SAP

Trigger Templates (PDM)

2. Click on one of the following tools:♦ Create from DBMS trigger template – opens a selection box listing

all the trigger templates available in the current DBMS. Select a checkbox for the type of trigger template that you want to use as the basis foryour new template and click OK to return to the trigger template list.The duplicate DBMS template has been added to the list.

♦ Add a Row – adds a new blank template to the list.

3. Type a new name and code for the new template and click Apply tocommit its creation.

4. Click the Properties tool to open the property sheet of the new triggertemplate:

208

Page 221: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

5. Click the Definition tab and enter or modify the definition code. You canadd trigger template items, use PDM variables and macros and variousother tools available from the toolbar. For more information, see “SQLCode Definition Toolbars” on page 238.

6. You can also modify other of the trigger template’s properties. For a fulllist of the properties available, see “Trigger template properties” onpage 211.

7. Click OK in each of the dialog boxes.

If you have created DBMS trigger template, a confirmation box willappear, asking if you want to save the changes to the DBMS.

Click Yes to confirm the template creation.

PowerDesigner pre-defined trigger templates

The pre-defined DBMS templates provided with PowerDesigner controlreferential integrity constraints for insert, update, and delete events.Depending on the current DBMS, there is a before and after event templatefor each trigger type.

You can modify the code of these pre-defined trigger templates, but theycannot be deleted or renamed.

The following templates types exist, but may vary by DBMS:

Insert templates

209

Page 222: Physical Data Model - SAP

Trigger Templates (PDM)

Template type Generates trigger/procedure executing. . .

InsertTrigger With insert

BeforeInsertTrigger

Before insert

AfterInsertTrigger After insert

InsertProc When called by InsertTrigger

BeforeInsertProc When called by BeforeInsertTrigger

AfterInsertProc When called by AfterInsertTrigger

Update templates

Template type Generates trigger/procedure executing. . .

UpdateTrigger With update

BeforeUpdateTrigger

Before update

AfterUpdateTrigger After update

UpdateProc When called by UpdateTrigger

BeforeUpdateProc When called by BeforeUpdateTrigger

AfterUpdateProc When called by AfterUpdateTrigger

Delete templates

Template type Generates trigger/procedure executing. . .

DeleteTrigger With delete

BeforeDeleteTrigger

Before delete

AfterDeleteTrigger After delete

DeleteProc When called by DeleteTrigger

BeforeDeleteProc When called by BeforeDeleteTrigger

AfterDeleteProc When called by AfterDeleteTrigger

Modifying a trigger template

You can modify both your templates and those that are provided withPowerDesigner.

210

Page 223: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

v To modify a trigger template

1. Open the trigger template property sheet in one of the following ways:

2. To modify a DBMS trigger template: select Database ä Edit CurrentDBMS to open the DBMS definition file in the resource editor, and thenclick the Trigger Templates tab.

3. To modify a model trigger template: select Model ä Triggers ä TriggerTemplates to open the List of User-Defined Trigger Templates.

4. Click a trigger template in the list, and then click the Properties tool toopen its property sheet.

5. Click the Definition tab and modify the trigger definition code. You canadd trigger template items, use PDM variables and macros and variousother tools available from the toolbar. For more information, see “SQLCode Definition Toolbars” on page 238.

6. You can also modify other of the trigger template’s properties. For a fulllist of the properties available, see “Trigger template properties” onpage 211.

7. Click OK in each of the dialog boxes.

If you have created DBMS trigger template, a confirmation box willappear, asking if you want to save the changes to the DBMS.

Click Yes to confirm the template creation.

Trigger template properties

You can modify a trigger templates properties from its property sheet. Thefollowing sections detail the property sheet tabs that contain the propertiesmost commonly entered for trigger templates.

Trigger template property sheet General tab

The General tab contains the following properties:

Property Description

Name The name of the item which should be clear and meaning-ful, and should convey the item’s purpose to non-technicalusers

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

211

Page 224: Physical Data Model - SAP

Trigger Templates (PDM)

Property Description

Comment Descriptive label for the trigger template

DBMS Current DBMS

Trigger time Time attribute of the trigger template. The list displays thevalues defined in the trigger templates and template itemsof the current DBMS

Trigger event Event attribute of the trigger template. The list displays thevalues defined in the trigger templates and template itemsof the current DBMS

Trigger name Name of trigger associated with template

Applies to ta-ble triggers orview triggers

For those DBMS that support view triggers, it allows youto define if the trigger template applies to table or viewtriggers

Trigger template property sheet Definition tab

The Definition tab contains a field for entering its definition code. Forinformation about editing this code, see ““Modifying Triggers” onpage 199”.

Trigger template property sheet Template Items tab

The Template Items tab list the template items that are defined in the triggertemplate and that will be generated when a trigger is generated from thetemplate.

A template item that is deleted from the Template Items tab is not deletedfrom the trigger template definition. You can therefore limit the templateitems available for generation by removing template items from theTemplate Item tab, without having to remove them from the trigger templatedefinition.

Rebuild triggers When you use Rebuild Triggers to automatically create triggers for selectedtables, the template items that are listed on this tab are those available forgeneration. Whether they are generated or not depends on the following:

♦ Template items are generated in a trigger if they match the triggerimplemented referential integrity defined for a reference attached to thetable

♦ Template items are generated in a trigger if they are user-defined,regardless of trigger referential integrity constraints

212

Page 225: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

Adding template items totrigger template definition

You can add any template item from the model or DBMS to the Triggertemplate definition by clicking an Add Trigger Item tool from the Definitiontab of the trigger template property sheet, and selecting a trigger item. It isautomatically added to the Template Items tab.

213

Page 226: Physical Data Model - SAP

Trigger Template Items (PDM)

Trigger Template Items (PDM)Trigger template items are named reusable blocks of script that can beinserted into trigger templates or triggers.

In a generated trigger script, a template item calls a macro that implements atrigger referential integrity constraint or does any other updating work ontables in the database.

Example A trigger template for Sybase Adaptive Server Anywhere 6 contains the.InsertChildParentExist template item, which corresponds to thefollowing definition:

.FOREACH_PARENT()/* Parent "[%PQUALIFIER%]%PARENT%" must exist when inserting a

child in "[%CQUALIFIER%]%CHILD%" */if (.JOIN("new_ins.%FK% is not null", "", " and", ") then")begin

set found = 0;select 1into foundfrom dummywhere exists (select 1

from [%PQUALIFIER%]%PARENT%where .JOIN("%PK% = new_ins.%FK%", "and ",

"", ");")if found <> 1 then

message ’Error: Trigger(%TRIGGER%) of table[%QUALIFIER%]%TABLE%’;

message ’ Parent code must exist when inserting achild!’;

signal user_defined_exception;end if;

endend if;.ENDFOR

Creating a trigger template item

You usually create a template item when an existing template item is notsuitable, or to create a repeatable block of code to do updating work ontables in the database.

You can create a new trigger template in your DBMS definition file or aspart of your model. You can begin by copying an existing template or writeone from scratch.

214

Page 227: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

v To create a trigger template item

1. To create a DBMS trigger template item: select Database ä Edit CurrentDBMS to open the DBMS definition file in the resource editor, and thenclick the Trigger Template Items tab:

or

To create a model trigger template item: select Model ä Triggers ä

Trigger Template Items to open the List of User-Defined TriggerTemplate Items:

2. Click on one of the following tools:♦ Create from DBMS trigger item – opens a selection box listing all

the trigger template items available in the current DBMS. Select a

215

Page 228: Physical Data Model - SAP

Trigger Template Items (PDM)

check box for the type of item that you want to use as the basis foryour new item and click OK to return to the trigger template item list.The duplicate DBMS template item has been added to the list.

♦ Add a Row – adds a new blank template item to the list.

3. Type a new name and code for the new template item and click Apply tocommit its creation.

4. Click the Properties tool to open the property sheet of the new templateitem:

5. Click the Definition tab and enter or modify the definition code. You canuse PDM variables and macros and various other tools available from thetoolbar. For more information, see “SQL Code Definition Toolbars” onpage 238.

6. You can also modify other of the trigger template item’s properties. For afull list of the properties available, see “Trigger template item properties”on page 220.

7. Click OK in each of the dialog boxes.

If you have created DBMS trigger template item, a confirmation box willappear, asking if you want to save the changes to the DBMS.

Click Yes to confirm the template creation.

216

Page 229: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

PowerDesigner pre-defined trigger template items

PowerDesigner ships pre-defined template items for each pre-defined triggertemplate defined in the supported DBMS. The Rebuild Triggers functionuses both pre-defined and user-defined trigger templates to automaticallycreate triggers for selected tables.

In the pre-defined trigger templates, each pre-defined template itemcorresponds to a referential integrity constraint. Although a pre-definedtemplate item is defined in a trigger template, it is only generated in a triggerscript if it implements the trigger referential integrity defined for a reference.

Template items have the following generation conditions:

Template item is listed in. . . Template item is. . .

Template Items tab of triggerproperty sheet

Available for generation

Template Items tab of triggertemplate property sheet

Generated

You can modify the code for these pre-defined template items, but theycannot be deleted or renamed.

The PowerDesigner pre-defined template items that are available depend onthe current DBMS.

Insert constraints The template items below implement referential integrity in insert triggertemplates.

Template item Integrity con-straint

Description

DeclInsertChildParentExistInsertChildParentExist

Mandatory parent Parent must existwhen inserting achild

DeclInsertTooManyChildrenInsertTooManyChildren

Cannot exceedmaximum cardi-nality constraint

Cannot insert achild if maximumcardinality hasbeen reached

DeclInsertSequenceColumnInsertSequenceColumn

Select value insequence list forcolumn

Select a value forthe column from alist of sequences

217

Page 230: Physical Data Model - SAP

Trigger Template Items (PDM)

Update constraints The template items below implement referential integrity in update triggertemplates.

Template item Integrity con-straint

Description

DeclUpdateChildParentExist

UpdateChildParentExist

Mandatory par-ent

Parent must existwhen updating achild

DeclUpdateChildChangeParent

UpdateChildChangeParent

Change parentnot allowed

Cannot modifyparent code inchild

DeclUpdateParentRestrict

UpdateParentRestrict

Restrict on up-date

Cannot modifyparent if childexists

DeclUpdateParentCascade

UpdateParentCascade

Cascade on up-date

Modify parentcode in all chil-dren

DeclUpdateChangeColumn

UpdateChangeColumn

Non-modifiablecolumn

Cannot modifycolumn

DeclUpdateParentSetNull

UpdateParentSetNull

Set null on up-date

Set parent code tonull in all children

DeclUpdateParentSetDefault

UpdateParentSetDefault

Set default onupdate

Set parent codeto default in allchildren

DeclUpdateTooManyChildren

UpdateTooManyChildren

Cannot exceedmaximum car-dinality con-straint

Cannot update achild if maximumcardinality hasbeen reached

Delete constraints The template items below implement referential integrity in delete triggertemplates.

Template item Integrity con-straint

Description

DeclDeleteParentRestrict

DeleteParentRestrict

Restrict ondelete

Cannot deleteparent if childexists

218

Page 231: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

Template item Integrity con-straint

Description

DeclDeleteParentCascade

DeleteParentCascade

Cascade ondelete

Delete parentcode in all chil-dren

DeclDeleteParentSetNull

DeleteParentSetNull

Set null ondelete

Delete in parentsets child to null

DeclDeleteParentSetDefault

DeleteParentSetDefault

Set default ondelete

Delete in parentsets child to de-fault

Constraint messages You can insert the following template items in any trigger template. Theygenerate error messages that indicate the violation of an integrity constraint.

Template item Description

UseErrorMsgText Error handling without a message table

UseErrorMsgTable Error handling with a message table

Modifying a trigger template item

You can modify both your template items and those that are provided withPowerDesigner.

v To modify a trigger template item

1. Open the trigger template item property sheet in one of the followingways:

2. To modify a DBMS trigger template item: select Database ä Edit CurrentDBMS to open the DBMS definition file in the resource editor, and thenclick the Trigger Template Items tab.

3. To modify a model trigger template item: select Model ä Triggers ä

Trigger Templates Items to open the List of User-Defined TriggerTemplate Items.

4. Click a trigger template item in the list, and then click the Properties toolto open its property sheet.

5. Click the Definition tab and modify the trigger definition code. You canuse PDM variables and macros and various other tools available from the

219

Page 232: Physical Data Model - SAP

Trigger Template Items (PDM)

toolbar. For more information, see “SQL Code Definition Toolbars” onpage 238.

6. You can also modify other of the trigger template item’s properties. For afull list of the properties available, see “Trigger template item properties”on page 220.

7. Click OK in each of the dialog boxes.

If you have created DBMS trigger template item, a confirmation box willappear, asking if you want to save the changes to the DBMS.

Click Yes to confirm the template creation.

Trigger template item properties

You can modify an object’s properties from its property sheet. To open atrigger template item property sheet, access it via the List of User-DefinedTrigger Template Items List or the DBMS Properties window. The followingsections detail the property sheet tabs that contain the properties mostcommonly entered for trigger template items.

Trigger template item property sheet General tab

The General tab contains the following properties:

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the template item

DBMS Current DBMS

Trigger template item property sheet Definition tab

The Definition tab allows you to enter the SQL code for the template item.For information about the tools available, see “SQL Code DefinitionToolbars” on page 238.

Trigger template item property sheet Declaration tab

The Declaration tab contains the declaration for the template item in trigger

220

Page 233: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

scripts. For information about the tools available, see “SQL Code DefinitionToolbars” on page 238.

221

Page 234: Physical Data Model - SAP

Stored Procedures and Functions (PDM)

Stored Procedures and Functions (PDM)You can define stored procedures and functions for any DBMS that supportsthem.

A stored procedure is a precompiled collection of SQL statements storedunder a name and processed as a unit. Stored procedures are stored within adatabase; can be executed with one call from an application; and allowuser-declared variables, conditional execution, and other programmingfeatures.

The use of stored procedures can be helpful in controlling access to data(end-users may enter or change data but do not write procedures), preservingdata integrity (information is entered in a consistent manner), and improvingproductivity (statements in a stored procedure only need to be written onetime).

A user-defined function is a form of procedure that returns a value to thecalling environment for use in queries and other SQL statements.

Creating a stored procedure or function

You can create a stored procedure or function in any of the following ways:

♦ Use the Procedure tool in the diagram Palette

♦ Open the Procedures tab in the property sheet of a table, and click theAdd a Row tool

♦ Select Model ä Procedures to access the List of Procedures, and click theAdd a Row tool

♦ Right-click the model or package in the Browser, and select New ä

Procedure

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

You can create a procedure based on one of the PowerDesigner templates oron a template of your own.

v To create a procedure

1. Double-click a table symbol to open its property sheet, and then click theProcedures tab.

2. Click the Add a Row tool to create a new procedure, and type a name andcode.

222

Page 235: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

3. Click Apply to commit the creation of the new procedure, and then clickthe Properties tool to open its property sheet.

4. Click the Definition tab:

5. [optional] Select a procedure template from the Template list (see“Procedure Templates (PDM)” on page 233).

6. Modify the procedure definition code. You can use PDM variables andmacros and various other tools available from the toolbar (see “SQLCode Definition Toolbars” on page 238).

7. You can also modify the procedure’s other properties. For a full list of theproperties available, see “Procedure properties” on page 223.

8. Click OK in each of the dialog boxes.

Editing procedures in EclipseWhen using the PowerDesigner Eclipse plug-in, you can right-click aprocedure in the Browser or diagram and select Edit in SQL Editor fromthe contextual menu to open it in the Eclipse SQL Editor. You canoptionally connect to your database in order to obtain auto-completion fortable names. The procedure definition is added to the Generated SQL Fileslist in the Workspace Navigator.

Procedure properties

You can modify an object’s properties from its property sheet. To open aprocedure property sheet, double-click its diagram symbol or its Browserentry in the Procedures folder. The following sections detail the propertysheet tabs that contain the properties most commonly entered for procedures.

223

Page 236: Physical Data Model - SAP

Stored Procedures and Functions (PDM)

Procedure property sheet General tab

The General tab contains the following properties:

Property Description

Name Specifies the name of the item which should be clear andmeaningful, and should convey the item’s purpose to non-technical users.

Code Specifies the technical name of the item used for generatingcode or scripts, which may be abbreviated, and should notgenerally include spaces.

Comment Specifies a descriptive label for the procedure.

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined.

Owner Specifies the name of the procedure owner.

Table Specifies the table to which the procedure is attached. Youcan use the tools to the right of the list to create an object,browse the complete tree of available objects or view theproperties of the currently selected object.

Procedure property sheet Definition tab

The Definition tab allows you to enter the SQL code for the procedure. Forinformation about the tools available, see “SQL Code Definition Toolbars”on page 238.

Tracing Trigger and Procedure Dependencies

When you write a trigger or procedure, PowerDesigner automatically createsdependencies to any table, view, procedure, or database package referencedin the code. These dependencies are taken into account when performing animpact analysis prior to deleting the trigger or procedure or objects on whichthey depend. For procedures, if the procedure has a symbol in your diagram,then any dependencies will be shown graphically by way of arrows linkingthe procedure to these objects.

The diagram below shows a procedure, ProcChangeLocation, which isdependent on a number of other objects:

224

Page 237: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

The Extended Dependencies tab of the trigger or procedure property sheetlists the objects upon which it depends. The stereotype <<DBCreateAfter(computed)>> specifies that PowerDesigner has determined that the triggeror procedure can only be created after these objects.

The Dependencies tab of the Employee table property sheet shows thatProcChangeLocation is dependent upon it.

225

Page 238: Physical Data Model - SAP

Stored Procedures and Functions (PDM)

If you were to perform an impact analysis prior to deleting the Employeetable, you would be warned of the dependency of the procedure upon it.

226

Page 239: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

Creating procedure dependencies manually

Since procedures have diagram symbols, you can manually adddependencies for them. To do this, use the Link/Extended Dependency toolin the palette. In the diagram below, I have added a dependency fromProcChangeLocation to a new procedure, ProcOccupancy:

227

Page 240: Physical Data Model - SAP

Stored Procedures and Functions (PDM)

Since ProcOccupancy is not directly referenced in ProcChangeLocation, Ineeded to manually add the stereotype <<DBCreateAfter>> to thedependency in the ProcChangeLocation property sheet ExtendedDependencies tab:

Rebuilding trigger and procedure dependencies

Trigger and procedure dependencies are rebuilt automatically after thefollowing actions:

228

Page 241: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

♦ Importing a PDM created with a former version of PowerDesigner

♦ Reverse engineering a database into a PDM

♦ Merging PDMs

You can also manually rebuild trigger and procedure dependencies at anytime.

v To rebuild trigger and procedure dependencies

1. Select Tools ä Rebuild Objects ä Rebuild Triggers and ProceduresDependencies to open the Procedures Dependencies window.

2. Specify a rebuild mode for each of Procedures and Triggers. You canchoose between the following options:

♦ Delete and Rebuild – all triggers and/or procedures attached totemplates are deleted and rebuilt, including those to which you havemade modifications

♦ Preserve – only those triggers and/or procedures attached to templatesthat have not been modified are deleted and rebuilt. Any triggersand/or procedures that you have modified are preserved.

3. [optional] Click the Selection tab and specify the tables, views,procedures, and (for Oracle only) database packages for which you wantto rebuild dependencies. By default all are selected.

4. Click OK to begin the rebuild process.

229

Page 242: Physical Data Model - SAP

Stored Procedures and Functions (PDM)

Attaching a stored procedure to a table

You can attach a stored procedure to a table when your current DBMSsupports stored procedures. This feature lets you update the table or retrieveinformation from this table.

For example, the stored procedure TABLE_ADDROW can be attached to atable in which you need to insert rows.

Intermodel generation When you generate an OOM from a PDM, the procedures attached to a tablebecome operations with the <<procedure>> stereotype in the generatedclass. By attaching procedures to tables, you are able to define classoperations in the generated OOM.

When you generate a PDM from an OOM, class operations with the<<procedure>> stereotype become stored procedures attached to thegenerated table. The operation body is generated as a comment in theprocedure definition.

You can attach a table to a procedure from the property sheet of a procedureor the property sheet of a table.

v To attach a stored procedure to a table

1. Open the table property sheet and click the Procedures.

2. Click the Add Objects tool to open a selection box, choose the the storedprocedure you want to attach to the table and click OK.

The stored procedure is displayed in the list of stored procedures.

230

Page 243: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

3. Click OK.

Rebuilding procedures attached to tables

You can rebuild procedures attached to tables at any time.

231

Page 244: Physical Data Model - SAP

Stored Procedures and Functions (PDM)

v To rebuild procedures attached to tables manually

1. Select Tools ä Rebuild Objects ä Rebuild Table Stored Procedures toopen the Rebuild Table Stored Procedures window.

2. Specify a rebuild mode. You can choose between the following options:♦ Delete and Rebuild – all procedures attached to tables are deleted and

rebuilt

♦ Add missing table stored procedures – adds procedures to any selectedtables that do not presently have them.

3. [optional] Click the Selection tab to specify for which tables you want torebuild stored procedures.

4. Click OK to begin the rebuild process.

232

Page 245: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

Procedure Templates (PDM)PowerDesigner procedure templates allow you to create procedures in amodular reusable fashion.

PowerDesigner provides certain basic procedure templates and also allowsyou to write your own. You can create procedure templates in your DBMSdefinition file or in your model. These elements will be available as follows:

Procedure template created in: Available to

DBMS (shared definition file) All models sharing the DBMS

DBMS (copied definition file) Current model only

+ For more information on the DBMS share and copied definition files,see the “Generating a Database from a PDM” chapter.

Modifying DBMS template itemsBy modifying a DBMS template, you modify its definition in the currentDBMS. You should only modify a DBMS if you have already made a copyof the DBMS definition file provided with PowerDesigner.

+ For more information on creating and copying a DBMS, see the “TheResource Editor” chapter in the General Features Guide .

Creating a procedure template

You can create a new procedure template in your DBMS definition file or aspart of your model. You can begin by copying an existing template or writeone from scratch:

233

Page 246: Physical Data Model - SAP

Procedure Templates (PDM)

v To create a procedure template

1. Select Database ä Edit Current DBMS to open the DBMS definition filein the resource editor, and then click the Procedure Templates tab:

2. Click the Add a Row tool to add a new blank template to the list.

3. Type a new name and code for the new template and click Apply tocommit its creation.

4. Click the Properties tool to open the property sheet of the new proceduretemplate:

5. Click the Definition tab and enter or modify the definition code. You can

234

Page 247: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

use PDM variables and macros and various other tools available from thetoolbar (see “SQL Code Definition Toolbars” on page 238).

6. You can also modify other of the procedure template’s properties. For afull list of the properties available, see “Procedure template properties”on page 236.

7. Click OK in each of the dialog boxes.

A confirmation box will appear, asking if you want to save the changes tothe DBMS.

Click Yes to confirm the template creation.

PowerDesigner pre-defined procedure templates

The pre-defined DBMS templates provided with PowerDesigner generateSQL insert, delete, update, and select statement procedures.

You can modify the code of these pre-defined procedure templates, but theycannot be deleted or renamed.

The following templates, which create procedures linked to tables, areprovided for those databases that support them:

Template type Generates procedure executing. . .

DeleteProcedure a SQL Delete statement

InsertProcedure a SQL Insert statement

SelectProcedure a SQL Select statement

UpdateProcedure a SQL Update statement

Modifying a procedure template

You can modify both your templates and those that are provided withPowerDesigner.

v To modify a procedure template

1. Select Database ä Edit Current DBMS to open the DBMS definition filein the resource editor, and then click the Procedure Templates tab.

2. Click a procedure template in the list, and then click the Properties tool toopen its property sheet.

3. Click the Definition tab and modify the procedure definition code. Youcan use PDM variables and macros and various other tools available from

235

Page 248: Physical Data Model - SAP

Procedure Templates (PDM)

the toolbar. For more information, see “SQL Code Definition Toolbars”on page 238.

4. You can also modify other of the procedure template’s properties. For afull list of the properties available, see “Procedure template properties”on page 236.

5. Click OK in each of the dialog boxes.

A confirmation box will appear, asking if you want to save the changes tothe DBMS.

Click Yes to confirm the template creation.

Procedure template properties

You can modify a procedure template’s properties from its property sheet.The following sections detail the property sheet tabs that contain theproperties most commonly entered for procedure templates.

Procedure template property sheet General tab

The General tab contains the following properties:

Property Description

Name The name of the item which should be clear and meaning-ful, and should convey the item’s purpose to non-technicalusers.

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces.

Comment Descriptive label for the procedure template.

DBMS Current DBMS.

Function Specifies whether the template defines procedures or func-tions.

ProcedureName

Specifies the format of the resulting procedure names.

Linked to table Specifies whether the resulting procedure will be linked toa table.

Procedure template property sheet Definition tab

The Definition tab contains a field for entering its definition code. For

236

Page 249: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

information about editing this code, see ““Modifying a procedure template”on page 235”.

237

Page 250: Physical Data Model - SAP

SQL Code Definition Toolbars

SQL Code Definition ToolbarsThe following tools are available on the Definition tabs of trigger, procedureand template property sheets:

Tool Description

Add Trigger Item From Model - [Triggers and trigger templatesonly] Opens a dialog box to select a trigger template item defined inthe model for insertion in the trigger definition.

Add Trigger Item From DBMS - [Triggers and trigger templatesonly] Opens a dialog box to select a trigger template item defined inthe DBMS definition file for insertion in the trigger definition.

Operators - Lists logical operators for insertion in the triggerdefinition.

Functions - Lists group, number, string, date, conversion and otherfunctions for insertion in the trigger definition.

Macros - Lists macros for insertion in the trigger definition. Formore information on macros, see the “Writing SQL Statements inPowerDesigner” appendix.

Variables - Lists variables for use with operators and functionsfor insertion in the trigger definition. You can also use formattingvariables that have a syntax that can force a format on their values,as follows:♦ Force values to lower-case or upper-case characters

♦ Truncate the length of valuesFor more information on variables, see List of PowerDesignervariables in chapter Variables in PowerDesigner.

Edit with SQL Editor - Opens the SQL Editor dialog box. Pro-vides object types and available objects for insertion in the triggerdefinition.

SQL/XML Wizard - Opens the SQL/XML Wizard to build aSQL/XML query from a table or a view and insert it in the triggerdefinition. For more information on the SQL/XML Wizard, see““Using the SQL/XML Wizard” on page 240”.

Insert SQL/XML Macro - Opens a dialog box to select a global ele-ment in an XML model open in the workspace with the SQL/XMLextended model definition. Inserts a SQL/XML macro referencingthe selected element in the trigger definition.

238

Page 251: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

+ For more information on macros and variables, see the “Writing SQLStatements in PowerDesigner” appendix.

+ For more information on the SQL/XML Wizard, see “Using theSQL/XML Wizard” on page 240.

239

Page 252: Physical Data Model - SAP

Using the SQL/XML Wizard

Using the SQL/XML WizardYou can use the SQL/XML Wizard to insert a SQL/XML query in thedefinition of a trigger, a stored procedure or a function. With the SQL/XMLWizard, you select tables and views from a PDM to build a mapped XMLmodel. This silent XML model (it does not appear in the workspace) is usedto generate SQL/XML queries from global elements. These SQL/XMLqueries allow you to store or retrieve data, in an XML format, fromrelational databases supporting SQL/XML.

During the SQL/XML Wizard process, you can perform the followingactions:

♦ Generate columns as elements or attributes

♦ Generate tables and views as elements by drag and drop or the contextualmenu

♦ Display tables, views or columns property sheets

♦ Add Sequence, Choice or All group particles

♦ Rename elements or attributes

♦ Add new elements or attributes without mapping

♦ Delete elements, attributes or group particles

v To insert a SQL/XML query in the definition of a trigger

1. In the trigger property sheet, select the Definition tab and position thecursor in the trigger definition where you want to insert the SQL/XMLquery.

2. In the toolbar of the Definition tab, click the SQL/XML Wizard tool.

3. Select tables and views and click Next.

4. Build an XML hierarchy and click Next.

5. In the Query tab, click Finish.

These different actions are detailed in the following sections.

Note: The trigger used in the following sections is defined in project.pdm, aPDM from the PowerDesigner Examples library.

240

Page 253: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

Launching the SQL/XML Wizard

Double-click the trigger item in the Browser tree view to display its propertysheet.

Click the Definition tab to display the Definition tab.

Click in the trigger definition and position the cursor where you want toinsert a SQL/XML query.

241

Page 254: Physical Data Model - SAP

Using the SQL/XML Wizard

In the toolbar of the Definition tab, click the SQL/XML Wizard tool.

Selecting tables and views

The SQL/XML Wizard opens to the Tables and Views Selection tab.

All tables and views are selected by default. Click the Deselect All tool and

242

Page 255: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

select the tables and views you want to generate into XML elements.

Click Next.

Building an XML hierarchy

In the XML Hierarchy Design page, you build the structure of an XMLmodel.

The XML model starts with the predefined Root element to which all firstgeneration elements must be linked.

In the Create column option, click the Element radio button if you want tocreate columns as child elements, otherwise they are created as attributes.

Click a table name in the left panel and drag and drop it to the Root elementin the right panel.

An element is displayed in the right panel, linked to the Root element via asequence group particle, with the table name and the attributes or childelements corresponding to the table columns.

243

Page 256: Physical Data Model - SAP

Using the SQL/XML Wizard

+ For more information on building an XML hierarchy, see Generating anXML model via the XML Builder Wizard, in chapter Generating from aPDM.

Click Next.

Inserting the SQL/XML query in the trigger definition

The Query page displays the SQL/XML query.

244

Page 257: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

Click Finish.

The SQL/XML query is displayed in the definition code at the cursorposition.

<optional> Add code to complete the SQL/XML query.

245

Page 258: Physical Data Model - SAP

Using the SQL/XML Wizard

Click OK.

The trigger definition is modified with the insertion of the SQL/XML query.

246

Page 259: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

Generating Triggers and ProceduresYou can create or modify database triggers to a script or to a live databaseconnection.

v To generate triggers and procedures

1. Select Database ä Generate Database to open the Database Generationwindow, and specify the standard options, including whether you want togenerate to a script or to a live database connection.

+ For detailed information about using this window, see the“Generating a Database” section in the “Generating a Database from aPDM” chapter.

2. Select “Triggers & Procedures (with Permissions)” from the Settings setlist in the Quick Launch groupbox at the bottom of the window. Thissettings set specifies standard options for generating triggers andprocedures.

or:

Click the Options tab and click on Trigger in the left-hand pane to displaythe trigger generation options. Change the default options as appropriate.

+ For detailed information about settings sets, see the “Quick launchselection and settings sets” section in the “Generating a Database from aPDM” chapter.

3. [optional] Click the Selection tab and select the Table or Proceduresubtab at the bottom of the tab. Select the tables or procedures that youwant to generate for. Note that if you want to generate a trigger script fortables owned by a particular owner, you can select an owner from theOwner list.

4. Click OK to begin the generation.

Defining a generation order for stored procedures

You can use extended dependencies to define an order in the generation ofstored procedures.

Extended dependencies are free links between PDM objects. These linkshelp to make object relationships clearer between model objects. Usually,these links are not interpreted and checked by PowerDesigner as they aremeant to be used for documentation purposes only. However, if you assignthe <<DBCreateAfter>> stereotype to an extended dependency betweenstored procedures, it will be analyzed during generation.

247

Page 260: Physical Data Model - SAP

Generating Triggers and Procedures

The procedure from which you start the extended dependency is thedependent procedure and the procedure at the other end of the link is theinfluent procedure. The influent procedure will be generated before thedependent procedure.

Circular extendeddependencies

If you create a reflexive and/or circular set of extended dependencies withthe <<DBCreateAfter>> stereotype, an error message is displayed duringthe check model. If you choose to ignore this error, the stored procedureswill be generated in alphabetical order, without taking into account thegeneration order, which could cause errors in the creation of storedprocedures in the database.

Example A publisher may decide to sell certain books at a reduced rate (15%) when acustomer’s order is above 10 000$.

In this model, one stored procedure GENERAL CHECK globally verifiesorders: check books availability, check the order amount, check if discountrate is calculated, and applies discount rate to order bill. During theexecution of this stored procedure, the procedure DISCOUNT CALC iscalled to calculate the 15% discount rate. It is important to generateGENERAL CHECK before DISCOUNT CALC; you can define an extendeddependency to set the generation order between these two objects. To do so,you have to open the property sheet of the dependent stored procedure, clickthe Extended Dependencies tab and create an extended dependency with the<<DBCreateAfter>> stereotype with the influent stored procedure.

248

Page 261: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

v To define a generation order for stored procedures

1. Select Model ä Procedures to display the List of Stored Procedures.

2. Select a dependent stored procedure in the list and click the Propertiestool.

The property sheet of the stored procedure is displayed.

3. Click the Extended Dependencies tab to display the ExtendedDependencies tab.

4. Click the Add Objects tool.

5. Select the Procedure tab in the Add Object selection dialog box.

6. Select the influent stored procedure check box and click OK.

7. Select the <<DBCreateAfter>> stereotype in the Stereotype list.

8. Click OK.

The influent stored procedure is displayed in the Influent Object columnof the list of extended dependencies of the dependent stored procedure.

+ For more information on extended dependencies, see Using ExtendedDependencies in the General Features Guide.

249

Page 262: Physical Data Model - SAP

Generating Triggers and Procedures

Creating and generating user-defined error messages

You can create user-defined error messages. The error messages are stored ina message table which you need to create in your database. When you selecttrigger generation parameters, you can choose to generate an error messagefrom this table.

In the generated trigger script, the message table is called in a SELECTcommand. If an error number in the script corresponds to an error numbervalue in the table column, then the standard error message is replaced by themessage defined in the table.

Creating a message table

You create a message table which stores error message information.

v To create a message table

1. Create a table with columns to store the following information:

Column to store. . . Description

Error number Number of the error message that is referencedin the trigger script

Message text Text of message

2. Generate the table in your database.

3. Select Database ä Execute SQL.

A dialog box asks you to identify a data source and connectionparameters.

4. Select a data source and fill in connection parameters.

5. Click Connect.

An SQL query editor box is displayed.

6. Type an SQL statement to insert a message number and text in theappropriate columns. You can use the following format for example:

insert into table values (error number,’error message’)

insert into ERR_MSG values (1004,’The value that you are

trying to insert does not exist in the referenced

table’)

250

Page 263: Physical Data Model - SAP

Chapter 5. Building Triggers and Procedures

7. Click Execute.

A message box tells you that the command has been successfullyexecuted.

8. Click OK.

You return to the SQL query box.

9. Click Close.

Generating a user-defined error message

You can choose to generate a user-defined error message from the triggergeneration parameters box.

v To generate a user-defined error message

1. Select Tools ä Rebuild Objects ä Rebuild Triggers.

The Rebuild Triggers dialog box is displayed.

2. Click the Error Messages tab.

The Error Messages tab is displayed.

3. Select the User-defined radio button.

4. Type the name of the table that contains the error message in the MessageTable Name box.

5. Type the name of the column that contains the error number in theMessage Number box.

6. Type the name of the column that contains the error message text in theMessage Text column.

Below is an example of the details for a table called ERR_MSG.

251

Page 264: Physical Data Model - SAP

Generating Triggers and Procedures

7. Click the General tab and select the mode and triggers to create.

8. Click the Selection tab and select the tables for which you want to createtriggers.

+ For more information on rebuilding triggers, see section “RebuildingTriggers” on page 195.

9. Click OK.

The trigger rebuilding process is shown in the Output window.

Select Database ä Generate Database to open the Database Generationwindow.

10. Select generation parameters as required.

11. Click OK.

+ For information on selecting trigger generation parameters, seesection “Generating Triggers and Procedures” on page 247.

252

Page 265: Physical Data Model - SAP

CHAPTER 6

Building a Database Access Structure

About this chapter This chapter explains how to manage access to the database using privilegesand permissions, and defining users, groups, roles, and object synonyms.

Contents Topic: page

Introducing database access 254

Users (PDM) 255

Roles (PDM) 270

Groups (PDM) 273

Synonyms (PDM) 276

253

Page 266: Physical Data Model - SAP

Introducing database access

Introducing database accessIn this manual, we group within the concept of database access, the objectsthat are used to let database users carry out their jobs while preserving theprivacy and integrity of the information within the database.

Depending on the target DBMS, the setting up of a secure databaseenvironment implies the following tasks:

♦ Creation of users (see “Users (PDM)” on page 255)

♦ Creation of groups (see “Groups (PDM)” on page 273)

♦ Creation of roles (see “Roles (PDM)” on page 270)

♦ Definition of system privileges (see “Granting system privileges” onpage 257)

♦ Definition of object permissions (see “Granting object permissions” onpage 262)

Reverse engineering During reverse engineering by script, the permission and privilege grantorders are reverse engineered only if the user, group, or role already exist inthe model or, in the case of a new model, if the user, group, or role creationorders are in the same script.

These restrictions do not apply to reverse engineering from a live databaseconnection.

254

Page 267: Physical Data Model - SAP

Chapter 6. Building a Database Access Structure

Users (PDM)A user is a database object that identifies a person who can login or connectto the database. Users may have:

♦ a role that specifies their responsibilities (see “Roles (PDM)” onpage 270)

♦ membership in a group that specifies their rights (see “Groups (PDM)”on page 273)

♦ privileges that control their level of access (see “Granting systemprivileges” on page 257)

♦ permissions that allow them to perform actions on objects (see “Grantingobject permissions” on page 262)

NoteNot all DBMSs support the concepts of user, role and group.

Creating a user

You can create a user in any of the following ways:

♦ Select Model ä Users and Roles ä Users to access the List of Users, andclick the Add a Row tool.

♦ Right-click the model or package in the Browser, and select New ä User.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

User properties

You can modify an object’s properties from its property sheet. To open auser property sheet, double-click its Browser entry in the Users folder. Thefollowing sections detail the property sheet tabs that contain the propertiesmost commonly entered for users.

User property sheet General tab

The General tab contains the following properties:

255

Page 268: Physical Data Model - SAP

Users (PDM)

Property Description

Name Name of the user

Code Code of the user used as identifier in the database

Comment Descriptive label for the user

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Password Password that may be used for database connection

User property sheet Privileges tab

The Privileges tab lists the system privileges granted to the user. For moreinformation, see “Granting system privileges” on page 257.

User property sheet Permissions tab

The Permissions tab lists the operations that the user is permitted to performon various database objects. For more information, see “Granting objectpermissions” on page 262.

Assigning an ownerto an object

In a database, the user who creates an object (tables, views, storedprocedures, etc) is the owner of the object and is automatically granted allpermissions on it.

When building a PDM, you must attach the user to the object in order tomake it the owner. Each object can have only one owner. In a model wheremany users have access to the same objects, you can restrict objectmodifications to the owner and define permissions for the other users.

Owners can also be used during generation: when you select to generate fora selected owner, only the tables belonging to this owner are generated,whereas when you generate as ADMIN, you generate all the tables on behalfof all their owners.

v To attach an object to a user

1. Open the property sheet of the object.

2. Select a user in the Owner list. You can create a new user by clicking theellipsis button to the right of the Owner list.

256

Page 269: Physical Data Model - SAP

Chapter 6. Building a Database Access Structure

3. Click OK.

Specifying default owners for object types

You can specify a default owner for each type of object that supports theconcept of ownership. The default owner will automatically be linked to allthe objects of this type that you create after making this change.

v To specify a default owner for tables

1. Select Tools ä Model Options and then select Table and View in theleft-hand pane.

2. Select a user in the Default owner list in the Table groupbox. You cancreate a new user by clicking the ellipsis button to the right of the Defaultowner list.

3. Click OK.

For more information, see “Setting PDM Model Options” in theCustomizing the PDM Environment chapter.

Granting system privileges

A system privilege is a set of rights assigned to a database user, group, or

257

Page 270: Physical Data Model - SAP

Users (PDM)

role. You use system privileges to create user profiles with different levels ofinfluence over the database content.

System privileges are used in association with object permissions (see“Granting object permissions” on page 262) to evaluate the rights of a user,group, or role. For example, if a user has the modify privilege, he cannotmodify an object on which he has no update permission.

TerminologyIn some DBMS, system privileges are called permissions. In this manual,the term privilege is used for any right granted to a user, a group, or a role.Permissions are defined for objects.

System privileges vary according to the DBMS you are using. The list ofprivileges also includes predefined roles (like connect, or resource) for aneasier use.

System privileges are granted to a user. A user with administrative profile isalso allowed to revoke a privilege in order to prevent a user from performingcertain actions over the database content.

The list of predefined system privileges allowed in the current DBMS isavailable in the System entry under Script\Object\Privileges in the DBMSresource file. The Privileges category also contains entries used to providethe syntax for the different order corresponding to the DBMS privileges.

Granting system privileges to a user, role, or group

The procedure for defining privileges is identical for users, groups, and roles.

Adding a system privilegeYou can add a system privilege to the list of available privileges from theDBMS editor. To do so, select Database ä Edit Current DBMS, expandcategories Script\Objects\Privileges and type each new system privilege ona new line at the end of the list of privileges in the Value box

Inherited privileges By default, a user belonging to a group or having a role inherits the group orrole privileges. Inherited privileges appear in the Privileges tab of the userproperty sheet.

When you select specific privileges for the user, the list of privilegesdisplays the user privilege above the group privilege. The following tablesummarizes the different privilege combinations:

258

Page 271: Physical Data Model - SAP

Chapter 6. Building a Database Access Structure

Privilege com-bination

Description

Privilege granted to user

Privilege inherited from group

Privilege inherited from group and revoked to user

Privilege inherited from group overloaded by “with adminoption”

v To grant system privileges to a user, role, or group

1. Open the property sheet of a user, role, or group, and click the Privilegestab.

2. Click the Add Objects tool to open a selection box listing all theprivileges available in the DBMS.

3. Select one or more privileges and click OK to add them to the list ofprivileges of the user, role, or group. By default, privileges are granted.

In the example below, the privileges in red are granted to the group towhich the user belongs.

259

Page 272: Physical Data Model - SAP

Users (PDM)

4. [optional] To change the state of a privilege, click in the State columnuntil the desired state is displayed, or select one of the Privilege statetools at the bottom of the tab:

♦ Grant – [default] Assigns the privilege to the user.

♦ Grant with admin option - Assigns the privilege to the user, and allowsthe recipient to pass on the privilege to other users; groups, or roles.For example, you assign the CREATE TABLE privilege for userDesigner_1 and then click the Grant With Admin Option button topermit Designer_1 to grant this privilege to other users.

♦ Revoke – Revokes the privilege inherited from a group or role for thecurrent user or group. This option is only available when the user hasinherited a privilege from a group or a role.

♦ None - Cancels any state and cleans up the current cell.

260

Page 273: Physical Data Model - SAP

Chapter 6. Building a Database Access Structure

5. Click OK.

Generating privileges

You can generate privileges to a script or to a live database connection.

v To generate privileges

1. Select Database ä Generate Database to open the Database Generationwindow, and specify the standard options, including whether you want togenerate to a script or to a live database connection.

+ For detailed information about using this window, see the“Generating a Database” section in the “Generating a Database from aPDM” chapter.

2. Select “Users & Groups (with privileges)” from the Settings set list in theQuick Launch groupbox at the bottom of the window. This settings setspecifies standard options for generating privileges.

or:

Click the Options tab and click on User in the left-hand pane to displaythe user generation options. Change the default options as appropriate.

+ For detailed information about settings sets, see the “Quick launchselection and settings sets” section in the “Generating a Database from aPDM” chapter.

261

Page 274: Physical Data Model - SAP

Users (PDM)

3. [optional] Click the Selection tab and select the Users sub-tab at thebottom of the tab. Select the users that you want to generate for.

4. Click OK to begin the generation.

Granting object permissions

Object permissions are operations attached to particular database objects.

PowerDesigner allows you to define permissions on tables, views, columns,procedures, packages, and other objects depending on your DBMS. Some orall of the following may be available

Permission Description

Select To observe information contained in object

Insert To insert rows into object

Alter To alter table with ALTER TABLE command

Delete To delete rows from object

References To create indexes in tables and foreign key referencingtables

Update To update row in object

Index To create an index with the CREATE INDEX command

Execute To execute procedure or function

+ For more information on the permissions allowed in your DBMS, seeyour DBMS documentation.

Object owner The owner of an object (see “Assigning an ownerto an object” on page 256)automatically has permission to carry out any operation on that object. Thesepermissions do not appear in the Permissions tab of the object property sheetbut they are implemented during generation and reverse engineering.

Granting permissions to a user, role, or group

The procedure for defining privileges is identical for users, groups, and roles.

Inherited permissions A user belonging to a group or having a role with permissions inherits thesepermissions. You can display or hide users with inherited permissions usingthe following tools in the upper part of the Permissions tab:

262

Page 275: Physical Data Model - SAP

Chapter 6. Building a Database Access Structure

Tool Action

Adds users that inherit permissions

Hides users that do not inherit permissions

When you select specific permissions for the user, the list of permissionsdisplays the user permission above the group permission. The followingtable summarizes the different permission combinations:

Permissioncombination

Description

Permission granted to user

Permission inherited from group

Permission granted to group and revoked to user

Permission granted to group and overloaded by “withadmin option”

Permission granted to group and revoked with cascade touser

v To grant permissions to a user, role, or group

1. Open the property sheet of a user, role, or group, and click thePermissions tab. The columns in the list show the permissions availablefor a given type of object in the current DBMS. A sub-tab is displayed foreach type of object supporting permissions in the current DBMS.

2. Click the Add Objects tool to open a selection box listing all the objectsof the present type in the model.

3. Select one or more objects and click OK to add them to the list ofpermissions of the user, role, or group. If the current user belongs to agroup with permissions on the selected objects, these permissions appearin red in the list.

263

Page 276: Physical Data Model - SAP

Users (PDM)

4. [optional] To change the state of a permission, click in the appropriatecolumn until the desired state is displayed, or select one of the Permissionstate tools at the bottom of the tab:

♦ Grant – Assigns the permission to the user.

♦ Grant with admin option - Assigns the permission to the user, andallows the recipient to pass on the permission to other users; groups, orroles.

♦ Revoke – Revokes the permission inherited from a group or role for thecurrent user or group. This option is only available when the user hasinherited a permission from a group or a role.

♦ Revoke with cascade – Revokes the permission inherited from a groupor role for the current user or group and revokes any permissiongranted by the user.

♦ None - Cancels any state and cleans up the current cell.

264

Page 277: Physical Data Model - SAP

Chapter 6. Building a Database Access Structure

5. [optional] For tables, you can specify permissions on individual columns(see “Defining column permissions” on page 267).

6. Click OK.

Granting permissions for an object from its property sheet

You can also grant permissions for an object directly in its property sheet.

v To define permissions from the object property sheet

1. Open the property sheet of the object and click the Permissions tab. Thecolumns in the list show the permissions available for the object in thecurrent DBMS. Sub-tabs allow you to grant permissions to Users, Roles,and Groups.

2. Click the Add Objects tool to open a selection box listing all the users (orroles or groups) in the model.

3. Select one or more users and click OK to add them to the list of userswith permissions on the object. If the user belongs to a group withpermissions on the object, these permissions appear in red in the list.

265

Page 278: Physical Data Model - SAP

Users (PDM)

4. [optional] To change the state of a permission, click in the appropriatecolumn until the desired state is displayed, or select one of the Permissionstate tools at the bottom of the tab:

266

Page 279: Physical Data Model - SAP

Chapter 6. Building a Database Access Structure

5. [optional] For tables, you can specify permissions on individual columns(see “Defining column permissions” on page 267).

6. Click OK.

Defining column permissions

You can fine tune the permissions on a table by specifying permissions on acolumn-by-column basis. The available column permissions are specified inthe DBMS resource file. Note that any new or modified permission may notbe supported during generation or reverse-engineering.

267

Page 280: Physical Data Model - SAP

Users (PDM)

v To define column permissions

1. Open the property sheet of a table, click the Permissions tab, and select auser, group or role:

2. Click the Ellipsis button beside the Columns box to open the ColumnPermissions dialog box. The columns in the list show the permissionsavailable for each of the table’s columns.

268

Page 281: Physical Data Model - SAP

Chapter 6. Building a Database Access Structure

3. Click inside a column cell until the desired state is displayed, or selectone of the Permission state tools at the bottom of the tab.

4. Click OK to close the Column Permissions dialog box and return to theproperty sheet. The cells corresponding to selected column permissionscontain ellipsis symbols. Click on one of these symbols to display theassociated column permissions information in the Columns box.

5. Click OK.

269

Page 282: Physical Data Model - SAP

Roles (PDM)

Roles (PDM)A role is a predefined profile that can be assigned to users, or roles in thoseDBMS that support this concept. Roles are reverse engineered in your modeland you can also create user-defined roles.

Roles may have:

♦ privileges that control their level of access (see “Granting systemprivileges” on page 257)

♦ permissions that allow them to perform actions on objects (see “Grantingobject permissions” on page 262)

Creating a role

You can create a role in any of the following ways:

♦ Select Model ä Users and Roles ä Roles to access the List of Roles, andclick the Add a Row tool.

♦ Right-click the model or package in the Browser, and select New ä Role.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Role properties

You can modify an object’s properties from its property sheet. To open a roleproperty sheet, double-click its Browser entry in the Roles folder. Thefollowing sections detail the property sheet tabs that contain the propertiesmost commonly entered for roles.

Role property sheet General tab

The General tab contains the following properties:

Property Description

Name Name of the role

Code Code of the role used as identifier in the database

Comment Descriptive label for the role

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

270

Page 283: Physical Data Model - SAP

Chapter 6. Building a Database Access Structure

Role property sheet Privileges tab

The Privileges tab lists the system privileges granted to the role. For moreinformation, see “Granting system privileges” on page 257.

Role property sheet Permissions tab

The Permissions tab lists the operations that the role is permitted to performon various database objects. For more information, see “Granting objectpermissions” on page 262.

Assigning a user to a role

Once you have created a role, you can assign users to it.

v To assign a role to a user

1. Select Model ä Users and Roles ä Roles to open the List of Roles.

2. Select a role in the list, click the Properties tool to open its property sheetand then click the Users tab.

3. Click the Add Objects tool to open a selection box listing the usersavailable in the model.

4. Select one or more users and click OK to assign these users to the role.

271

Page 284: Physical Data Model - SAP

Roles (PDM)

5. Click OK.

272

Page 285: Physical Data Model - SAP

Chapter 6. Building a Database Access Structure

Groups (PDM)Groups are used to facilitate the granting of privileges and permissions tousers. They prevent the time-consuming and error-prone process ofassigning privileges and permissions individually to each user.

Groups may have:

♦ privileges that control their level of access (see “Granting systemprivileges” on page 257)

♦ permissions that allow them to perform actions on objects (see “Grantingobject permissions” on page 262)

Creating a group

You can create a group in any of the following ways:

♦ Select Model ä Users and Roles ä Groups to access the List of Groups,and click the Add a Row tool.

♦ Right-click the model or package in the Browser, and select New ä

Group.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Group properties

You can modify an object’s properties from its property sheet. To open agroup property sheet, double-click its Browser entry in the Groups folder.The following sections detail the property sheet tabs that contain theproperties most commonly entered for groups.

Group property sheet General tab

The General tab contains the following properties:

273

Page 286: Physical Data Model - SAP

Groups (PDM)

Property Description

Name Name of the group

Code Code of the group used as identifier in the database

Comment Descriptive label for the group

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Password Password that may be used for database connection

Group property sheet Privileges tab

The Privileges tab lists the system privileges granted to the group. For moreinformation, see “Granting system privileges” on page 257.

Group property sheet Permissions tab

The Permissions tab lists the operations that the group is permitted toperform on various database objects. For more information, see “Grantingobject permissions” on page 262.

Inserting a user into a group

Once you have created a group, you can insert users into it.

274

Page 287: Physical Data Model - SAP

Chapter 6. Building a Database Access Structure

v To insert a user into a group

1. Select Model ä Users and Roles ä Groups to open the List of Groups.

2. Select a group in the list, click the Properties tool to open its propertysheet and then click the Users tab.

3. Click the Add Objects tool to open a selection box listing the usersavailable in the model.

4. Select one or more users and click OK to insert these users into the group.

5. Click OK.

275

Page 288: Physical Data Model - SAP

Synonyms (PDM)

Synonyms (PDM)A synonym is an alternative name for various types of objects (table, view,sequence, procedure, function, synonym or database package). Synonymsare created to:

♦ Mask the name and owner of an object

♦ Provide location transparency for remote objects of a distributed database

♦ Simplify SQL statements for database users

Example For example, table SALES_DATA is owned by user JWARD. A standardselect statement on this table would be:

SELECT * FROM jward.sales_data

The database administrator can create a synonym for this table and ownerand call it SALES. In this case, the SQL statement is simplified in thefollowing way:

SELECT * FROM sales

In PowerDesigner synonyms are created for base objects. The base object isthe object used to create a synonym. Base objects support multiplesynonyms while each synonym must have only one base object. You canview the synonyms depending on a base object in the Dependencies tab ofthe base object property sheet.

If you delete the base object of a synonym, the synonym is deleted as well.

Creating a synonym

You can create a synonym as follows:

276

Page 289: Physical Data Model - SAP

Chapter 6. Building a Database Access Structure

v To create a synonym

1. Select Model ä Synonyms to open the List of Synonyms.

2. Click the Create Synonyms tool to open a selection box listing all theavailable objects in the model on various sub-tabs.

3. Select one or more objects and click OK.

Synonyms for each of the selected objects are created in the List ofSynonyms. By default, a synonym has the same name as its base object.If the Base Object column is not shown in the list, click the CustomizeColumns and Filter tool, select Base Object in the list of availablecolumns, and click OK.

277

Page 290: Physical Data Model - SAP

Synonyms (PDM)

4. Click in the Name column of one of the rows and enter a new name forthe synonym. Alternatively, you can click the Properties tool to open theproperty sheet of the synonym and edit its name and other propertiesthere.

5. Click OK in each of the dialog boxes.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Synonym properties

You can modify an object’s properties from its property sheet. To open asynonym property sheet, double-click its Browser entry in the Synonymsfolder. The following sections detail the property sheet tabs that contain theproperties most commonly entered for synonyms.

Synonym property sheet General tab

The General tab contains the following properties:

Property Description

Name Name of the synonym (usually corresponding to a simplifiedname of the base object)

278

Page 291: Physical Data Model - SAP

Chapter 6. Building a Database Access Structure

Property Description

Code Code of the synonym

Comment Additional information about the synonym

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Owner Name of the synonym owner. You choose an owner from alist of users. A synonym can only have one owner at a time

Base Object Name of the object origin of the synonym. The Ellipsis but-ton displays a selection dialog box that lets you select objectsamong all the models opened in the current workspace andbelonging to the same DBMS family as the current DBMS

Visibility Allows to define a synonym as public (accessible to alldatabase users) or private (available to a specific user)

Type For those DBMS that support it (for example DB2) you cancreate an alias instead of a synonym. In PowerDesignersynonyms and aliases are managed in the same way whereastheir behavior in the database may be different

+ For more information on aliases, see the DB2 documentation.

Creating a view for a synonym

You can create views for synonyms in the same way as you create views fortables. The view query displays the content of the object used for thesynonym. For example, the ORDERS_PROD_DEPT table has a synonymORDERS:

If you create a view for the ORDERS synonym, the view query displays theselect order of the table content:

279

Page 292: Physical Data Model - SAP

Synonyms (PDM)

v To create a view from a synonym

1. Ensure that no objects are selected in the diagram and select Tools ä

Create View to open a selection box listing all the available objects in themodel.

2. Click the Synonyms tab and select one or more synonyms to add to theview.

3. Click OK. The view is created in the diagram.

+ For more information about creating views, see “Views (PDM)” in theBuilding Physical Diagrams chapter.

Generating synonyms

You can generate synonyms from the Database Generation dialog box. Formore information, see the “Generating a Database” section in the“Generating a Database from a PDM” chapter.

Reverse engineering synonyms

PowerDesigner supports the reverse engineering of synonyms.

When you reverse engineer synonyms, the link with the base object ispreserved if both objects are reverse engineered and if the base object isdisplayed before the synonym in the script.

You can reverse a synonym without its base object; in this case you shouldnot forget to define a base object for the synonym.

280

Page 293: Physical Data Model - SAP

Chapter 6. Building a Database Access Structure

For more information about reverse engineering, see the ReverseEngineering a Database into a PDM chapter.

281

Page 294: Physical Data Model - SAP
Page 295: Physical Data Model - SAP

CHAPTER 7

Building Web Services

About this chapter This chapter describes how to create, generate and reverse engineer webservices in the following databases:

♦ Sybase Adaptive Server Anywhere 9 and over

♦ Sybase Adaptive Server Enterprise 15 and over

♦ Sybase IQ12.6 and over

♦ IBM DB2 v8.1 and over

Contents Topic: page

Introducing Web Services 284

Web Services (PDM) 285

Web Operations (PDM) 290

Web Parameters (PDM) 295

Testing Web Services 297

Generating Web Services 298

Reverse Engineering Web Services 302

283

Page 296: Physical Data Model - SAP

Introducing Web Services

Introducing Web ServicesWeb services are applications stored on web servers that you can accessremotely through standard web protocols (HTTP, SOAP) and data formats(HTML, XML. . . ), whatever the systems and programming languages.

In SOAP requests, queries are encapsulated into services, whereas in HTTPrequests, operations are invoked directly. In PowerDesigner, you can designweb services for both protocols.

PowerDesigner supports web services for the following databases:

♦ Sybase Adaptive Server Anywhere 9 and over

♦ Sybase Adaptive Server Enterprise 15 and over

♦ Sybase IQ12.6 and over

♦ IBM DB2 v8.1 and over

Web services can be used to simplify access to databases. If you use webservices to query databases, you no longer need drivers to communicate withthose databases.

In the following example, you can see the result of an HTTP request for adatabase web service:

Web services are made of a set of operations. Each operation contains a SQLquery for retrieving data from a database.

284

Page 297: Physical Data Model - SAP

Chapter 7. Building Web Services

Web Services (PDM)In PowerDesigner, web services are made of web operations whichthemselves contain web parameters and result columns:

♦ Web operations specify the SQL statements used to retrieve data fromdatabases

♦ Web parameters are the parameters which appear in the SQL statements

♦ Result columns are the columns in which the results are displayed

These objects have no symbols, but they appear in the Browser tree view.

This structure is compatible with the definition of web services in thesupported databases.

Import Web service asservice provider

You can import a web service as a service provider into a Business ProcessModel (BPM) to define the links between a concrete implementation ofservice interfaces and operations and their abstract definition.

+ For more information, see “Importing and exporting service providers”in the Building an Executable BPM: Working with Service DescriptionObjects chapter of the BPM User’s Guide .

Web services in Sybase ASA, ASE, and IQ

PowerDesigner supports web services for ASA 9 and over, ASE 15 and overand IQ 12.6 and over. You must specify the type of the web service in theService type list on the General tab of its property sheet (see “Web serviceproperty sheet General tab” on page 287).

Web services can be invoked by either of two protocols:

♦ A web service invoked via an HTTP request can have a RAW, HTML orXML type.

When several web services concern the same table in a database, theirname usually starts with the name of the table, followed by a slash and a

285

Page 298: Physical Data Model - SAP

Web Services (PDM)

specific name identifying the query (e.g. Customer/List,Customer/Name). In that case, the name of the table is called the localpath (which is defined on the General tab of the web service propertysheet).

PowerDesigner treats HTTP web operations which share a local path asbelonging to the web service with that local path name.

♦ [ASA and IQ only] A web service invoked in a SOAP request can have aSOAP or a DISH type.

PowerDesigner treats SOAP web services for these databases as weboperations belonging to a DISH web service.

Implementation (SQLstatement)

When you create a web service, you must type a SQL statement to selectwhich data you want to retrieve from the database in the Implementationtab of the property sheet of its web operation(s). For DISH web services,SQL statements are defined in the SOAP web services bearing their prefixname.

Web services in IBM DB2

PowerDesigner supports web services for IBM DB2 v8.1 and over.

In IBM DB2, web services are defined by Document Access DefinitionExtension (DADX) files.

+ For more information about generating DADX files, see “Generatingweb services for IBM DB2 v8.1” on page 298.

A DADX file specifies a web service through a set of operations defined bySQL statements or Document Access Definition (DAD) files, which specifythe mapping between XML elements and DB2 tables.

+ For more information on DAD files, see “Generating a DAD file forIBM DB2”, in the Exchanging Data with Databases Supporting XML”chapter of the XML Model User’s Guide .

Creating a web service

You can create a web service in any of the following ways:

♦ Select Model ä Web Services to access the List of Web Services, andclick the Add a Row tool.

♦ Right-click the model or package in the Browser, and select New ä WebService.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

286

Page 299: Physical Data Model - SAP

Chapter 7. Building Web Services

Web service properties

You can modify an object’s properties from its property sheet. To open aweb service property sheet, double-click its Browser entry in the WebServices folder. The following sections detail the property sheet tabs thatcontain the properties most commonly entered for web services.

Web service property sheet General tab

The General tab contains the following properties:

Property Description

Name Name of the web service. Used in URIs to access the webservice. It can neither start with a slash nor contain twoconsecutive slashes

Code Code of the web service

Comment Descriptive label for the web service

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined oruser-defined

Local path Name prefixing the web service. If you type a path, theUser-Defined tool (beside the Local path box) is pushed-in.Click the User-Defined tool to recover the original path.The default value is the name of the web service

287

Page 300: Physical Data Model - SAP

Web Services (PDM)

Property Description

Service type [ASA, ASE, and IQ only] Specifies the type of web service.You can choose from:♦ DISH - [ASA and IQ only] acts as a proxy for a group

of SOAP services and generates a WSDL (Web Ser-vices Description Language) file for each of its SOAPservices. When you create a DISH service, you mustspecify a prefix name (on the Extended Attributes tab)for all the SOAP services to which the DISH service ap-plies. PowerDesigner treats SOAP web services as Weboperations (see “Web Operations (PDM)” on page 290)of DISH web services.

♦ HTML – [ASA and IQ only] the result of the SQL state-ment or procedure is formatted as an HTML document(with a table containing rows and columns).

♦ RAW - the result of the SQL statement or procedure issent without any additional formatting.

♦ SOAP - [ASE only] generates a WSDL (Web ServicesDescription Language) file.

♦ XML - the result of the SQL statement or procedureis sent in XML. By default, the result is converted intoXML RAW format.

Web service property sheet Operations tab

This tab lists the web operations associated with the web service (see “WebOperations (PDM)” on page 290).

Web service property sheet Sybase tab

Only available with ASA, ASE, and IQ.

This tab displays the following properties:

288

Page 301: Physical Data Model - SAP

Chapter 7. Building Web Services

Property Description

Port number Specifies the port number for the test URL.

Server name Specifies the server name for the test URL.

Name prefix(dish servicesonly)

[ASA and IQ only] Specifies the name prefix for DISHservices.

Database name [ASE only] Specifies the database name for the test URL.

Web service property sheet Security tab

Only available with ASA and IQ.

This tab displays the following properties:

Property Description

Secured con-nection

If selected, only HTTPS connections are accepted. Ifcleared, both HTTP and HTTPS connections are accepted

Required au-thorization

If selected, all users must provide a name and a password.When cleared, a single user must be identified

ConnectionUser

When authorization is required, you can select <None> ora list of user names. When authorization is not required,you must select a user name. Default value is <None>,which means all users are granted access

Web service property sheet Namespaces tab

Only available with IBM DB2.

This tab displays a list of namespaces with their prefix, URI and comment.

An XML Schema can be specified where elements and data types used inweb parameters and result columns are defined.

289

Page 302: Physical Data Model - SAP

Web Operations (PDM)

Web Operations (PDM)A web operation is a child object of a web service. It allows you to definethe SQL statement of a web service and to display its parameters and resultcolumns.

Creating a web operation

You can create a web operation as follows:

♦ Open the Operations tab in the property sheet of a web service, and clickthe Add a Row tool.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Web operation properties

You can modify an object’s properties from its property sheet. To open aweb operation property sheet, double-click its Browser entry in theOperations folder beneath the parent web service. The following sectionsdetail the property sheet tabs that contain the properties most commonlyentered for web operations.

Web operation property sheet General tab

The General tab contains the following properties:

Property Description

Name Name of the web operation. In URIs, it comes after the nameof the web service followed by a slash. It can neither start witha slash nor contain two consecutive slashes

Code Code of the web operation

Comment Descriptive label for the web operation

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Web Ser-vice

Code of the web service containing the web operation. Youcan click the Properties tool (beside the web Service box) todisplay the web service property sheet

Owner [ASE 15 only] Specifies the owner of the operation.

290

Page 303: Physical Data Model - SAP

Chapter 7. Building Web Services

Property Description

OperationType

[IBM DB2 only] Specifies the type of operation. You canchoose from the following:♦ call - invokes a stored procedure with parameters and result

columns for the web operation

♦ query - retrieves relational data using the SQL select state-ment in the Implementation tab

♦ retrieveXML - retrieves an XML document from relationaldata. The mapping of relational data to XML data is definedby a DAD file with SQL or RDB as MappingType

♦ storeXML - stores an XML document as relational data.The mapping of XML data to relational data is defined by aDAD file, with RDB as MappingType

♦ update - executes the SQL update statement with optionalparameters. Parameters can be created from the Parameterstab in the web operation property sheet

Web operation property sheet Parameters tab

This tab lists the web parameters associated with the web operation. Theseparameters are part of the SQL statement defined on the Implementation tab.They can be created on this tab, before generating a web service, or reverseengineered from a web service (ASA, ASE, and IQ only).

You can use the following tools to add parameters on this tab:

Tool Name Description

Add a Row Adds a parameter to the end of the list.

Insert a Row Inserts a parameter above the current line inthe list.

Add Parametersfrom SQL Imple-mentation

[ASA, ASE, and IQ only] Display the param-eters resulting from the reverse engineering ofthe web service .

Web operation property sheet Implementation tab

This tab displays the SQL statement for the web service. You can use thefollowing tools to type the SQL statement:

291

Page 304: Physical Data Model - SAP

Web Operations (PDM)

Tool Name Description

Operators Provides logical operators

Functions Provides group, number, string, date, conversionand other functions

Macros Provides macros to accelerate the creation of a SQLstatement

Variables Provides variables for use with operators andfunctions

Edit withSQL Editor

Opens the SQL Editor dialog box. Provides objecttypes and available objects to insert in the SQLstatement

SQL/XMLWizard

Opens the SQL/XML Wizard to build a SQL/XMLquery from a table or a view, and insert it in theSQL statement

InsertSQL/XMLMacro

Opens a dialog box to select a global element inan XML model open in the workspace with theSQL/XML extended model definition. Inserts aSQLXML macro referencing the selected elementin the SQL statement

For example:

292

Page 305: Physical Data Model - SAP

Chapter 7. Building Web Services

Web operation property sheet Result Columns tab

This tab lists the result columns associated with the web operation (see“Web Operation Result Columns” on page 294).

You can use the following tools to add result columns on this tab:

Tool Name Description

Add a Row Adds a result column to the end of the list.

Insert a Row Inserts a result column above the current linein the list.

Add Result Columnsfrom Executing SQLStatement

Display the result columns resulting fromthe execution of the SQL statement in thedatabase.

Web operation property sheet Security tab

Only available with ASA, and IQ.

This tab displays the following properties:

Property Description

Secured con-nection

If selected, only HTTPS connections are accepted. If cleared,both HTTP and HTTPS connections are accepted

Required au-thorization

If selected, all users must provide a name and a password.When cleared, a single user must be identified

ConnectionUser

When authorization is required, you can select <None> or alist of user names. When authorization is not required, youmust select a user name. Default value is <None>, whichmeans all users are granted access

Web operation property sheet Sybase tab

Only available with ASE.

This tab displays the following properties:

293

Page 306: Physical Data Model - SAP

Web Operations (PDM)

Property Description

Alias Specifies the user-defined database alias.

Secure Specifies the form of security. You can choose between:♦ Clear – Use standard HTTP

♦ SSL – Use HTTPS

Web Operation Result Columns

Result columns are sub-objects of web operations. They are part of the SQLstatement defined in the Implementation tab of a web operation propertysheet, and belong to a table in the target database. They are listed in theResult Columns tab of a web operation property sheet.

The General tab of a result column property sheet displays the followingproperties:

Property Description

Name Name of the result column

Code Code of the result column

Comment Descriptive label for the result column

Data Type [IBM DB2 only] Select an XML schema data type from thelist, or click the Select Object tool to open a selection dialogbox where you select a global element in an XML model openin the workspace

Is element [IBM DB2 only] Checked and greyed when a global element isattached to a result column

294

Page 307: Physical Data Model - SAP

Chapter 7. Building Web Services

Web Parameters (PDM)Web parameters are child objects of web operations. They are part of theSQL statement defined in the Implementation tab of a web operationproperty sheet. They are listed in the Parameters tab of a web operationproperty sheet.

Creating a web parameter

You can create a web parameter in any of the following ways:

♦ Open the Parameters tab in the property sheet of a web operation, andclick the Add a Row tool.

♦ Right-click a web operation in the Browser, and select New ä WebParameter.

+ For general information about creating objects, see the chapter “GettingStarted with PowerDesigner” in the General Features Guide .

Web parameter properties

You can modify an object’s properties from its property sheet. To open aweb parameter property sheet, double-click its Browser entry in theParameters folder beneath its parent web operation. The following sectionsdetail the property sheet tabs that contain the properties most commonlyentered for web parameters.

Web parameter property sheet General tab

The General tab contains the following properties:

Property Description

Name Name of the web parameter.

Code Code of the web parameter.

Comment Descriptive label for the web parameter.

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined.

Web Oper-ation

Name of the web operation containing the web parameter.

295

Page 308: Physical Data Model - SAP

Web Parameters (PDM)

Property Description

ParameterType

Select in if you want the web parameter to be an input param-eter. Select in/out if you want the web parameter to be bothan input and output parameter. Select out if you want the webparameter to be an output parameter.

DefaultValue

[ASE only] Specifies a default value for the parameter.

Data Type [For IBM DB2] Select an XML schema data type from the list,or click the Select Object tool to open a selection dialog boxwhere you select a global element in an XML model open inthe workspace.

[For ASE] Select a datatype from the list.

Is element [IBM DB2 only] Checked and greyed when a global element isattached to a web parameter.

296

Page 309: Physical Data Model - SAP

Chapter 7. Building Web Services

Testing Web ServicesPowerDesigner provides a method for testing web services within the modelenvironment. You must be connected to the appropriate database.

v To test a web service

1. Right-click the browser entry for a web service of type DISH or SOAPand select Show WSDL

or

Right-click the browser entry for a web service operation belonging to aweb service of another type and select Test Web Service Operation fromthe contextual menu.

2. Review the generated URL and then click OK.

For a web service of type SOAP, the WSDL file will be displayed in yourbrowser

or

For a web service of type RAW, the result will be displayed in yourbrowser

297

Page 310: Physical Data Model - SAP

Generating Web Services

Generating Web ServicesYou generate web services in order to implement them on target databases.

Generating web services for Sybase ASA, ASE, and IQ

You can generate database web services to a script or to a live databaseconnection.

v To generate web services for Sybase ASA, ASE, and IQ

1. Select Database ä Generate Database to open the Database Generationwindow, and specify the standard options, including whether you want togenerate to a script or to a live database connection.

+ For detailed information about using this window, see the“Generating a Database” section in the “Generating a Database from aPDM” chapter.

2. [optional] Click the Options tab and click on Web Service in the left-handpane to display the web service generation options. Change the defaultoptions as appropriate.

3. [optional] Click the Selection tab and select the Web Services subtab atthe bottom of the tab. Select the web services that you want to generate.

4. Click OK to begin the generation.

Note that for web services generated to a live database connection, you mayhave to refresh the Web Services folder before they appear.

Generating web services for IBM DB2 v8.1

In IBM DB2, web services are defined by Document Access DefinitionExtension (DADX) files.

A PDM with the appropriate extended model definition allows you togenerate a DADX file for each web service defined for IBM DB2.

You can attach the DADX extended model definition at model creation. Inthe New dialog box, once you have selected Physical Data Model in theModel type list, and IBM DB2 UDB 8.x Common Server in the DBMS list,click the Extended Model Definitions tab and select DADX.

298

Page 311: Physical Data Model - SAP

Chapter 7. Building Web Services

v To generate DADX files for IBM DB2

1. Select Model ä Extended Model Definitions to open the List of ExtendedModel Definitions.

2. Click the Import an Extended Model Definition tool to open theExtended Model Definition Selection dialog box, select DADX in the listof extended model definitions and click OK.

DADX is displayed in the List of Extended Model Definitions.

3. Click OK to return to the main window.

4. Select Tools ä Extended Generation to open the Generation dialog boxwith DADX selected in the Targets tab.

5. Click the Select a Path button, to the right of the Directory box, andspecify a path for the DADX files.

6. Click the Selection tab, and select the web services for which you want togenerate a DADX file.

299

Page 312: Physical Data Model - SAP

Generating Web Services

7. Click OK to begin generation.

When generation is complete, the Result dialog box will be displayedwith the paths of the DADX files.

8. Select the path of a DADX file and click Edit.

The DADX file is displayed in the editor window.

300

Page 313: Physical Data Model - SAP

Chapter 7. Building Web Services

9. Click Close in the Result dialog box.

You can now use the DADX files for SOAP requests in IBM DB2 UDB webservices Object Runtime Framework (WORF).

301

Page 314: Physical Data Model - SAP

Reverse Engineering Web Services

Reverse Engineering Web ServicesYou reverse engineer web services from a database to a PDM, when youwant to reuse these web services in the PDM. Once reverse engineered, youcan modify and generate them in the database.

You can only reverse engineer web services from Sybase ASA, ASE, and IQ.

You can reverse engineer web services into a new or existing PDM from ascript or live database connection via the Database Reverse Engineeringdialog box.

+ For information about using the Database Reverse Engineering dialogbox, see the “Reverse Engineering a Database into a PDM” chapter.

The following list shows how web service objects in these databases aretreated in PowerDesigner:

♦ Database HTTP web services with a common local path are grouped asPowerDesigner web operations of an HTTP web service with thespecified local path:

Software Web servicename

Type Web operationname

Database Customers/Name HTML —

PowerDesigner Customers HTML Name

♦ Database HTTP web services without a common local path are groupedas PowerDesigner web operations of an HTTP web service named raw,xml or html:

Software Web servicename

Type Web operationname

Database Customers HTML —

PowerDesigner html HTML Customers

♦ Database SOAP web services with a prefix name are considered asPowerDesigner web operations of a DISH web service with the prefixname:

302

Page 315: Physical Data Model - SAP

Chapter 7. Building Web Services

Software Web servicename

Type Web operationname

Database DishPrefix/Name SOAP —

PowerDesigner Customers (withDishPrefix as pre-fix)

DISH Name

♦ Database SOAP web services without a prefix name are considered asPowerDesigner web operations of a DISH web service without a prefixname:

Software Web servicename

Type Web operationname

Database Customers SOAP —

PowerDesigner WEBSERVICE_1 DISH Customers

♦ Database DISH web services with or without a prefix name areconsidered identically in PowerDesigner:

Software Web servicename

Type Web operationname

Database Customers DISH —

PowerDesigner Customers (withor without Dish-Prefix as prefix)

DISH —

303

Page 316: Physical Data Model - SAP
Page 317: Physical Data Model - SAP

CHAPTER 8

Working with PDMs

About this chapter This chapter describes how to work with Physical Data Models.

Contents Topic: page

Checking a PDM 306

Retrieving Multidimensional Objects 348

Rebuilding Cubes 350

Generating Extraction Scripts 353

Generating Cube Data 357

Migrating from Version 6 Data Warehouse 360

Using PowerBuilder Extended Attributes 364

305

Page 318: Physical Data Model - SAP

Checking a PDM

Checking a PDMThe Physical Data Model is a very flexible tool, which allows you quickly todevelop your model without constraints. You can, however, check thevalidity of your PDM at any time. A valid PDM conforms to the followingkinds of rules:

♦ Each object name must be unique

♦ Model constraints must be compatible with database constraints

♦ Each table must have at least one column

♦ Each index must have a column

♦ Each reference must have at least one column pair

Check your PDM before generating a databaseWe recommend that you check your PDM before generating a databasefrom it. If the check encounters errors, generation will be stopped. TheCheck model option is enabled by default in the Generation dialog box.

v To check a PDM

1. Press F4, or

2. Select Tools ä Check Model, or

3. Right-click the diagram background and select Check Model from thecontextual menu

The Check Model Parameters window opens, which allows you to specifythe kinds of checks to perform, and the objects to apply them to. For detailedinformation about this window and correcting problems reported, see“Checking a Model” in the “Managing Models” chapter of the GeneralFeatures Guide .

The following sections document the checks available by default for a PDM.

Horizontal partitioning checks

The following PDM model checks are made on horizontal partitioningobjects:

306

Page 319: Physical Data Model - SAP

Chapter 8. Working with PDMs

Check Description and Correction

Horizontal partitioning nameand code uniqueness

Horizontal partitioning names and codesmust be unique in the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Existence of partitions A horizontal partitioning object cannot beempty, it must contain at least one partition.

Manual correction: Delete the horizontalpartitioning object or create at least onepartition in the horizontal partitioning objectproperty sheet

Automatic correction: Deletes empty hori-zontal partitioning object

Unavailable target table A partition should have a correspondingtable. You could delete a table that actuallycorresponds to a partition, this check verifiesthat each partition has a corresponding table.

Manual correction: Delete the partition withno corresponding table

Automatic correction: Deletes the partitionwith no corresponding table

Table collapsing checks

The following PDM model checks are made on table collapsing:

Check Description and Correction

Table collapsing name andcode uniqueness

Table collapsing names and codes must beunique in the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

307

Page 320: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

Existence of target table A table collapsing must have a table as resultof the collapsing.

Manual correction: Delete the table collaps-ing object

Automatic correction: None

Unavailable target table The table resulting from the collapsingshould be available.

Manual correction: Delete the table collaps-ing object

Automatic correction: Deletes the tablecollapsing object

Vertical partitioning checks

The following PDM model checks are made on partitions:

Check Description and Correction

Vertical partitioning nameand code uniqueness

Vertical partitioning names and codes mustbe unique in the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Existence of partitions A vertical partitioning object cannot beempty, it must contain at least one partition.

Manual correction: Delete the vertical parti-tioning object or create at least one partitionin the vertical partitioning object propertysheet

Automatic correction: Deletes empty verticalpartitioning object

308

Page 321: Physical Data Model - SAP

Chapter 8. Working with PDMs

Check Description and Correction

Unavailable target table A partition should have a correspondingtable. You could delete a table that actuallycorresponds to a partition, this check verifiesthat each partition has a corresponding table.

Manual correction: Delete the partition withno corresponding table

Automatic correction: Deletes the partitionwith no corresponding table

Business Rule checks

The following PDM model checks are made on business rules:

Check Description and Correction

Business rule name and codeuniqueness

Business rule names and codes must beunique in the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Unused business rule The business rule you have created is notused in the model.

Manual correction: Apply the business ruleto an object in the model

Automatic correction: None

Package checks

The following PDM model checks are made on packages:

309

Page 322: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

Circular references A circular reference occurs when a tablerefers to another table, and so on until a loopis created between tables. A package cannotcontain circular references.

Manual correction: Resolve the circular ref-erence by correcting the reference, deletingits source, or clearing the Mandatory parentor Check on commit option

Automatic correction: None

Constraint name uniqueness A constraint name is a unique identifier forthe constraint definition of tables, columns,primary and foreign keys in the database.You define the constraint name in the follow-ing tabs:

Check tab of the table property sheet

Additional Check tab of the column propertysheet

General tab of the key property sheet

A constraint name must be unique in a model.

Manual correction: Modify the duplicatedconstraint name in the corresponding tab

Automatic correction: Modifies the dupli-cated constraint name of a selected object byappending a number to its current name

Constraint name maximumlength

The constraint name length cannot be longerthan the length specified in the DBMS defini-tion: either in the MaxConstLen entry, in theObject category, or in each object category.

Manual correction: Modify the constraintname to meet this requirement

Automatic correction: Truncates the con-straint name to the maximum length specifiedin the DBMS definition

310

Page 323: Physical Data Model - SAP

Chapter 8. Working with PDMs

Check Description and Correction

Circular dependencies Extended dependencies with the stereo-type <<DBCreateAfter>> can be usedbetween stored procedures to define a gen-eration order for stored procedures. Anextended dependency with the stereotype<<DBCreateAfter>> should not introducea circular dependency in the model.

Manual correction: Remove the<<DBCreateAfter>> extended depen-dency

Automatic correction: None

Shortcut code uniqueness Shortcuts codes must be unique in a names-pace.

Manual correction: Change the code of oneof the shortcuts

Automatic correction: None

User checks

The following PDM model checks are made on users:

Check Description and Correction

User name and code unique-ness

User names and codes must be unique in themodel.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

User code maximum length The user code length is limited by the maxi-mum length specified in the DBMS definition(MaxLen entry, in the Objects ä User cate-gory).

Manual correction: Modify the user codelength to meet this requirement

Automatic correction: Truncates the usercode length to the maximum length specifiedin the DBMS definition

311

Page 324: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

User password empty Users must have a password to be able toconnect to the database.

Manual correction: Define a password forthe user

Automatic correction: None

Group checks

The following PDM model checks are made on groups:

Check Description and Correction

Group name and codeuniqueness

Group names and codes must be unique inthe model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Group code maximum length The group code length is limited by the maxi-mum length specified in the DBMS definition(MaxLen entry, in the Objects ä Group cat-egory) or in the naming conventions of themodel options.

Manual correction: Modify the group codelength to meet this requirement

Automatic correction: Truncates the groupcode length to the maximum length specifiedin the DBMS definition

Existence of user A group is created to factorize privilegeand permission granting to users. A groupwithout user members is useless.

Manual correction: Add users to group ordelete group

Automatic correction: Deletes unassignedgroup

312

Page 325: Physical Data Model - SAP

Chapter 8. Working with PDMs

Check Description and Correction

Group password empty Groups must have a password to be able toconnect to the database (for those DBMS thatsupport passwords for groups.)

Manual correction: Define a password forthe group

Automatic correction: None

Role checks

The following PDM model checks are made on roles:

Check Description and Correction

Role name and code unique-ness

Role names and codes must be unique in themodel.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Role code length The role code length is limited by the maxi-mum length specified in the DBMS definition(MaxLen entry, in the Objects ä Role cat-egory) or in the naming conventions of themodel options.

Manual correction: Modify the role codelength to meet this requirement

Automatic correction: Truncates the rolecode length to the maximum length specifiedin the DBMS definition

Existence of user or role A role is used to create predefined profile thatcan be assigned to users or roles. A role thatis not assigned to any user or role is useless.

Manual correction: Assign role to users ordelete role

Automatic correction: Deletes unassignedrole

313

Page 326: Physical Data Model - SAP

Checking a PDM

Domain checks

The following PDM model checks are made on domains:

Check Description and Correction

Domain name and codeuniqueness

Domain names and codes must be unique inthe model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Domain code maximumlength

The domain code length is limited by themaximum length specified in the DBMSdefinition (MaxLen entry, in the Objects ä

Domain category) or in the naming conven-tions of the model options.

Manual correction: Modify the domain codelength to meet this requirement

Automatic correction: Truncates the domaincode length to the maximum length specifiedin the DBMS definition

Detect Inconsistencies be-tween check parameters

The values entered in the check parameterstab are inconsistent for numeric and stringdata types: default does not respect minimumand maximum values, or default does notbelong to list of values, or values in listare not included in minimum and maximumvalues, or minimum is greater than maximumvalue. Check parameters must be definedconsistently.

Manual correction: Modify default, mini-mum, maximum or list of values in the checkparameters tab

Automatic correction: None

Data type precision andlength

The data type precision should not be greaterthan the length.

Manual correction: Make the data typelength greater than the precision

Automatic correction: None

314

Page 327: Physical Data Model - SAP

Chapter 8. Working with PDMs

Check Description and Correction

Undefined data type A model should not contain domains withundefined data type, all domains should havea defined data type.

Manual correction: Select a data type fromthe domain property sheet

Automatic correction: None

Missing default object A domain cannot have a default value withoutbeing attached to a default object.

Manual correction: Create a default objectfor the domain or use the rebuild defaultfeature

Automatic correction: Creates a defaultobject for domain

Table checks

The following PDM model checks are made on tables:

Check Description and Correction

Table name and code unique-ness

Tables names and codes must be unique inthe model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Table name and code length The table name and code length is limitedby the maximum length specified in theDBMS definition (MaxLen entry, in theObjects ä Table category) and in the namingconventions of the model options.

Manual correction: Modify the name/codelength to meet this requirement

Automatic correction: Truncates thename/code length to the maximum lengthspecified in the DBMS definition

315

Page 328: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

Constraint name conflict withindex name

A constraint name of the table cannot be thesame as an index name.

Manual correction: Change the name of thetable constraint

Automatic correction: None

Existence of column, refer-ence, index, key

A table should contain at least one column,one index, one key, and one reference.

Manual correction: Add missing item to thedefinition of the table

Automatic correction: None

Number of auto-incrementedcolumns

Auto-incremented columns contain auto-matically calculated values. A table cannotcontain more than one auto-incrementedcolumn.

Manual correction: Delete all but one auto-incremented column

Automatic correction: None

Table index definitionuniqueness

Identical indexes are indexes with the samecolumns, order and type. A table cannot haveidentical indexes.

Manual correction: Delete index or changeits properties

Automatic correction: None

Table mapping not defined When a table belongs to a model contain-ing one or several data sources, it must bemapped to tables or views in the data sourcein order to establish a relational to relationalmapping.

Manual correction: Map the current table toone or several tables or views in the modelbelonging to the data source

Automatic correction: Destroys the mappingfor the table. This removes the data sourcefrom the Mapping list in the table Mappingtab

316

Page 329: Physical Data Model - SAP

Chapter 8. Working with PDMs

Check Description and Correction

Column mapping not defined When a column belong to a table in a modelcontaining one or several data sources, itshould be mapped to columns in the datasource in order to establish a relational torelational mapping.

Manual correction: Map the current columnto one or several columns in the modelsbelonging to the data source

Automatic correction: Destroys the mappingfor the column. This removes the columnsthat are not mapped to any object in theColumns Mapping tab of the table Mappingtab

Existence of permission Permissions are usage restrictions set on atable for a particular user, group or role.

Manual correction: Define permissions onthe table for users, groups and roles

Automatic correction: None

Column checks

The following PDM model checks are made on columns:

Check Description and Correction

Column name and codeuniqueness

Column names and codes must be unique ina table.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

317

Page 330: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

Column code maximumlength

The column code length is limited by themaximum length specified in the DBMSdefinition (MaxLen entry, in the Objects ä

Column category) or in the naming conven-tions of the model options.

Manual correction: Modify the column codelength to meet this requirement

Automatic correction: Truncates the codelength to the maximum length specified inthe DBMS definition

Domain divergence Divergence is verified between columns,domains, and data types. Various checks andattributes are also examined. One or moreof the Enforce non divergence model optionsmust be selected.

Manual correction: Select one or more ofthe Enforce non divergence model options toenforce non divergence

Automatic correction: Restores divergentattributes from domain to column (domainvalues overwrite column values)

Column mandatory In some DBMS, the columns included in akey or a unique index should be mandatory.

Manual correction: Select the Mandatorycheck box in the column property sheet

Automatic correction: Makes the columnmandatory

Inconsistency in check pa-rameters

The values entered in the check parameterstab are inconsistent for numeric and stringdata types: default does not respect minimumand maximum values, or default does notbelong to list of values, or values in listare not included in minimum and maximumvalues, or minimum is greater than maximumvalue. Check parameters must be definedconsistently.

Manual correction: Modify default, mini-mum, maximum or list of values in the checkparameters tab

Automatic correction: None

318

Page 331: Physical Data Model - SAP

Chapter 8. Working with PDMs

Check Description and Correction

Data type precision andlength

The data type precision should not be greaterthan the length. Note that some DBMSaccept a precision higher than the length.

Manual correction: Make the data typelength greater than the precision

Automatic correction: None

Undefined data type A model should not contain columns withundefined data type, all columns should havea defined data type.

Manual correction: Select a data type in thecolumn property sheet

Automatic correction: None

Foreign key column data typeand constraint parametersdivergence

Primary/alternate and foreign key columnsinvolved in a join should have consistent datatypes and constraint parameters.

Manual correction: Modify foreign key datatypes and constraint parameters to makethem consistent

Automatic correction: Parent column over-writes existing data type and constraintparameters in the foreign key column

Column with sequence not ina key

Since a sequence is used to initialize a key,it should be attached to a column that is partof a key. This applies to those DBMS thatsupport sequences.

Manual correction: Attach the sequence to acolumn that is part of a key

Automatic correction: None

Auto-incremented columnwith data type not numeric

An auto-incremented column must have anumeric data type.

Manual correction: Change the column datatype

Automatic correction: Changes data type tonumeric data type

319

Page 332: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

Auto-incremented column isforeign key

A foreign key column should not be auto-incremented.

Manual correction: Deselect the Indentitycheck box in the column property sheet

Automatic correction: None

Missing computed columnexpression

A computed column should have a computedexpression defined.

Manual correction: Add a computed expres-sion to the column in the Details tab of thecolumn property sheet

Automatic correction: None

Index checks

The following PDM model checks are made on indexes:

Check Description and Correction

Index name and code unique-ness

Depending on the DBMS, a model or a tablecannot contain two indexes with identicalname and/or code.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Index code maximum length The index code length is limited by themaximum length specified in the DBMSdefinition (MaxLen entry, in the Objects ä

Index category) or in the naming conventionsof the model options.

Manual correction: Modify the index codelength to meet this requirement

Automatic correction: Truncates the indexcode length to the maximum length specifiedin the DBMS definition

320

Page 333: Physical Data Model - SAP

Chapter 8. Working with PDMs

Check Description and Correction

Existence of index column An index must have at least one index col-umn.

Manual correction: Add an index columnfrom the Column tab of the index propertysheet or delete the index

Automatic correction: Deletes the indexwithout column

Undefined index type An index type must be specified.

Manual correction: Specify a type in theindex property sheet or delete the index withno type

Automatic correction: None

Index column count The current DBMS does not support morethan the number of index columns specifiedin the MaxColIndex entry of the currentDBMS.

Manual correction: Delete one or morecolumns in the index property sheet. You cancreate additional indexes for these columns

Automatic correction: None

Uniqueness forbidden forHNG index type

An index of HNG (HighNonGroup) typecannot be unique.

Manual correction: Change the index type orset the index as non unique

Automatic correction: None

Index inclusion An index should not include another index.

Manual correction: Delete the index thatincludes an existing index

Automatic correction: None

View index checks

The following PDM model checks are made on view indexes:

321

Page 334: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

Index name and code unique-ness

Depending on the DBMS, a model or aview cannot contain two view indexes withidentical name and/or code.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Index code length The view index code length is limited bythe maximum length specified in the DBMSdefinition (MaxLen entry, in the Objects ä

Index category) or in the naming conventionsof the model options.

Manual correction: Modify the view indexcode length to meet this requirement

Automatic correction: Truncates the viewindex code length to the maximum lengthspecified in the DBMS definition

Existence of index column A view index must have at least one indexcolumn.

Manual correction: Add an index columnfrom the Column tab of the view indexproperty sheet or delete the index

Automatic correction: Deletes the view indexwithout column

Index column count The current DBMS does not support morethan the number of index columns speci-fied in the MaxColIndex entry in the Indexcategory of the current DBMS.

Manual correction: Delete one or morecolumns in the view index property sheet.You can create additional view indexes forthese columns

Automatic correction: None

Index inclusion A view index should not include anotherindex.

Manual correction: Delete the view indexthat includes an existing index

Automatic correction: None

322

Page 335: Physical Data Model - SAP

Chapter 8. Working with PDMs

Key checks

The following PDM model checks are made on keys:

Check Description and Correction

Key name and code unique-ness

Key names and codes must be unique in themodel.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Key code length The key code length is limited by the maxi-mum length specified in the DBMS definition(MaxConstLen entry, in the Object ä Keycategory).

Manual correction: Modify the key codelength to meet this requirement

Automatic correction: Truncates the keycode length to the maximum length specifiedin the DBMS definition

Key column exists Each key must have at least one column.

Manual correction: Add a column to the keyfrom the Column tab of the key propertysheet

Automatic correction: Deletes key withoutcolumn

Key inclusion A key cannot include another key (on somecolumns, regardless of their order).

Manual correction: Delete the key thatincludes an existing key

Automatic correction: None

Multi-column key has se-quence column

Since the column initialized by a sequence isalready a key, it should not be included in amulti-column key.

Manual correction: Detach the sequencefrom a column that is already part of a multi-column key

Automatic correction: None

323

Page 336: Physical Data Model - SAP

Checking a PDM

Trigger checks

The following PDM model checks are made on triggers:

Check Description and Correction

Trigger name and codeuniqueness

Trigger names and codes must be unique inthe model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Trigger code length The trigger code length is limited by themaximum length specified in the DBMSdefinition (MaxLen entry, in the Objects ä

Trigger category).

Manual correction: Modify the trigger codelength to meet this requirement

Automatic correction: Truncates the triggercode length to the maximum length specifiedin the DBMS definition

Reference checks

The following PDM model checks are made on references:

Check Description and Correction

Reference name and codeuniqueness

Reference names and codes must be uniquein the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Reflexive mandatory refer-ence

A reflexive reference exists should not havea mandatory parent which could lead toinconsistent joins.

Manual correction: Correct the reference byclearing the Mandatory parent check box

Automatic correction: None

324

Page 337: Physical Data Model - SAP

Chapter 8. Working with PDMs

Check Description and Correction

Existence of reference join A reference must have at least one referencejoin.

Manual correction: Create a reference joinfor the reference or delete the reference

Automatic correction: Deletes referencewithout join

Reference code length The reference code length is limited by themaximum length specified in the DBMSdefinition (MaxConstLen entry, in the Objectä Reference category) or in the namingconventions of the model options.

Manual correction: Modify the referencecode length to meet this requirement

Automatic correction: Truncates the refer-ence code length to the maximum lengthspecified in the DBMS definition

Incomplete joins Joins must be complete.

Manual correction: Select a foreign keycolumn or activate the primary key columnmigration

Automatic correction: None

Join order The join order must be the same as the keycolumn order for some DBMS.

Manual correction: If required, change thejoin order to reflect the key column order

Automatic correction: The join order ischanged to match the key column order

During a reference check, the followingobject controls are made.

View reference checks

The following PDM model checks are made on view references:

325

Page 338: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

View reference name andcode uniqueness

View reference names and codes must beunique in the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Existence of view referencejoin

A view reference must have at least one viewreference join.

Manual correction: Create a view referencejoin for the view reference or delete thereference

Automatic correction: Deletes view refer-ence without join

View checks

The following PDM model checks are made on views:

Check Description and Correction

View name and code unique-ness

View names and codes must be unique in themodel.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

View code length The view code length is limited by themaximum length specified for the table codelength.

Manual correction: Modify the view codelength to meet this requirement

Automatic correction: Truncates the viewcode length to the maximum length specifiedin the DBMS definition

Existence of permission Permissions are usage restrictions set on aview for a particular user, group or role.

Manual correction: Define permissions onthe view for users, groups and roles

Automatic correction: None

326

Page 339: Physical Data Model - SAP

Chapter 8. Working with PDMs

Abstract data type checks

The following PDM model checks are made on abstract data types:

Check Description and Correction

Abstract data type name andcode uniqueness

Abstract data type names and codes must beunique in the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Instantiable object type If an abstract data type of type Object (orSQLJ Object) is instantiable (Abstract optionnot checked), then it must have attributes andno abstract procedure.

Manual correction: Define at least one at-tribute in the ADT Attributes tab and clearthe Abstract option in the procedures prop-erty sheet

Automatic correction: None

Abstract object type If an abstract data type of type Object (orSQLJ Object) is not instantiable (Abstractoption checked), then it must not have tablesbased on it.

Manual correction: Set the Based on propertyto <None> in the tables property sheet

Automatic correction: None

Abstract Data Type codemaximum length

The code of the ADT is longer than themaximum allowed by the DBMS.

Manual correction: Reduce the length of thecode

Automatic correction: Reduces the code to apermissible length

Abstract data type procedure checks

The following PDM model checks are made on abstract data type (ADT)procedures:

327

Page 340: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

Abstract data type procedurename and code uniqueness

Abstract data type procedure names andcodes must be unique in the abstract datatype.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Name conflict with attribute An abstract data type procedure cannot havethe same name as an attribute.

Manual correction: Change the name of theADT procedure

Automatic correction: None

Abstract data type proceduredefinition empty

An abstract data type procedure must have adefinition.

Manual correction: Create an ADT proce-dure definition in the Definition tab of theADT procedure property sheet

Automatic correction: None

Inconsistent return type If the abstract data type procedure is a func-tion, a map or an order, you should definea return data type for the function, map ororder.

Manual correction: Select a return data typein the Return data type list

Automatic correction: None

Abstract Data Type proce-dure code maximum length

The code of the ADT procedure is longerthan the maximum allowed by the DBMS.

Manual correction: Reduce the length of thecode

Automatic correction: Reduces the code to apermissible length

Synonym checks

The following PDM model checks are made on synonyms:

328

Page 341: Physical Data Model - SAP

Chapter 8. Working with PDMs

Check Description and Correction

Synonym name and codeuniqueness

Synonym names and codes must be uniquein the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Synonym name and codelength

The synonym name and code length is lim-ited by the maximum length specified inthe DBMS definition (MaxLen entry, in theObjects ä Synonym category) and in thenaming conventions of the model options.

Manual correction: Modify the name/codelength to meet this requirement

Automatic correction: Truncates thename/code length to the maximum lengthspecified in the DBMS definition

Existence of base object A synonym must correspond to a model ob-ject. By default, when you create synonymsfrom the List of Synonyms using the Add aRow tool, they are not attached to any baseobject.

Manual correction: Select a base object fromthe synonym property sheet

Automatic correction: Deletes the synonym

Database package checks

The following PDM model checks are made on database packages:

Check Description and Correction

Database package name andcode uniqueness

Database package names and codes must beunique in the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

329

Page 342: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

Database package name andcode length

The database package name and code lengthis limited by the maximum length specifiedin the DBMS definition (MaxLen entry, inthe Objects ä DB Package category) and inthe naming conventions of the model options.

Manual correction: Modify the name/codelength to meet this requirement

Automatic correction: Truncates thename/code length to the maximum lengthspecified in the DBMS definition

Existence of package proce-dure

A database package is an encapsulated col-lection of related procedures. It shouldcontain at least one procedure.

Manual correction: Create one or severalprocedures in the database package or useexisting stored procedures and duplicatethem in the database package

Automatic correction: None

Existence of package cursor This check is to suggest that a databasepackage can contain cursors to define a workarea and access its stored information.

Manual correction: Create one or severalcursors in the Cursors tab of the databasepackage property sheet

Automatic correction: None

Existence of package variable This check is to suggest that a databasepackage can contain variables to capture orprovide a value when one is needed.

Manual correction: Create one or severalvariables in the Variables tab of the databasepackage property sheet

Automatic correction: None

Existence of package type This check is to suggest that a databasepackage can contain user-defined data typescalled types.

Manual correction: Create one or severaltypes in the Types tab of the database packageproperty sheet

Automatic correction: None

330

Page 343: Physical Data Model - SAP

Chapter 8. Working with PDMs

Check Description and Correction

Existence of package excep-tion

This check is to suggest that a databasepackage can contain exceptions to handleinternal and user-defined error conditions.

Manual correction: Create one or severalexceptions in the Exceptions tab of thedatabase package property sheet

Automatic correction: None

Database package procedure checks

The following PDM model checks are made on package procedures:

Check Description and Correction

Package procedure name andcode uniqueness

Database package procedure names andcodes must be unique in the database pack-age.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Package procedure definitionempty

A package procedure must have a definition.

Manual correction: Create the package pro-cedure definition in the Definition tab of thepackage procedure property sheet

Automatic correction: None

Existence of parameter A package procedure must contain parame-ters for input and output values.

Manual correction: Create one or severalparameters in the Parameters tab of thepackage procedure property sheet

Automatic correction: None

Undefined return type If the package procedure is a function, youshould define a return data type for thefunction.

Manual correction: Select a return data typein the Return Data Type list

Automatic correction: None

331

Page 344: Physical Data Model - SAP

Checking a PDM

Database package cursor checks

The following PDM model checks are made on package cursors:

Check Description and Correction

Package cursor name andcode uniqueness

Database package cursor names and codesmust be unique in the database package.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Package cursor definitionempty

A package cursor must have a definition.

Manual correction: Create the cursor def-inition in the Definition tab of the cursorproperty sheet

Automatic correction: None

Undefined return type You should define a return data type for acursor.

Manual correction: Select a return data typein the cursor property sheet

Automatic correction: None

Existence of parameter A cursor must contain parameters for inputvalues.

Manual correction: Create one or severalparameters in the Parameters tab of thecursor property sheet

Automatic correction: None

Database package variable checks

The following PDM model checks are made on package variables:

332

Page 345: Physical Data Model - SAP

Chapter 8. Working with PDMs

Check Description and Correction

Package variable name andcode uniqueness

Variable names and codes must be unique inthe database package.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Undefined data type You should define a data type for a variable.

Manual correction: Select a data type in thevariable property sheet

Automatic correction: None

Database package type checks

The following PDM model checks are made on package types:

Check Description and Correction

Package type name and codeuniqueness

Package type names and codes must beunique in the database package.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Package type definitionempty

A package type must have a definition.

Manual correction: Create the type definitionin the Definition tab of the package typeproperty sheet

Automatic correction: None

Database package exception checks

The following PDM model checks are made on exceptions:

333

Page 346: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

Package exception name andcode uniqueness

Exception names and codes must be uniquein the database package.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Procedure checks

The following PDM model checks are made on procedures:

Check Description and Correction

Procedure name and codeuniqueness

Procedures names and codes must be uniquein the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Procedure code maximumlength

The procedure code length is limited by themaximum length specified in the DBMSdefinition (MaxLen entry, in the Objects ä

Procedure category).

Manual correction: Modify the procedurecode length to meet this requirement

Automatic correction: Truncates the pro-cedure code length to the maximum lengthspecified in the DBMS definition

Procedure definition bodyempty

A procedure definition should have a body tospecify its functionality.

Manual correction: Specify a procedure bodyfrom the Definition tab of the procedureproperty sheet

Automatic correction: None

Existence of permission Permissions are usage restrictions set on aprocedure for a particular user, group or role.

Manual correction: Define permissions onthe procedure for users, groups and roles

Automatic correction: None

334

Page 347: Physical Data Model - SAP

Chapter 8. Working with PDMs

Data source checks

The following PDM model checks are made on data sources:

Check Description and Correction

Data source name and codeuniqueness

Data source names and codes must be uniquein the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Existence of physical datamodel

A data source must contain at least onephysical data model in its definition.

Manual correction: Add a physical datamodel from the Models tab of the propertysheet of the data source

Automatic correction: Deletes data sourcewithout physical data model

Differing DBMS types The models in a data source should share thesame DBMS since they represent a singledatabase.

Manual correction: Delete models withdifferent DBMS or modify the DBMS ofmodels in the data source

Automatic correction: None

File object checks

The following PDM model checks are made on files:

335

Page 348: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

Embedded file name unique-ness

Embedded file names must be unique in themodel.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Existence of external filelocation

External file objects should have a validlocation path.

Manual correction: Define a valid pathlocation

Automatic correction: None

Cube checks

The following PDM model checks are made on cubes:

Check Description and Correction

Cube name and code unique-ness

Cubes names and codes must be unique inthe model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Existence of association A cube must have at least one associationwith a dimension.

Manual correction: Create an associationbetween the cube and a dimension

Automatic correction: None

Existence of fact A cube must be associated to a fact.

Manual correction: Click the Ellipsis buttonbeside the Fact box in the cube propertysheet, and select a fact from the List of Facts

Automatic correction: None

Duplicated association withthe same dimension

A cube cannot have more than one associa-tion with the same dimension.

Manual correction: Delete one of the associ-ations

Automatic correction: None

336

Page 349: Physical Data Model - SAP

Chapter 8. Working with PDMs

Fact checks

The following PDM model checks are made on facts:

Check Description and Correction

Fact name and code unique-ness

Fact names and codes must be unique in themodel.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Existence of measure A fact must have at least one measure.

Manual correction: Create a measure in theMeasures tab of the fact property sheet

Automatic correction: None

Fact mapping not defined A fact must be mapped to tables or views inan operational model in order to be populatedby data from this model.

Manual correction: Map the fact to tables orviews. You may need to create a data sourcebefore you can create the mapping

Automatic correction: Destroys the mappingfor the fact. This removes the data sourcefrom the Mapping list in the fact Mappingtab

Measure mapping not defined Fact measures must be mapped to columnsin the data source tables or views.

Manual correction: Map the fact measure tocolumns in the data source

Automatic correction: Destroys the mappingfor the measure. This removes the measuresthat are not mapped to any object in theMeasures Mapping tab of the fact Mappingtab

Fact measure checks

The following PDM model checks are made on fact measures:

337

Page 350: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

Fact measure name and codeuniqueness

Fact measure names and codes must beunique in the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Dimension checks

The following PDM model checks are made on dimensions:

Check Description and Correction

Dimension name and codeuniqueness

Dimension names and codes must be uniquein the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Existence of attribute A dimension must have at least one attribute.

Manual correction: Create an attribute inthe Attributes tab of the dimension propertysheet

Automatic correction: None

Existence of hierarchy A dimension must use at least one hierarchy.

Manual correction: Create a hierarchy in theHierarchies tab of the dimension propertysheet

Automatic correction: None

Duplicated hierarchies Dimensions should not have duplicated hier-archies, that is to say hierarchies organizingidentical attributes.

Manual correction: Remove one of theduplicated hierarchies

Automatic correction: None

338

Page 351: Physical Data Model - SAP

Chapter 8. Working with PDMs

Check Description and Correction

Dimension without a defaulthierarchy

A dimension should have a default hierarchy.

Manual correction: Select a hierarchy inthe Default Hierarchy list of the dimensionproperty sheet

Automatic correction: None

Dimension mapping not de-fined

A dimension should be mapped to tables orviews in an operational model in order to bepopulated by data from this model.

Manual correction: Map the dimension to atable or a view. You may need to create a datasource before you can create the mapping

Automatic correction: Destroys the map-ping for the dimension. This removes thedata source from the Mapping list in thedimension Mapping tab

Attribute mapping not de-fined

Attributes must be mapped to columns in thedata source tables or views.

Manual correction: Map the attributes tocolumns in the data source

Automatic correction: None

Incomplete dimension map-ping for multidimensionalgeneration

All attributes, detail attributes and hierarchiesof the dimension must be mapped to tablesand columns. You must map the dimensionobjects before generation.

Manual correction: Map dimension objectsto tables and columns

Automatic correction: None

Attribute checks

The following PDM model checks are made on attributes:

339

Page 352: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

Attribute name and codeuniqueness

Attribute names and codes must be unique inthe model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Dimension hierarchy checks

The following PDM model checks are made on dimension hierarchies:

Check Description and Correction

Dimension hierarchy nameand code uniqueness

Dimension hierarchy names and codes mustbe unique in the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Existence of attribute A dimension hierarchy must have at least oneattribute.

Manual correction: Add an attribute to thehierarchy from the Attributes tab of thehierarchy property sheet

Automatic correction: None

Association checks

The following PDM model checks are made on associations:

Check Description and Correction

Existence of hierarchy Association names and codes must be uniquein the model.

Manual correction: Select a hierarchy in theHierarchy list in the association propertysheet

Automatic correction: None

Join index checks

The following PDM model checks are made on join indexes and bitmap join

340

Page 353: Physical Data Model - SAP

Chapter 8. Working with PDMs

indexes:

Check Description and Correction

Join index name and codeuniqueness

Join index names and codes must be uniquein the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Existence of base table Join index must have a base table.

Manual correction: Select a base table in thejoin index property sheet

Automatic correction: None

Join Index tables owners The tables associated to a join index musthave the same owner.

Manual correction: Modify the join indexowner or the table owner

Automatic correction: None

Join index references con-nection

Join index references must be connected toselected table on a linear axis.

Manual correction: Delete or replace refer-ences in the join index

Automatic correction: None

Duplicated join indexes Join indexes cannot have the same set ofreferences.

Manual correction: Delete one of the dupli-cated join indexes

Automatic correction: None

Replication checks

The following PDM model checks are made on replications:

341

Page 354: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

Partial replication A replica object is partially synchronizedwith its replicated object.

Manual correction: Modify the list of repli-cated attributes from the replication propertysheet

Automatic correction: Enforces the repli-cation of desynchronized attributes of thereplica object in the replication propertysheet

Sequence checks

The following PDM model checks are made on sequences:

Check Description and Correction

Sequence name and codeuniqueness

Default names and codes must be unique inthe model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Sequence code maximumlength

The code of the sequence is longer than themaximum allowed by the DBMS.

Manual correction: Reduce the length of thecode

Automatic correction: Reduces the code to apermissible length

Default checks

The following PDM model checks are made on defaults:

Check Description and Correction

Default name and codeuniqueness

Default names and codes must be unique inthe model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

342

Page 355: Physical Data Model - SAP

Chapter 8. Working with PDMs

Check Description and Correction

Default code maximumlength

The default code length is limited by themaximum length specified in the DBMSdefinition (MaxLen entry, in the Objects ä

Default category).

Manual correction: Modify the default codelength to meet this requirement

Automatic correction: Truncates the defaultcode length to the maximum length specifiedin the DBMS definition

Default value empty You must type a value for the default, thisvalue is used during generation.

Manual correction: Type a value in the Valuebox of the default property sheet

Automatic correction: None

Several defaults with samevalue

A model should not contain several defaultswith identical value.

Manual correction: Modify default value ordelete defaults with identical value

Automatic correction: None

Storage checks

The following PDM model checks are made on storages:

Check Description and Correction

Storage name and codeuniqueness

Storage names and codes must be unique inthe model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Storage code maximumlength

The code of the storage is longer than themaximum allowed by the DBMS.

Manual correction: Reduce the length of thecode

Automatic correction: Reduces the code to apermissible length

343

Page 356: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

Storage not used The storage you have created is not used inthe model.

Manual correction: Delete the storage orapply the storage as a physical option to atable, an index, a key, a column, a tablespaceor a view (Options tab of the object propertysheet)

Automatic correction: None

Tablespace checks

The following PDM model checks are made on tablespaces:

Check Description and Correction

Tablespace name and codeuniqueness

Tablespace names and codes must be uniquein the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Tablespace code maximumlength

The code of the tablespace is longer than themaximum allowed by the DBMS.

Manual correction: Reduce the length of thecode

Automatic correction: Reduces the code to apermissible length

Tablespace not used The tablespace you have created is not usedin the model.

Manual correction: Delete the tablespace orapply the tablespace as a physical option toa table, an index, a key, a column, a storageor a view (Options tab of the object propertysheet)

Automatic correction: None

344

Page 357: Physical Data Model - SAP

Chapter 8. Working with PDMs

Extended object checks

The following PDM model checks are made on extended objects/linkscheck, the following object controls are made.

Check Description and Correction

Extended object/link nameand code uniqueness

Extended object/link names and codes mustbe unique in the namespace.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Web service checks

The following PDM model checks are made on Web services:

Check Description and Correction

Web service name and codeuniqueness

Web service names and codes must be uniquein the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Web service code maximumlength

The Web service code length is limited bythe maximum length specified in the DBMSdefinition (Maxlen entry, in the Objects ä

Web Service category).

Manual correction: Modify the Web servicecode length to meet this requirement

Automatic correction: Truncates the Webservice code length to the maximum lengthspecified in the DBMS definition

Web operation checks

The following PDM model checks are made on Web operations:

345

Page 358: Physical Data Model - SAP

Checking a PDM

Check Description and Correction

Web operation name andcode uniqueness

Web operation names and codes must beunique in the model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Web operation code maxi-mum length

The Web operation code length is limited bythe maximum length specified in the DBMSdefinition (Maxlen entry, in the Objects ä

Web Operation category).

Manual correction: Modify the Web opera-tion code length to meet this requirement

Automatic correction: Truncates the Weboperation code length to the maximum lengthspecified in the DBMS definition

Database checks

The following PDM model checks are made on databases:

Check Description and Correction

Database name and codeuniqueness

Database names and codes must be unique inthe model.

Manual correction: Modify the duplicatename/code

Automatic correction: Appends a number tothe duplicate name/code

Unused database The database you have created is not used inthe model.

Manual correction: Delete the database orapply the database as a physical option to atable, an index, a key, a column, a storage,a tablespace or a view (Options tab of theobject property sheet)

Automatic correction: None

346

Page 359: Physical Data Model - SAP

Chapter 8. Working with PDMs

Check Description and Correction

Database code maximumlength

The code of the database is longer than themaximum allowed by the DBMS.

Manual correction: Reduce the length of thecode

Automatic correction: Reduces the code to apermissible length

347

Page 360: Physical Data Model - SAP

Retrieving Multidimensional Objects

Retrieving Multidimensional ObjectsYou will need to identify fact and dimension tables and views during thedesign of a data warehouse. Tables and views support multidimensionaltypes, in this section both are referred to as fact and dimension tables.

A fact table stores variable numerical values related to aspects of a business.For example, sales, revenue, budget. These are usually the values you wantto obtain when you carry out a decision support investigation.

A dimension table stores data related to the axis of investigation of a fact.For example, geography, time, product. A dimension table should beconnected to a central fact table.

You can use the retrieve multidimensional objects feature to highlight thefact and dimension tables in a physical diagram. The RetrieveMultidimensional Object feature analyzes the references between the tablesin order to deduce the table type:

♦ Child tables or views become Fact tables or views

♦ Parent tables or views along the path to the child table or view becomeDimension tables or views

The new table type is indicated in the Type dropdown list box in the tableproperty sheet. A type icon is also displayed in the upper left corner of thetable symbol:

Fact table Dimension table

v To retrieve multidimensional objects

1. Select Tools ä Multidimension ä Retrieve Multidimensional Objects.

A selection box is displayed.

2. Select retrieve options in the General tab.

3. Select the tables that will be transformed in the Selection tab.

348

Page 361: Physical Data Model - SAP

Chapter 8. Working with PDMs

If you are using Sybase AS IQ (version 12.0)If your current DBMS is Sybase AS IQ (version 12.0), an additionalcheck box is displayed. The option allows you to automatically rebuildjoin indexes after retrieving multidimensional objects. For more infor-mation about rebuilding join indexes, see the section “Rebuilding JoinIndexes” in section Support for Sybase Adaptive Server IQ in chapterDBMS Specific Features.

4. Click OK.

The selected tables are assigned a multidimensional type.

349

Page 362: Physical Data Model - SAP

Rebuilding Cubes

Rebuilding CubesThe Rebuild Cubes feature allows you to create cubes and dimensions fromfact and dimension tables and views. Tables and views supportmultidimensional types, in this section both are referred to as fact anddimension tables

Once the fact and dimension tables of the data warehouse schema aredesigned, you can use this information to build the multidimensional cubes.The Rebuild Cubes feature allows the switch to the multidimensionalenvironment by transforming fact tables or views into cubes, and dimensiontables or views into dimensions. You can then design the cubes taking intoaccount the different analysis axis of the dimensions. These cubes will serveto generate the text files used to create and populate the OLAP engine.

The Rebuild Cubes feature works only if the tables have a multidimensionaltype (Fact or Dimension). If the tables have no type, an error message isdisplayed.

You define the type of a table or view using the following methods:

♦ Using the Dimensional Type list from the object property sheet

+ For more information about using the table property sheet, see the“Defining tables” section in the “Building Physical Diagrams” chapter.

♦ Using the retrieve multidimensional objects feature

+ For more information about retrieving multidimensional objects, seesection “Retrieving Multidimensional Objects” on page 348.

Object transformation The rebuild cubes operation creates multidimensional objects in amultidimensional diagram. If there is no multidimensional diagram in themodel when you start the rebuild cubes, it will be created. Otherwise thesymbols appear in the active multidimensional diagram or the firstmultidimensional diagram created in the model.

The rebuild cubes functionality modifies objects according to the followingrule:

Physical object After rebuild cubes, creates

Fact table One fact with the same name as the fact table

+

One Cube

Column in a Facttable (except foreignkeys)

Measure

350

Page 363: Physical Data Model - SAP

Chapter 8. Working with PDMs

Physical object After rebuild cubes, creates

Dimensions tablesattached to the facttable

One dimension, the name of the dimension corre-sponds to the concatenation of the dimension tablesalong the path to the child table, from the furthest tothe closest

+

One hierarchy that becomes the default hierarchy.This hierarchy contains the attributes correspondingto the primary key columns of the tables convertedinto a dimension

Column in a Dimen-sion table (exceptforeign keys)

One attribute, the name of the attribute is the concate-nation of the dimension table name and column nameif column names are ambiguous. Otherwise the nameis identical to the name of the column.

References betweena fact and a dimen-sion table

One cube dimension association

The Cube Rebuild dialog box allows you to select among the followingrebuild modes:

Rebuild mode Impact

Delete and Re-build

All objects previously rebuilt are deleted when you startthe current cube rebuild

Preserve Objects previously rebuilt are preserved during currentcube rebuild

351

Page 364: Physical Data Model - SAP

Rebuilding Cubes

v To start the cube rebuild

1. Select Tools ä Multidimension ä Rebuild Cubes.

The Cube Rebuild dialog box is displayed.

2. Select the rebuild mode in the General tab.

3. Select the fact tables that will be transformed in the Selection tab.

4. Click OK.

A message in the Output window informs you that the rebuild issuccessful. The cube and dimension are created and displayed in amultidimensional diagram. You can double-click the diagram node in theBrowser to display the symbols of the multidimensional objects.

352

Page 365: Physical Data Model - SAP

Chapter 8. Working with PDMs

Generating Extraction ScriptsThe Generate Extraction Script feature allows you to generate script filesthat will be used to fill and update tables in a data warehouse or data martdatabase.

The link between the operational database and the data warehouse or datamart database is a relational to relational mapping.

+ For more information about relational to relational mapping, see the“Relational to relational mapping” section in the “Using Mappings” chapterin the General Features Guide”.

You can generate a script file for each data source, you can also select thetables in the data source which select orders will be generated in the scriptfile. The extraction scripts list all the select orders defined in the tablemappings.

353

Page 366: Physical Data Model - SAP

Generating Extraction Scripts

v To generate an extraction script

1. In the Physical Diagram, select Database ä Generate Extraction Script toopen the Extraction Script Generation dialog box.

2. Specify a destination directory for the generated file, and select the CheckModel check box if you want to verify the PDM syntax before generation.The name of the script is identical to the name of the data source.

3. [optional] Click the Options tab and specify any appropriate options. Formore information, see ““Extraction Script Generation Options tab” onpage 354”.

4. [optional] Click the Selection tab, and select the tables that you want touse in the script generation. For more information, see ““ExtractionScript Generation Selection tab” on page 355”.

5. Click OK to generate the script files in the specified directory.

Extraction Script Generation Options tab

The Options tab allows you to specify the format for the script.

354

Page 367: Physical Data Model - SAP

Chapter 8. Working with PDMs

The following options are available:

Option Description

Title Inserts the database header and the name of the tablesbefore each select query.

Encoding Encoding format to use for generation. You shouldselect the encoding format that supports the languageused in your model and the database encoding format.

Character Case Defines the character case in the generated text file.

No Accent When selected, disallows the use of accents.

Extraction Script Generation Selection tab

The Selection tab allows you to specify the tables to be included in the script.

355

Page 368: Physical Data Model - SAP

Generating Extraction Scripts

+ For more information about selection windows, see the “Adding an itemfrom a selection list” section in the Using the PowerDesigner Interfacechapter in the General Features Guide.

356

Page 369: Physical Data Model - SAP

Chapter 8. Working with PDMs

Generating Cube DataThe cube data generation feature allows the generation of a text file that willbe used by an OLAP tool to create and populate cubes using data fromoperational sources.

Defining the query of a cube

Cubes in an OLAP database have to be filled with data from a datawarehouse, data mart or operational database.

You use text files to load data in the cubes of the OLAP database. The textfiles contain records and fields. A record is a row of fields that is read as aunit, and a field is a vertical list of values.

In the multidimensional diagram, each cube is associated with a query.There is actually one cube per mapping and per data source. The querydefined on a cube is used to extract data from a data warehouse oroperational database to populate the cubes in the OLAP database. The linkbetween the data warehouse database and the OLAP database is a relationalto multidimensional mapping.

+ For more information about relational to multidimensional mapping, seethe “Relational to multidimensional mapping” section in the “UsingMappings” chapter in the General Features Guide ”.

The Generate Cube Data feature allows the generation of a text filecontaining the cube data. This text file will then be loaded to populate the

357

Page 370: Physical Data Model - SAP

Generating Cube Data

cubes in the OLAP engine.

Generating a text file

The Generate Cube Data feature allows you to generate one text file for eachselected cube and each selected data source. The name of the generated fileis a concatenation of the name of the cube and the name of the data source.

Each file contains the following fields:

Field Details

Dimension Lists the attributes of the cube

Member Lists the attribute values

Data fields Contains the values stored in the fact measures

The generated text file must be easily loaded in the OLAP database. You cancustomize the format of the generated text files from the Generate Cube Datadialog box.

Generation op-tion

Description

Header When selected, includes the name of the attribute at thebeginning of the generated text file

Extension Extension of the generated text file, you can choosebetween .txt and .csv

Separator Separator used between columns

Delimiter String delimiter

Encoding Encoding format to use for generation. You should selectthe encoding format that supports the language used inyour model and the database encoding format

Character Case Defines the character case in the generated text file

No Accent When selected, disallows the use of accents

358

Page 371: Physical Data Model - SAP

Chapter 8. Working with PDMs

v To generate cube data

1. In the multidimensional diagram, select Tools ä Generate Cube Data.

The Generate Cube Data dialog box is displayed.

2. Define a destination directory for the generated file in the Directory box.

3. Select the generation options in the Options tab.

4. Select the cubes and data sources for which you want to generate a filefrom the different tabbed tabs in the Selection tab.

5. Click OK.

The generated files are stored in the destination directory you havedefined.

359

Page 372: Physical Data Model - SAP

Migrating from Version 6 Data Warehouse

Migrating from Version 6 Data WarehouseYou can import a data warehouse model from version 6 into a PDM in thecurrent version of PowerDesigner.

Comparing version features

The warehouse features in the current version of PowerDesigner differ fromversion 6:

Version 6 Current version

Warehouse model Physical Data Model with data ware-house extension

Multidimensional hierarchies Multidimensional hierarchies are con-verted into simplified hierarchies asso-ciated with cubes in a multidimensionaldiagram

Extraction script generation Extraction script generation

Cube generation Cube data generation

OLAP interface —

Partitioning and aggregation wiz-ard

Converting objects from version 6

When you import a data warehouse model with external sources fromPowerDesigner version 6, the links to external sources are preserved: eachexternal database is converted into a new PDM in the current workspace.This new PDM is automatically declared as a data source for the importedmodel. Tables and columns in the imported model are automatically mappedto tables and columns in the data source model.

The modeling elements and their relationships are slightly different betweenprevious and current version of PowerDesigner. When you open a version 6data warehouse model into the current version of PowerDesigner, thefollowing object translations are performed:

360

Page 373: Physical Data Model - SAP

Chapter 8. Working with PDMs

Object in version6

Object in currentversion

Details

Fact table withoutfact hierarchy

Fact A fact is created for each fact table

Fact table withfact hierarchy

Fact and cube A fact and a cube are created foreach fact table having a fact hier-archy. The fact is automaticallyassociated with the cube

Dimension table Dimension Each dimension table directlyattached to a fact is converted intoa new dimension containing allthe attributes of the dimension

Attribute Attribute attribute

Metric Measure A measure is created for eachmetric in the origin model

Dimension hierar-chy

Dimension Hierarchies are created in thedimension based on the multidi-mensional hierarchy

Hierarchies anddimensions

Each dimension hierarchy is converted into a single dimension.

The dimensions inside the dimension hierarchy are merged into a newdimension. The attributes of these child dimensions become attributes of thenew dimension, and, if necessary, their names are prefixed by the name ofthe new parent dimension.

The conversion process also creates a new hierarchy with the same attributesas the child dimensions copied into the new dimension.

Version 6 Current version

Associations In the dimension hierarchy, an association is created for each dimension andeach dimension hierarchy linked to a fact.

361

Page 374: Physical Data Model - SAP

Migrating from Version 6 Data Warehouse

Version 6 Current version

Converting external sources

When you open a version 6 data warehouse model into the current version ofPowerDesigner, the links to external sources are preserved thanks to amapping mechanism.

+ For more information about object mapping, see the “Definingmappings in a Physical Data Model” section in the General Features Guide .

Version 6 Current version Details

External database Physical Data Modelopened in the currentworkspace

Each external databasebecomes a new PDM withthe same name and thesame DBMS family. Amessage is displayed if theDBMS cannot be found

External table Table in the new PhysicalData Model opened inthe current workspace

The external tables in theexternal database becomeregular tables in the newPDM. A shortcut is createdfor each external table in theimported model to illustratethe mapping

External column Column in the tables ofthe new Physical DataModel opened in thecurrent workspace

The external columns be-come columns in the tablesof the new PDM

The concept of external database in PowerDesigner version 6 becomes adata source: when you import a data warehouse model with one or severalexternal databases, the model is imported and the external databases areconverted into physical models. These models are automatically declared asdata sources of the imported model, and the tables of the model are mapped

362

Page 375: Physical Data Model - SAP

Chapter 8. Working with PDMs

with tables in the data source. Shortcuts of the mapped tables appear in theimported model diagram.

+ For more information about data sources, see the “Defining data sourcesin a model” section in the General Features Guide .

363

Page 376: Physical Data Model - SAP

Using PowerBuilder Extended Attributes

Using PowerBuilder Extended AttributesWhen designing tables to be used in a PowerBuilder DataWindow,PowerDesigner lets you manage the extended attributes which PowerBuilderuses to store application-based information such as label and heading textfor columns, validation rules, display formats, and edit styles.

Importing the PowerBuilder extended model definition

In order to use the PowerBuilder extended attributes, you must first importthe PowerBuilder extended model definition into the current physical datamodel. You can then view and modify the extended attribute values throughthe extended attributes tab in a table or column property sheet.

+ For more information about extended model definitions, see the“Extended Model Definitions Reference Guide” chapter in the AdvancedUser Documentation .

Supported system tables PowerDesigner supports two PowerBuilder system tables: PBCatTbl fortables and PBCatCol for columns. Note that for both tables, PowerDesignerdoes not support all columns. You can view the supported columns bydisplaying the extended attributes tab of a table or a column in a modelwhere you have attached the PowerBuilder extended model definition.

The list of extended attributes corresponds to the supported columns intables PBCatTbl and PBCatCol.

364

Page 377: Physical Data Model - SAP

Chapter 8. Working with PDMs

v To import the PowerBuilder extended model definition

1. Create a new PDM.

2. Select Model ä Extended Model Definition to display the List ofExtended Model Definitions.

3. Click the Import an Extended Model Definition tool.

The Extended Model Definition Selection dialog box is displayed.

4. Select PowerBuilder.

orClick the Path tool to browse to the extended model definitions directory.

5. Select the Share or Copy radio button.

6. Click OK

The extended model definition is displayed in the list.

7. Double-click the PowerBuilder extended model definition to display itsproperties in the resource editor.

You can expand the Extended Attributes sub-category in the differentmetaclass categories under Profile to display the extended attributes.

365

Page 378: Physical Data Model - SAP

Using PowerBuilder Extended Attributes

Importing models with PowerBuilder extended attributes from a previousversion

When importing a previous version model containing PowerBuilderextended attributes, PowerDesigner detects these extended attributes andautomatically attaches the PowerBuilder extended model definition to themodel.

The PowerBuilder extended model definition contains only thePowerBuilder extended attributes supported in the current version ofPowerDesigner. If the imported model contains PowerBuilder extendedattributes other than those in the PowerBuilder extended model definition,they are lost when the model is imported.

The values of PowerBuilder extended attributes are imported with the model.

You can also import the extended attributes contained in a .EXA file.

For more information about how to import .EXA files, see the “Importingthe extended attributes from a .EXA file” section in the “Extended ModelDefinitions Reference Guide” chapter in the Advanced User Documentation.

v To import a model with PowerBuilder extended attributes from aprevious version

1. Open a model saved with a previous version of PowerDesigner.

2. Select Model ä Extended Model Definitions.

366

Page 379: Physical Data Model - SAP

Chapter 8. Working with PDMs

The list displays the PowerBuilder extended model definition.

Modifying the value of a PowerBuilder extended attribute

You can use the PowerDesigner interface to modify the values ofPowerBuilder extended attributes.

v To modify the value of a PowerBuilder extended attribute

1. Display a table or column property sheet.

2. Click the Extended Attributes tab.

3. Select an extended attribute in the list and modify its value in the Valuecolumn using the down arrow or the Ellipsis button.

367

Page 380: Physical Data Model - SAP

Using PowerBuilder Extended Attributes

4. Click OK.

Generating PowerBuilder extended attributes

You can update the PowerBuilder extended attribute system tables byperforming a PowerBuilder extended attribute generation.

During generation, certain extended attributes may contain variables in theirvalues, which are translated during generation, for example to access objectproperties. The following object properties are translated during generation:

Object Property

Table Comment

Column Comment

Label

Header

Initial value

This automated process uses the PowerDesigner generation templatelanguage (GTL).

368

Page 381: Physical Data Model - SAP

Chapter 8. Working with PDMs

+ For more information about the PowerDesigner template language, seethe “Generation Reference Guide” chapter in the Advanced UserDocumentation .

v To generate PowerBuilder extended attributes

1. Select Tools ä PowerBuilder ä Generate Extended Attributes to open thePowerBuilder Extended Attributes Generation dialog box.

2. Click the Connect to a Data Source tool to open the Connect to a DataSource window.

3. Select a machine or file data source and click Connect.

The selected data source is displayed in the Data Source box in the upperpart of the PowerBuilder Extended Attributes Generation dialog box.

4. Select the tables you want to generate.

5. Click OK to start generation.

The Output window displays the generation messages.

Reverse engineering PowerBuilder extended attributes

The reverse engineering feature reads the PowerBuilder extended attributescontained in a database and writes them into the appropriate tables andcolumns in a PDM.

During reverse engineering, certain reversed extended attributes arecompared with the translated default values in the PowerBuilder extendedmodel definition. It these attributes match, the reversed value is replaced bythe default value from the extended model definition.

+ For more information about objects translated during reverseengineering, see section “Generating PowerBuilder extended attributes” onpage 368.

This automated process uses the PowerDesigner generation templatelanguage (GTL).

+ For more information about the PowerDesigner template language, seethe “Generation Reference Guide” chapter in the Advanced UserDocumentation .

369

Page 382: Physical Data Model - SAP

Using PowerBuilder Extended Attributes

v To reverse engineer PowerBuilder extended attributes

1. Select Tools ä PowerBuilder ä Reverse Extended Attributes.

The PowerBuilder Extended Attributes Reverse Engineering dialog boxis displayed.

2. Click the Connect to a Data Source tool to open the Connect to a DataSource dialog box.

3. Select a machine or file data source and click Connect.

The selected data source is displayed in the Data Source box in the upperpart of the PowerBuilder Extended Attributes Reverse Engineering dialogbox.

4. Select the tables you want to reverse engineer.

5. Click OK to start reverse engineering.

The Output window displays the reverse engineering messages.

370

Page 383: Physical Data Model - SAP

CHAPTER 9

Denormalizing a PDM

About this chapter This chapter describes the different methods for denormalizing a PhysicalData Model.

Contents Topic: page

Overview 372

Horizontal partitioning 373

Vertical partitioning 380

Table collapsing 388

Column denormalization 393

371

Page 384: Physical Data Model - SAP

Overview

OverviewUsually normalization consists in eliminating redundancy and inconsistentdependencies between tables in order to create a functional and efficientrelational database.

Denormalization is the process of putting one fact in numerous places, inorder to speed data retrieval. The only valid reason for denormalizing arelational design is to enhance performance. However, there are severalindicators which will help to identify systems and tables which are potentialdenormalization candidates. These are:

♦ Critical queries rely upon data from more than one table

♦ Many calculations need to be applied to one or many columns beforequeries can be successfully answered

♦ Tables need to be accessed in different ways by different users during thesame timeframe

♦ Certain columns are queried a large percentage of the time

When deciding whether to denormalize, you need to analyze the data accessrequirements of the applications in your environment and their actualperformance characteristics. Often, good indexing and other solutions solvemany performance problems rather than denormalization.

Denormalization may be accomplished in several ways:

♦ Horizontal partitioning is used to divide a table into multiple tablescontaining the same columns but fewer rows

♦ Vertical partitioning is used to divide a table into multiple tablescontaining the same number of rows but fewer columns

♦ Table collapsing is used to merge tables in order to eliminate the joinbetween them

♦ Column denormalization is used to repeat a column in tables in order toavoid creating a join between tables

♦ The following sections explain these different denormalizationtechniques.

372

Page 385: Physical Data Model - SAP

Chapter 9. Denormalizing a PDM

Horizontal partitioningHorizontal partitioning consists in segmenting a table into multiple tableseach containing a subset of rows and the same columns as the partitionedtable.

Horizontal partitioning optimizes data retrieval by dividing rows of a table.

Example The table Annual_Sales contains the following columns:

This table is likely to contain a very large amount of data. You can use theHorizontal Partitioning Wizard to optimize data retrieval by creatingpartitions corresponding to sales per year. You can use any column, evenprimary keys, as partitioning criteria.

The result is the following:

Pros and cons Horizontal partitioning allows you to divide a large table into smaller tablesin order to:

♦ Improve the query response time

♦ Accelerate incremental data backup and recovery

♦ Decrease time required to load into indexed tables

However, horizontal partitioning also implies to:

♦ Create joins and unions to retrieve related data from multiple tables

♦ Create more intelligent queries to determine which table contains therequested data

♦ Use additional metadata to describe the partitioned table

Using the Horizontal Partitioning Wizard

The Horizontal Partitioning Wizard lets you generate multiple tables from aselected table. The generated tables correspond to partitions of a table; they

373

Page 386: Physical Data Model - SAP

Horizontal partitioning

contain the same columns as the partitioned table apart from those columnsused as partitioning criterion.

You can keep or delete the original table used for the partitioning.

The Horizontal Partitioning Wizard is accessible from the Tools menu or thecontextual menu of a table. The wizard lets you define the followingparameters:

Wizard page Description

Partitioned Table Selec-tion

Lets you select the table to partition in anypackage of the current model. If a table isselected in the diagram, it is displayed in thePartitioned Table box. If you select the Keep thePartitioned Table After the Partitioning checkbox, you preserve the original table used for thetransformation

Partition Definition Lets you define the partitions of the selectedtable. You can use the Insert or Add a row toolsto create as many partitions as needed. Thename of each partition is unique in the model.A table will be created for each partition usingthe partition name

Discriminant Column Se-lection

Lets you define the columns that will not beduplicated in each partition. Such columns arepartition criteria. You can use the Add Columnstool to select the columns not to duplicate

Partitioning Information Lets you enter a name and a code for the trans-formation object that will be created togetherwith the partitions. In this documentation, weshall call this object horizontal partitioningobject

v To use the Horizontal Partitioning Wizard

1. Select Tools ä Denormalization ä Horizontal Partitioning.

or

Right-click a table in the diagram and select Horizontal Partitioning fromthe contextual menu.

The Horizontal Partitioning Wizard is displayed.

374

Page 387: Physical Data Model - SAP

Chapter 9. Denormalizing a PDM

2. Select a partitioned table.

3. <optional> Select Keep the Partitioned Table After the Partitioningcheck box.

4. Click Next.

5. Define the partitions to generate and click Next.

6. Define the partition criteria and click Next.

7. Define the name and code of the horizontal partitioning object and clickFinish.

After the creation of the partitions and their corresponding tables, allreferences incoming or outgoing the partitioned table are also created oneach partition table.

A horizontal partitioning object is created each time you perform ahorizontal partitioning on a table.

Using the horizontal partitioning object

The horizontal partitioning object is automatically created when you definetable partitions, this object belongs to the category of transformation objectsthat is displayed in the List of Transformations, available from the menucommand Model ä Transformations.

The horizontal partitioning object has the following properties:

375

Page 388: Physical Data Model - SAP

Horizontal partitioning

Property Description

Name Name of the horizontal partitioning object. It is rec-ommended to provide a clear name in the HorizontalPartitioning Wizard

Code Code of the horizontal partitioning object

Comment Additional information about the horizontal partitioningobject. The comment box is also used to display the

Partitioned table Name of the table used to create the table partitions. Thistable no longer exists in the model

DiscriminantColumns

Name and code of the columns used as partition criteria

The Partitions page in the horizontal partitioning object property sheetdisplays the list of partitions created during horizontal partitioning. You canmanage partitions from this list.

+ For more information on how to manage partitions, see section“Managing horizontal partitions” on page 376.

Delete a horizontal partitioning object

You can use the List of Transformations to delete a horizontal partitioningobject using the Delete tool in the list toolbar. Delete removes the horizontalpartitioning object and the partitions, but does not delete the tablescorresponding to the partitions. The tables become independent from eachother.

Cancel a horizontal partitioning transformation

You can use the List of Transformations to cancel a transformation using theCancel Transformation tool in the list toolbar. When you cancel atransformation, you delete the horizontal partitioning object, the partitions,and their corresponding tables from the model.

Cancel can be used to recover the original table of the partitioning.

+ For more information on recovering the original table of thepartitioning, see section “Revert a horizontal partitioning” on page 378.

Managing horizontal partitions

You can manage partitions from the Partitions page of the property sheet of ahorizontal partitioning object. The following actions can be performed:

376

Page 389: Physical Data Model - SAP

Chapter 9. Denormalizing a PDM

♦ Open the property sheets of the tables corresponding to the partitions.You can modify the properties of the table from the property sheet. If youmodify the name or the code of the table, the name or code of thecorresponding partition is automatically updated

♦ Add more partitions and define the properties of their correspondingtables

♦ Use the Comment column to comment and specify the discriminatingcriteria of the different partitions

♦ Delete one or several partitions and their corresponding tables. When youdelete a partition, a message box is displayed to ask you if you want todelete the corresponding table. You can delete a partition and keep thecorresponding table, however you cannot delete a table and keep anorphan partition

You cannot move or paste a horizontal partitioning object into another modelor package.

Intermodel generation of horizontal partitions

When you generate in update mode a PDM from a PDM, a CDM or anOOM, horizontal partitioning is preserved.

For example, model Sales.CDM contains entity Customer:

Sales.CDM is generated in SALES.PDM, entity Customer becomes tableCustomer:

You decide to create partitions for this table using the City criterion, you usehorizontal partitioning to create table partitions from which you remove thecity column:

377

Page 390: Physical Data Model - SAP

Horizontal partitioning

You modify the CDM and regenerate the PDM in update mode. Thepartitions are taken into account in the merge dialog box as you can see inthe merge dialog box: CDM changes (creation of the Activity attribute) areselected by default, and column modifications related to partition creationare not selected.

Revert a horizontal partitioning

The revert feature is used to recover the original table used for partitioning.This procedure does not apply if you have kept the original table.

Revert is not a single-click operation, you have to perform several actions asdescribed in the procedure below. Revert is only accessible if the partitionedtable is a generated object proceeding from a PDM, CDM, or OOMgeneration into a PDM, otherwise you will not be able to recover thepartitioned table.

378

Page 391: Physical Data Model - SAP

Chapter 9. Denormalizing a PDM

v To revert a horizontal partitioning

1. Select a horizontal partitioning object in the List of Transformations.

2. Click the Cancel Transformation tool in the list toolbar in order to initiatethe revert process.

Cancel Transformation toolThe Cancel Transformations tool is disabled if the table is not a gener-ated object

The horizontal partitioning object is removed from the list.

3. Click OK.

The horizontal partitions and their corresponding tables are deleted fromthe PDM.

4. Regenerate the PDM in update mode.

Since the transformation object is no longer in the model, the mergedialog box lets you recreate the original table used for the partitioning.You have reverted the horizontal partitioning.

379

Page 392: Physical Data Model - SAP

Vertical partitioning

Vertical partitioningVertical partitioning consists in segmenting a table into multiple tables eachcontaining a subset of columns and the same number of rows as thepartitioned table. The partition tables share the same primary key.

Example The table Customer contains the following columns:

This table can be divided in two tables corresponding to different aspects ofthe table. You can use the Vertical Partitioning Wizard to split the table asfollows:

Pros and cons Vertical partitioning allows queries to scan less data thus improves the queryresponse time. It also allows you to split data requiring different levels ofprotection, you can store confidential information in a special partition.

However, vertical partitioning also implies to:

♦ Create joins and unions to retrieve related data from multiple tables

♦ Create more intelligent queries to determine which table contains therequested data

♦ Additional metadata to describe the partitioned table

Using the Vertical Partitioning Wizard

The Vertical Partitioning Wizard lets you generate multiple tables from aselected table. The generated tables correspond to partitions of a table.

The key columns of the partitioned table are duplicated whereas the othercolumns are distributed among the partition tables. PowerDesigner verifiesthat all the columns of the partitioned table are used in the partition tables.

380

Page 393: Physical Data Model - SAP

Chapter 9. Denormalizing a PDM

You can keep the original table used for the partitioning.

The Vertical Partitioning Wizard is accessible from the Tools menu or thecontextual menu of a table. The wizard lets you define the followingparameters:

Wizard page Description

Partitioned Table Selection Lets you select the table to partition in anypackage of the current model. If a table isselected in the diagram, it is displayed in thePartitioned Table box. If you select the Keepthe Partitioned Table After the Partitioningcheck box, you preserve the original table usedfor the transformation

Partition Definition Lets you define the partitions of the selectedtable. You can use the Insert or Add a row toolsto create as many partitions as needed. Thename of each partition is unique in the model.A table will be created for each partition usingthe partition name

Partition Column Selection Lets you define the columns to include in eachpartition table. You can use the Add buttonto add columns from the partitioned table tothe partition tables. The key columns do notappear in the list because they are duplicatedin each partition table. Include each column ina partition and click Next

Partitioning Information Lets you enter a name and a code for the trans-formation object that will be created togetherwith the partitions. In this documentation, weshall call this object vertical partitioning object

381

Page 394: Physical Data Model - SAP

Vertical partitioning

v To use the Vertical Partitioning Wizard

1. Select Tools ä Denormalization ä Vertical Partitioning.

or

Right-click a table in the diagram and select Vertical Partitioning fromthe contextual menu.

The Vertical Partitioning Wizard is displayed.

2. Select a partitioned table.

3. <optional> Select Keep the Partitioned Table After the Partitioningcheck box.

4. Click Next.

5. Define the partitions to generate and click Next.

6. Select the columns to include in each partition and click Next.

7. Define the name and code of the vertical partitioning object and clickFinish.

After the creation of the partitions and their corresponding tables, thepartitioned table is deleted from the model. All references incoming oroutgoing the partitioned table are recreated on each partition table.

A vertical partitioning object is created each time you perform a verticalpartitioning on a table.

382

Page 395: Physical Data Model - SAP

Chapter 9. Denormalizing a PDM

Using the vertical partitioning object

The vertical partitioning object is automatically created when you definetable partitions, this object belongs to the category of transformation objectsthat is displayed in the List of Transformations, available from the menucommand Model ä Transformations.

This vertical partitioning object has the following properties:

Property Description

Name Name of the vertical partitioning object. It is recom-mended to provide a clear name in the Vertical Partition-ing Wizard

Code Code of the vertical partitioning object

Comment Additional information about the vertical partitioningobject

Partitioned table Name of the table used to create the table partitions. Thistable no longer exists in the model

The Partitions page in the vertical partitioning object property sheet displaysthe list of partitions created during vertical partitioning. You can managepartitions from this list.

+ For more information on how to manage partitions, see section“Managing vertical partitions” on page 384.

Delete a vertical partitioning object

You can use the List of Transformations to delete a vertical partitioningobject using the Delete tool in the list toolbar. Delete removes the verticalpartitioning object and the partitions, but does not delete the tablescorresponding to the partitions. The tables become independent from eachother.

Cancel a vertical partitioning transformation

You can use the List of Transformations to cancel a transformation using theCancel Transformation tool in the list toolbar. When you cancel atransformation, you delete the vertical partitioning object, the partitions, andtheir corresponding tables from the model.

Cancel can be used to recover the original table of the partitioning.

+ For more information on recovering the original table of the

383

Page 396: Physical Data Model - SAP

Vertical partitioning

partitioning, see section “Revert a vertical partitioning” on page 386.

Managing vertical partitions

You can manage partitions from the Partitions page of the property sheet of avertical partitioning object. The following actions can be performed:

♦ Open the property sheets of the tables corresponding to the partitions.You can modify the properties of the table from the property sheet. If youmodify the name or the code of the table, the name or code of thecorresponding partition is automatically updated

♦ Add more partitions and define the properties of their correspondingtables

♦ Delete one or several partitions and their corresponding tables. When youdelete a partition, a message box is displayed to ask you if you want todelete the corresponding table. You can delete a partition and keep thecorresponding table, however you cannot delete a table and keep anorphan partition

The Partition Columns page lets you move columns between partition tables.You can drag and drop columns from one partition table to another.

You cannot move or paste a vertical partitioning object into another model orpackage.

Intermodel generation of vertical partitions

When you generate in update mode a PDM from a PDM, a CDM or anOOM, vertical partitioning is preserved.

For example, you build a CDM to design the project management process,this model contains entity Task:

The CDM is generated in a PDM, entity Task becomes table Task:

384

Page 397: Physical Data Model - SAP

Chapter 9. Denormalizing a PDM

You decide to split the table in two table partitions: one table contains thedetails about the task, the other table contains the task schedule:

You modify the CDM and regenerate the PDM in update mode. Thepartitions are taken into account in the merge dialog box as you can see inthe following dialog box: CDM changes (creation of the Task_Managerattribute) are selected by default, and column modifications related topartition creation are not selected.

385

Page 398: Physical Data Model - SAP

Vertical partitioning

Revert a vertical partitioning

The revert feature is used to recover the original table used for partitioning.This procedure does not apply if you have kept the original table.

Revert is not a single-click operation, you have to perform several actions asdescribed in the procedure below. Revert is only accessible if the partitionedtable is a generated object proceeding from a PDM, CDM, or OOMgeneration into a PDM, otherwise you will not be able to recover thepartitioned table.

386

Page 399: Physical Data Model - SAP

Chapter 9. Denormalizing a PDM

v To revert a vertical partitioning

1. Select a vertical partitioning object in the List of Transformations.

2. Click the Cancel Transformation tool in the list toolbar in order to initiatethe revert process.

Cancel Transformation toolThe Cancel Transformations tool is disabled if the table is not a gener-ated object

The vertical partitioning object is removed from the list.

3. Click OK.

The vertical partitions and their corresponding tables are deleted from thePDM.

4. Regenerate the PDM in update mode.

Since the transformation object is no longer in the model, the mergedialog box lets you recreate the original table used for the partitioning.You have reverted the vertical partitioning.

387

Page 400: Physical Data Model - SAP

Table collapsing

Table collapsingTable collapsing consists in merging tables into a single table in order toeliminate joins and to improve query performance.

The generated table gathers the columns of the merged tables. All incomingand outgoing references to the input tables are preserved in the resultingtable. When the collapsed tables are related by references, the followingoccurs:

♦ The parent column of the join is no longer needed, thus removed

♦ The columns of the parent table are duplicated

♦ The foreign keys of the children are removed, but their columns arepreserved in the resulting table

Example Tables Customer and Order are linked together.

To optimize data retrieval in the database, you collapse both tables into asingle table to eliminate the join. The result is a single table (with 2synonym symbols) with the primary key of the child table:

388

Page 401: Physical Data Model - SAP

Chapter 9. Denormalizing a PDM

Using the Table Collapsing Wizard

The Table Collapsing Wizard lets you merge multiple tables into a singletable. You can collapse tables related to each other with a reference or tableswith identical primary keys.

You can keep or delete the input tables used for the collapsing.

The Table Collapsing Wizard is accessible from the Tools menu. The wizardlets you define the following parameters:

Wizard page Description

Table Collapsing Target Lets you define the name and code of the tableresulting from the collapsing of selected tables

Input Table Selection Lets you select the tables to collapse. If tablesymbols are selected in the diagram, the selec-tion is displayed in the list. You can use theAdd Tables tool to display a selection dialogbox. The tables you select will disappear. If youselect the Keep the Input Tables After the TableCollapsing check box, you preserve the originaltables used for the transformation

Table Collapsing Informa-tion

Lets you enter a name and a code for the trans-formation object that will be created togetherwith the new table. In this documentation, weshall call this object table collapsing object

389

Page 402: Physical Data Model - SAP

Table collapsing

v To use the Table Collapsing Wizard

1. Select Tools ä Denormalization ä Table Collapsing.

or

Right-click the a reference among the tables to collapse in the diagramand select Table Collapsing from the contextual menu.

The Table Collapsing Wizard is displayed.

2. Define the target table and click Next.

3. Select the input tables.

4. <optional> Keep the Input Tables After the Table Collapsing check box.

5. Click Next.

6. Define the name and code of the table collapsing object and click Finish.

A table collapsing object is created each time you perform a table collapsing.

Using the table collapsing object

The table collapsing object is automatically created when you collapsetables, this object belongs to the category of transformation objects that isdisplayed in the List of Transformations, available from the menu commandModel ä Transformations.

The table collapsing object has the following properties:

390

Page 403: Physical Data Model - SAP

Chapter 9. Denormalizing a PDM

Property Description

Name Name of the table collapsing object. It is recommended toprovide a clear name in the Table Collapsing Wizard

Code Code of the table collapsing object

Comment Additional information about the table collapsing object

Target table Name of the table resulting from the collapsing of selectedtables

The Source Tables page displays the list of collapsed tables. These tables nolonger exist in the model.

You cannot move or paste a table collapsing object into another model orpackage.

Delete a table collapsing object

You can use the List of Transformations to delete a table collapsing objectusing the Delete tool in the list toolbar. Delete removes the table collapsingobject, but does not delete the resulting table created in the model.

Cancel a table collapsing transformation

You can use the List of Transformations to cancel a transformation using theCancel Transformation tool in the list toolbar. When you cancel atransformation, you delete the table collapsing object, and the resulting tablefrom the model.

Cancel can be used to recover the original tables of the collapsing.

+ For more information on recovering the original tables of the collapsing,see section “Revert a table collapsing” on page 391.

Intermodel generation of table collapsing

When you generate in update mode a PDM from a PDM, a CDM or anOOM, table collapsing is preserved.

Revert a table collapsing

The revert feature is used to recover the original tables used for collapsing.This procedure does not apply if you have kept the original tables.

Revert is not a single-click operation, you have to perform several actions asdescribed in the procedure below. Revert is only accessible if the collapsed

391

Page 404: Physical Data Model - SAP

Table collapsing

tables are generated objects proceeding from a PDM, CDM, or OOMgeneration into a PDM, otherwise you will not be able to recover thecollapsed tables.

v To revert a table collapsing

1. Select a table collapsing object in the List of Transformations.

2. Click the Cancel Transformation tool in the list toolbar in order to initiatethe revert process.

Cancel Transformation toolThe Cancel Transformations tool is disabled if the table is not a gener-ated object

The table collapsing object is removed from the list.

3. Click OK.

The table collapsing and resulting table are deleted from the PDM.

4. Regenerate the PDM in update mode.

Since the transformation object is no longer in the model, the mergedialog box lets you recreate the original table used for the collapsing.You have reverted the table collapsing.

392

Page 405: Physical Data Model - SAP

Chapter 9. Denormalizing a PDM

Column denormalization

NoteColumn denormalization uses the object replication feature, it is recom-mended to read the object replication chapter in the General Features Guidebefore using column denormalization

You can denormalize columns to eliminate frequent joins using columndenormalization.

Example

In this example, you want to have the division name printed on the pay slipof each employee, however, you do not want to create a join between thosetables. You can denormalize columns in order to have column Div_Name intable PaySlip:

Column denormalization eliminates joins for many queries, however itrequires more maintenance and disk space.

Using the Column Denormalization Wizard

The Column Denormalization Wizard lets you duplicate columns in aselected table. The result is a column replica object in the target table.

+ For more information on replications, see chapter Managing ObjectReplications in the General Features Guide .

The Column Denormalization Wizard is accessible from the Tools menu orthe contextual menu of a table. The wizard lets you define the followingparameters:

393

Page 406: Physical Data Model - SAP

Column denormalization

Wizard page Description

Target Table Selection Lets you select the table in which you willduplicate one or several columns. If a tableis selected in the diagram, it is displayed bydefault in the Target Table Selection box. youcan use

Selection Lets you select one or several columns that willbe duplicated in the selected table

v To use the Column Denormalization Wizard

1. Select Tools ä Denormalization ä Column Denormalization.

The Column Denormalization Wizard is displayed.

2. Select the table in which you want to duplicate columns and click Next.

3. Select the columns to duplicate and click Finish.

A replica is created for each duplicated column.

You can display the list of replica from the menu command Model ä

Replications. Each replica has a property sheet with details about thereplicated object, replicated attributes, replicated collections (associationbetween metaclasses in the metamodel), and sub-replications.

+ For more information on replica, see chapter Managing ObjectReplications in the General Features Guide .

394

Page 407: Physical Data Model - SAP

Chapter 9. Denormalizing a PDM

You can move and paste a denormalized column into another model orpackage using the standard copy/paste or cut/paste features.

Intermodel generation of denormalized columns

When you generate in update mode a PDM from a PDM, a CDM or anOOM, denormalized columns are preserved.

Revert a column denormalization

You can revert a column denormalization by deleting the duplicated columnfrom the target table property sheet. This automatically removes the columnreplica.

You cannot revert a column denormalization by deleting a column replicafrom the list of replications.

395

Page 408: Physical Data Model - SAP
Page 409: Physical Data Model - SAP

CHAPTER 10

Using Business Rules in a PDM

About this chapter This chapter describes how business rules help you model information.

Contents Topic: page

What is a business rule in a PDM? 398

Defining business rules in a PDM 399

Using business rules in a PDM 408

397

Page 410: Physical Data Model - SAP

What is a business rule in a PDM?

What is a business rule in a PDM?A business rule is a rule that your business follows. This can be agovernment-imposed law, a customer requirement, or an internal guideline.

Starts as an observation Business rules often start as simple observations. For example, “customerscall toll-free numbers to place orders”. During the design process theydevelop into more detailed expressions. For example, what information acustomer supplies when placing an order or how much a customer can spendbased on a credit limit.

Guides modeling Business rules guide and document the creation of a model. For example,the rule “an employee belongs to only one division” can help yougraphically build the link between an employee and a division.

Complements graphics Business rules complement model graphics with information that is noteasily represented graphically. For example, some rules specify physicalconcerns in the form of formulas and validation rules. These technicalexpressions do not have a graphical representation.

Intermodel generation During intermodel generation the business rules transfer directly into thegenerated model where you can further specify them.

Check parameters You can attach business rules to objects in a PDM. You can generatebusiness validation rules as check parameters if the validation rules areattached to columns or domains.

+ For more information on defining and using check parameters, seesection Defining check parameters in a PDM in chapter Building PhysicalDiagrams.

398

Page 411: Physical Data Model - SAP

Chapter 10. Using Business Rules in a PDM

Defining business rules in a PDMYou can define a business rule which can be attached to an object in thePDM.

Business rule properties in a PDM

A business rule definition includes the following properties:

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces

Comment Descriptive label for the rule

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined

Type Indicates if the rule is a definition, a fact, a formula, arequirement or a validation

A business rule definition also includes the following properties, each withtheir respective page:

Property Description

Expression Presence of associated expression

Notes Presence of associated notes

Types of business rules in a PDM

In PowerDesigner, you can define several different types of business rules.Only the validation rule type can be generated to a database.

Types of business rules The different business rule types that you can define in a PDM are describedbelow:

399

Page 412: Physical Data Model - SAP

Defining business rules in a PDM

Rule type Describes Example

Definition Characteristics or prop-erties of an object in theinformation system

A customer is a person identi-fied by a name and an address

Fact Certainty or existence inthe information system

A client places one or moreorders

Formula Calculation used by theinformation system

The total order is the sum of allthe order line costs

Requirement Functional specification inthe information system

The model is designed so thattotal losses do not exceed 10%of total sales

Validation Constraint on a value in theinformation system. Val-idation business rules aregenerated in the database

The sum of all order totals for aclient must not be greater thanthe allowance for the client

Constraint Additional check constrainton a value. You can assignmultiple constraint busi-ness rules to a table or acolumn. Constraint busi-ness rules are generated inthe database

The start date should be inferiorto the end date of a project

+ For more information on constraint business rules, see section “Usingconstraint business rules in a PDM” on page 402.

Creating a business rule in a PDM

Before you create business rules, formulate your rules by asking yourself thefollowing questions:

♦ What business problems do I want to address?

♦ Are there any mandatory procedures for my system?

♦ Do any specifications set the scope of my project?

♦ Do any constraints limit my options?

♦ How do I describe each of these procedures, specifications, andconstraints?

♦ How do I classify these descriptions: as definitions, facts, formulas, orvalidation rules?

400

Page 413: Physical Data Model - SAP

Chapter 10. Using Business Rules in a PDM

v To create a business rule in a PDM

1. Select Model ä Business Rules to display the List of Business Rulesshowing any business rules currently defined for the model.

2. Click a blank line in the list.

or

Click the Add a Row tool.

An arrow is displayed at the beginning of the line.

3. Type a name and a code for the business rule.

4. Click Apply to commit the creation of the new business rule.

5. Double-click the new business rule line to display the business ruleproperty sheet.

6. Select a business rule type from the Type dropdown list box.

7. Click OK.

Attaching an expression to a business rule in a PDM

A business rule typically starts out as a description. As you develop yourmodel and analyze your business problem, you can complete a rule byadding a technical expression. The syntax of expressions depends on thetarget database.

Each business rule can include two types of expression:

♦ Server

401

Page 414: Physical Data Model - SAP

Defining business rules in a PDM

♦ Client

Only the server expression can be generated to a database. You can generateserver expressions as check parameters if they are attached to tables,domains, or columns.

A client expression is used mainly for documentation purposes. However,you can insert both types of expression into a trigger or a stored procedure.

v To attach an expression to a business rule in a PDM

1. Select Model ä Business Rules to display the List of Business Rules.

2. Double-click the new business rule line to display the business ruleproperty sheet.

3. Click the Expression tab to display the Expression page.

4. Click the Server tab at the bottom of the page to define a serverexpression.

or

Click the Client tab at the bottom of the page to define a client expression.

5. Type an expression in the Expression textbox.

6. Click OK in each of the dialog boxes.

Using constraint business rules in a PDM

A constraint business rule is used to manage multiple constraints on tablesand columns in a database for the DBMS that support this feature.

During generation, the variable %RULES% is evaluated in order to generatea single constraint in the SQL script. This constraint is a concatenation of allcheck parameters defined in the Check tab of a table property sheet, and allvalidation business rules applied to the current table. You can preview theresult of the concatenation of checks and validation business rules in thePreview page of a table property sheet.

+ For more information on the check parameters of a table, see sectionNaming a table constraint in chapter Building physical diagrams.

If you want to define distinct check constraints on tables and columns, youhave to define constraint business rules and attach them to objects. This typeof business rule allows to generate multiple check constraints on an object inthe database.

402

Page 415: Physical Data Model - SAP

Chapter 10. Using Business Rules in a PDM

This feature is only available for DBMS supporting multiple checkconstraints, and provided the EnableMultiCheck entry in the Generalcategory of the DBMS is set to Yes.

+ For more information on DBMS entries, see chapter DBMS ReferenceGuide in the Advanced User Documentation .

Example Let’s consider the table Project:

+ The following checks are defined for this table:

Check Description

Check parameter (inthe Check page of thetable)

This check verifies that the customer number isdifferent from the employee number

Validation business rule PROJ_NUM to check that the column projectnumber is not null

EMP_NUM to check that the employee number isnot null

Constraint business rule DATE_CONSTY to check that the start date of theproject is inferior to the end date of the project

+ When you display the table code preview, you can verify that the checkparameters and validation business rules are concatenated into a singleconstraint, whereas the constraint business rule is displayed as a differentconstraint in the script.

403

Page 416: Physical Data Model - SAP

Defining business rules in a PDM

Creating a constraint business rule

v To create a constraint business rule in a PDM

1. Select Model ä Business Rules to display the List of Business Rulesshowing any business rules currently defined for the model.

2. Click a blank line in the list.

or

Click the Add a Row tool.

An arrow is displayed at the beginning of the line.

3. Type a name and a code for the business rule.

4. Click Apply to commit the creation of the new business rule.

5. Double-click the new business rule line to display the business ruleproperty sheet.

6. Select a business rule type from the Type dropdown list box.

404

Page 417: Physical Data Model - SAP

Chapter 10. Using Business Rules in a PDM

7. Click the Expression tab to display the Expression page of the businessrule.

8. Type an expression in the Server page.

405

Page 418: Physical Data Model - SAP

Defining business rules in a PDM

9. Click OK.

+ For more information on applying a constraint business rule to a table ora column, see section “Applying a constraint business rule to a table or acolumn” on page 409.

Generating a constraint business rule

Depending on the type of DBMS, the following is generated regarding checkconstraints:

Database type Generation result

Database does not sup-port any check con-straints

No constraint is generated

Database does not sup-port multiple check con-straints

Constraint business rules, check parameters, andvalidation business rules are concatenated into asingle constraint expression

Database supports multi-ple check constraints

First, the check parameters and validation busi-ness rules are generated into a single constraint,then the constraint business rules are generatedinto different constraints. Constraints are thusordered

406

Page 419: Physical Data Model - SAP

Chapter 10. Using Business Rules in a PDM

Reverse engineering a constraint business rule

During reverse engineering, the constraint order is taken into account:

♦ The first constraint is retrieved as check parameters (in the Check page ofthe table property sheet)

♦ Each constraint following the initial constraint is retrieved as a constraintbusiness rule

407

Page 420: Physical Data Model - SAP

Using business rules in a PDM

Using business rules in a PDMThere are three ways to use business rules in a PDM:

♦ You can apply a business rule to an object in the PDM

♦ You can create a server expression for a business rule which can begenerated to a database

♦ A business rule expression can also be inserted in a trigger or storedprocedure

+ For more information on triggers, see the Building Triggers andProcedures chapter.

Applying a business rule to the current object in a PDM

You can apply a business rule to the current object from its property sheet.

v To apply a business rule to the current object in a PDM

1. Double-click an object in the diagram to display the object property sheet.

2. Click the Rules tab to display the Rules page showing any business rulesattached to the object.

3. Click the Add Objects tool to display the list of business rules.

4. Select one or more business rules.

408

Page 421: Physical Data Model - SAP

Chapter 10. Using Business Rules in a PDM

5. Click OK.

The business rules are added to the object and appear in the list ofbusiness rules for the object.

6. Click OK.

U Column in the List of business rules

When you apply a business rule to an object, the U (Used) columnbeside this business rule is automatically checked in the List of businessrules to indicate that the business rule is used by at least one object inthe model. The U column allows you to visualize unused business rules,you can then delete them if necessary.

Applying a constraint business rule to a table or a column

You can attach a constraint business rule to a table or a column, however youcannot reuse a constraint business rule between different objects, so youmust create as many constraint business rules as needed for your modelobjects.

When you attach a constraint business rule to an object, the code of thebusiness rule will be used as constraint name. If you wish to enforce codeuniqueness for constraints in your model, you have to set theUniqueConstName entry in the General category of the DBMS to Yes. Insuch case, the code of the constraint generated from validation business rulesand the code of the constraint business rules must be unique in the model.

+ For more information on DBMS entries, see chapter DBMS ReferenceGuide in the Advanced User Documentation .

v To attach a constraint business rule to an object

1. Open the object property sheet.

2. Click the Rules tab to display the Rules page.

3. Click the Add Objects tool.

4. Select a constraint business rule from the selection list and click OK.

The business rule is displayed in the list of business rules attached to thecurrent object.

409

Page 422: Physical Data Model - SAP

Using business rules in a PDM

5. Click Apply.

6. Click the Preview tab if you are working on a table to verify that differentconstraints have been created in the script.

7. Click OK.

410

Page 423: Physical Data Model - SAP

CHAPTER 11

Generating Other Models from a PDM

About this chapter This chapter describes how to generate a PDM, a CDM, an OOM, and anXML model from a Physical Data Model.

Contents Topic: page

Generation Basics 412

Generating a Physical Data Model from a Physical Data Model 413

Generating a Conceptual Data Model from a Physical Data Model 417

Generating an Object-Oriented Model from a Physical Data Model 425

Generating an XML Model from a Physical Data Model 431

411

Page 424: Physical Data Model - SAP

Generation Basics

Generation BasicsYou can generate a PDM, a CDM, an OOM or an XSM from a PDM.

+ For more information on model to model or inter-model generationcommon features, see the “Linking and Synchronizing Models inPowerDesigner” chapter in the General Features Guide .

412

Page 425: Physical Data Model - SAP

Chapter 11. Generating Other Models from a PDM

Generating a Physical Data Model from a PhysicalData Model

This section explains how to generate a Physical Data Model from aPhysical Data Model.

Why generate a PDM into a PDM?

You can generate a PDM into a PDM when you need to keep two modelssynchronized during the design process.

This kind of generation allows you to create a copy of a given model anddefine generation links between objects in the source PDM and theirequivalent in the generated PDM. When changes are made to the sourcemodel, they can then be easily propagated to the generated models using theUpdate Existing Model generation mode.

The generated model is the one that usually contains more information.

Multi DBMS environment If you are working in a multi DBMS environment, you can use the PDM toPDM generation to avoid generating a CDM into different PDM based ondifferent DBMS. You generate a PDM from the CDM, this PDM uses the<logical model> DBMS. Then you can use this PDM to generate differentPDM for the different DBMS required as shown in the following figure:

413

Page 426: Physical Data Model - SAP

Generating a Physical Data Model from a Physical Data Model

<logical model> DBMSThis DBMS does not support database generation

Generating and updating a PDM

To generate a PDM, you must choose between one of the following methods:

♦ Generate new Physical Data Model

♦ Update existing Physical Data Model

You must indicate the following parameters when you generate a new PDM:

Parameter Description

DBMS Database Management System definition for the resultingPDM

Share The resulting PDM uses a shared DBMS definition filestored in the DBMS library

Copy The resulting PDM uses a copy of the DBMS definition filein the model

Name File name for the resulting PDM

Code Reference code for the resulting PDM

ConfigureModel Options

Lets you specify model options for the model to be gener-ated. For example links to requirements in the origin modelare preserved, by default, in the generated model, unlessyou clear the Enable Links Requirements checkbox in theModel Options dialog box before starting the generation

+ For more information, see the “Linking and Synchronizing Models inPowerDesigner” chapter in the General Features Guide .

Defining DBMS preserve options

If you generate a PDM into a PDM with a different DBMS, depending onwhich objects are supported by the old and new target DBMS, you canchoose to preserve or lose, the values associated with the following databaseobjects:

♦ Triggers and stored procedures

♦ Physical options for: databases, tables, indexes, primary and alternatekeys, default options, tablespaces, and storages

414

Page 427: Physical Data Model - SAP

Chapter 11. Generating Other Models from a PDM

♦ Database objects: databases, storages, tablespaces, abstract data types,sequences

♦ Extended attributes

If a database object is not supported by the old or new target DBMS, thepreserve option for that object is grayed and cannot be selected. If the newtarget DBMS does not support an object, you will lose the values associatedwith that object when you change target DBMS.

Triggers are rebuilt when a change in DBMS family is madeIf you change the target DBMS family, for example from Sybase to Oracleor IBM DB2, triggers are automatically rebuilt

Defining PDM generation options

You can set the following general generation options from the Detail tab:

415

Page 428: Physical Data Model - SAP

Generating a Physical Data Model from a Physical Data Model

Option Description

Check Model When selected, verifies the model before generating thePDM, and stops generation if an error is found

Save Genera-tion Dependen-cies

When selected, PowerDesigner keeps track of the identityof the origin of each generated object. It is useful whenmerging two PDM which have been generated from thesame PDM. Objects can be compared and recognized asthe same object, even if the object has been modified inthe merged PDM. If not selected, origin objects have nolink with generated objects

R/R Mapping When selected, allows to define the current PDM as thedata source of the generated PDM and to create objectcorrespondence between source and target PDM. If youselect the R/R mapping option, the Save GenerationDependencies option is automatically selected becauseR/R mapping uses object identifying numbers. You cannotdeselect the Save Generation Dependencies option as longas the R/R mapping option is selected

Enable transfor-mations

This button is used to activate transformations duringgeneration.

When you click this button, the Pre-generation tab isdisplayed if the source model contains transformations.You can select the transformations to execute beforegeneration.

The Extended Model Definitions tab also is displayed foryou to select extended model definition files to attach to thegenerated model. These files may contain post-generationtransformations, in this case, the Post-Generation tab isdisplayed to let you select the transformations you wantto be executed in the generated model. If the generationis an update, and the generated model contains extendedmodel definitions with post-generation transformations,the Post-generation tab automatically is displayed as soonas you click the Enable Transformations button

Check model before generationIf you select the Check Model option, the procedure to generate a PDMstarts by checking the validity of the source PDM. A PDM results when noerrors are found. You can set check options by selecting Tools ä CheckModel.

416

Page 429: Physical Data Model - SAP

Chapter 11. Generating Other Models from a PDM

Generating a Conceptual Data Model from aPhysical Data Model

This section explains how to generate a Conceptual Data Model from aPhysical Data Model.

Generating CDM objects

When you generate a Conceptual Data Model (CDM) from a PDM,PowerDesigner translates physical objects to conceptual objects as follows:

Object in a PDM Generated object in a CDM

Table Entity

Table column Entity attribute

Primary key Primary identifier

Alternate key Identifier

Reference Relationship

Oracle 8 and Interbasesequence translation

When a CDM is generated from a PDM, the data type of a table columnattached to a sequence is translated to a serial data type in the new model.

The resulting CDM serial data type for an entity property has the formatNO%n, where %n is a number indicating the length of the data type.

+ For more information on sequences, see sections on Oracle andInterbase in chapter DBMS-specific Features.

Translating PDM to CDM data types

PowerDesigner supports both physical and conceptual data types. Thefollowing table lists the physical data types to which PowerDesigner assignstranslations:

Numeric data types

Translation ex-ample for SQLAnywhere

Code inDBMS

What it stores Conceptual datatype

integer I 32-bit integer Integer

smallint SI 16-bit integer Short Integer

integer LI 32-bit integer Long Integer

417

Page 430: Physical Data Model - SAP

Generating a Conceptual Data Model from a Physical Data Model

Translation ex-ample for SQLAnywhere

Code inDBMS

What it stores Conceptual datatype

smallint BT 256 values Byte

numeric N Numbers with a fixeddecimal point

Number

decimal DC Numbers with a fixeddecimal point

Decimal

float F 32-bit floating decimalnumbers

Float

real SF Less than 32-bit float-ing decimal number

Short Float

double LF 64-bit floating decimalnumbers

Long Float

numeric MN Numbers with a fixeddecimal point

Money

numeric NO Automatically incre-mented numbers

Serial

numeric(1) BL Two opposing values(true/false; yes/no; 1/0)

Boolean

Character data types

418

Page 431: Physical Data Model - SAP

Chapter 11. Generating Other Models from a PDM

Translation ex-ample for SQLAnywhere

DBMS What it stores Conceptual data type

char A Character strings Characters

varchar VA Character strings Variable Characters

varchar LA Character strings Long Characters

long varchar LVA Character strings Long Var Characters

long varchar TXT Character strings Text

char MB Multibyte char-acter strings

Multibyte

varchar VMB Multibyte char-acter strings

Variable Multibyte

Time data types

Translation ex-ample for SQLAnywhere

DBMS What it stores Conceptual data type

Date D Day, month, year date

Time T Hour, minute, andsecond

time

Date & Time DT Date and time timestamp

Timestamp TS System date and time timestamp

Other data types

419

Page 432: Physical Data Model - SAP

Generating a Conceptual Data Model from a Physical Data Model

Translation ex-ample for SQLAnywhere

DBMS What it stores Conceptual datatype

binary BIN Binary strings Binary

long binary LBIN Binary strings Long Binary

long binary PIC Images Image

long binary BMP Images in bitmapformat (BMP)

Bitmap

long binary OLE OLE links OLE

char(10) * User-defined datatype

Other

<undefined> <UNDEF> Not yet defineddata type

Undefined

Generating and updating a CDM

To generate a CDM, you must choose between one of the followingmethods:

♦ Generate new Conceptual Data Model

♦ Update existing Conceptual Data Model

You must indicate the following parameters when you generate a new CDM:

Parameter Description

Name File name for the resulting CDM

Code Reference code for the resulting CDM

Configure ModelOptions

Lets you specify model options for the model tobe generated. For example links to requirements inthe origin model are preserved, by default, in thegenerated model, unless you clear the Enable LinksRequirements checkbox in the Model Options dialogbox before starting the generation

+ For more information, see the “Linking and Synchronizing Models inPowerDesigner” chapter in the General Features Guide .

420

Page 433: Physical Data Model - SAP

Chapter 11. Generating Other Models from a PDM

Configuring the generated model options

When you configure the options of a CDM to generate, you may defineoptions diverging from the PDM options.

To avoid conflicts, PowerDesigner applies the following rule for defaultvalues of CDM options: an option defined for the generated CDM shouldrespect the equivalent option of the PDM.

Equivalent Enforce non-divergence model options are available in both thePDM and CDM.

PDM option CDM option Result in generated CDM

4 En-force non-divergence

— Enforce non-divergence in model accordingto PDM options. Data items and attributesattached to the domain cannot have divergentdefinitions

— 4 En-force non-divergence

Enforce non-divergence in model accordingto CDM options defined using the ConfigureModel Options feature

Relationships uniquecode

Unique Code for relationships is not selected by default in the CDM options.However, if you select Unique Code for relationships in the CDM options,relationships are renamed during the generation of a PDM to a CDM.

Options with no equivalent, like Enforce Profile in the PDM without anycorresponding option in a CDM, are generated using default values found inthe registry.

Defining CDM generation options

You can set the following general generation options:

421

Page 434: Physical Data Model - SAP

Generating a Conceptual Data Model from a Physical Data Model

Option Description

Check Model When selected, verifies the model before generating theCDM, and stops generation if an error is found

Save Genera-tion Dependen-cies

When selected, PowerDesigner keeps track of the identityof the origin of each generated object. It is useful whenmerging two CDM which have been generated from thesame PDM. Objects can be compared and recognized asthe same object, even if the object has been modified inthe merged CDM. If not selected, origin objects have nolink with generated objects

Convert Namesinto Codes

When selected, object codes are generated from namesusing the corresponding conversion script. This is usefulwhen generating models with very different naming con-ventions. With this option selected, objects will have theircodes generated from their names. If you do not selectthis option, generated object codes will be copied fromoriginal object codes

Enable transfor-mations

This button is used to activate transformations duringgeneration.

When you click this button, the Pre-generation tab isdisplayed if the source model contains transformations.You can select the transformations to execute beforegeneration.

The Extended Model Definitions tab also is displayed foryou to select extended model definition files to attach to thegenerated model. These files may contain post-generationtransformations, in this case, the Post-Generation tab isdisplayed to let you select the transformations you wantto be executed in the generated model. If the generationis an update, and the generated model contains extendedmodel definitions with post-generation transformations,the Post-generation tab automatically is displayed as soonas you click the Enable Transformations button

+ For more information on conversion scripts, see chapter Managingmodels in the General Features Guide.

Check model before generationIf you select the Check Model option, the procedure to generate a CDMstarts by checking the validity of the PDM A CDM results when no errorsare found. You can set check options by selecting Tools ä Check Model.

422

Page 435: Physical Data Model - SAP

Chapter 11. Generating Other Models from a PDM

Migrating models from version 6

When migrating a version 6 CDM and its corresponding generated PDM tocurrent version, PowerDesigner automatically preserves the generation linkbetween the CDM and the PDM during the import process. So that if youhave modified the migrated CDM and PDM and want to regenerate the PDMfrom the CDM in current version, with the Preserve Modifications optionselected, the modifications you made in the PDM are preserved.

Migration procedure The synchronization of your models through migration is guaranteed as youimport the version 6 CDM and its corresponding version 6 PDM at once.

The migration process begins with the import of the Conceptual Model thenthe import of the corresponding Physical Models.

There can be several generated PDMs for a given CDM. Note that if you failto select one of the corresponding PDMs to import and wish later to importit in PowerDesigner current version, you must import again the version 6CDM and select again its corresponding version 6 PDMs that you want toimport. This operation is mandatory, otherwise the CDM and the previouslyimported PDMs are no longer synchronized.

When migrating a version 6 PDM, you can open:

♦ Archived models (*.apm): you avoid losing constraint names becausearchived models store all constraint names without making a differencebetween user defined and calculated constraints. Importing an archivedmodel allows you to recover all the constraint names of your version 6PDM, which is recommended

♦ Standard models (*.pdm): you may lose constraint names becausestandard PDM do not store calculated constraint names

v To migrate version 6 models to current version and keep themsynchronized

1. Select File ä Import ä V6 Synchronized Models.

The Import V6 Synchronized Models dialog box is displayed.

2. Click the Add CDM File tool in the Conceptual Data Model to importgroupbox to select the CDM to import.

3. Click the Add PDM Files tool in the Physical Data Models to importgroupbox to select the PDMs to import.

423

Page 436: Physical Data Model - SAP

Generating a Conceptual Data Model from a Physical Data Model

4. Click OK.

The name of the CDM first is displayed in the Browser followed by thenames of the PDMs you selected for import. The CDM diagram also isdisplayed in the diagram window.

5. Save the CDM in current version.

6. Save the PDMs in current version.

7. Save the workspace displaying the linked CDM and PDMs under ameaningful workspace name.

424

Page 437: Physical Data Model - SAP

Chapter 11. Generating Other Models from a PDM

Generating an Object-Oriented Model from aPhysical Data Model

This chapter describes how you can generate an Object-Oriented Model(OOM) from a Physical Data Model (PDM).

Generating OOM Objects

When you generate an Object-Oriented Model (OOM) from a PDM,PowerDesigner translates PDM objects into specified object languageobjects as follows:

PDM Object Generated object in an OOM

Domain Domain

Table Class. The cardinality of a class is translated from thenumber of estimated records in a table

Table with migratedkeys from only twoother tables

Class linked with an association class between thetwo classes generated by the two parent tables

Column Attribute

Key Identifier

Primary key Primary identifier

Stored-Proceduresand stored functionsattached to selectedtable

If the parent table is generated as a class, the storedprocedure or the stored function is generated as anoperation attached to the class

Reference Association

Persistent tables All tables are generated as persistent classes with the “Generate table”persistence mode.

All abstract data types are generated as persistent classes with the “GenerateADT” persistence mode.

425

Page 438: Physical Data Model - SAP

Generating an Object-Oriented Model from a Physical Data Model

OOM naming conventionsIf the code of the generated OOM objects does not correspond to the targetlanguage naming conventions, you can define a code naming conventionscript to convert object names into codes. For more information onconversion scripts, see section .convert_name & .convert_code macros inchapter Managing Models in the General Features Guide.

Oracle 8 and Interbasesequence translation

When an OOM is generated from a PDM, the data type of a table columnattached to a sequence is translated to a serial data type in the new model.

The resulting OOM serial data type for a class attribute has the format NO%n,where %n is a number indicating the length of the data type.

+ For more information on sequences, see sections on Oracle andInterbase in chapter DBMS-specific Features.

Translating PDM to OOM data types

PowerDesigner supports both physical and object language data types.

The following table lists the physical data types to which the object languagedefinition assigns translations:

Physicaldata type

Code inPDM

What it stores Translation examplewith Java

Char A Character strings char

Numeric(1) BL Two opposing values(true/false; yes/no; 1/0)

boolean

Smallint BT 256 values byte

Integer SI 16-bit integer short

Integer LI 32 bit integer integer

Integer I 32 bit integer long

Float F 32 floating point numbers float

Numeric N Numbers with a fixeddecimal point

double

Long varchar TXT Character strings String

Generating and updating an OOM

To generate an OOM, you must choose between one of the following

426

Page 439: Physical Data Model - SAP

Chapter 11. Generating Other Models from a PDM

methods:

♦ Generate a new Object-Oriented Model

♦ Update an existing Object-Oriented Model

You must indicate the following parameters when you generate a new OOM:

Parameter Description

Object Lan-guage

Target object language

Share Object language for the resulting OOM uses a shared Objectlanguage definition file stored in the Object language library

Copy Object language for the resulting OOM uses a copy ofthe Object language definition file stored in the Objectlanguage library

Name File name for the resulting OOM

Code Reference code for the resulting OOM

ConfigureModel Options

Lets you specify model options for the model to be gener-ated. For example links to requirements in the origin modelare preserved, by default, in the generated model, unlessyou clear the Enable Links Requirements checkbox in theModel Options dialog box before starting the generation

+ For more information, see the “Linking and Synchronizing Models inPowerDesigner” chapter in the General Features Guide .

Configuring the generated model options

When you configure the options of an OOM to generate, you may defineoptions diverging from the PDM options.

To avoid conflicts, PowerDesigner applies the following rule for defaultvalues of OOM options: an option defined for the generated OOM shouldrespect the equivalent option of the PDM.

Equivalent Enforce non-divergence model options are available in both theOOM and PDM.

427

Page 440: Physical Data Model - SAP

Generating an Object-Oriented Model from a Physical Data Model

PDM option OOM option Result in generated OOM

4 En-force non-divergence

— Enforce non-divergence in model ac-cording to PDM options

— 4 Enforce non-divergence

Enforce non-divergence in model ac-cording to OOM options defined usingthe Configure Model Options feature

Options with noequivalent in the models

Options with no equivalent, like Enforce Profile in the PDM without anycorresponding option in an OOM, are generated using default values foundin the registry.

Defining OOM generation options

You can set the following general generation options:

Option Description

Check Model When selected, verifies the model before generating theOOM, and stops generation if an error is found

Save Genera-tion Dependen-cies

When selected, PowerDesigner keeps track of the identityof the origin of each generated object. It is useful whenmerging two OOM which have been generated from thesame PDM. Objects can be compared and recognized asthe same object, even if the object has been modified inthe merged OOM. If not selected, origin objects have nolink with generated objects

Class Prefix Prefix for a class. It can help identify a class in a model

O/R Mapping When selected, allows to define the current PDM as thedata source of the generated OOM and to create objectcorrespondence between PDM and OOM. If you select theO/R mapping option, the Save Generation Dependenciesoption is automatically selected because O/R mappinguses object identifying numbers. You cannot deselect theSave Generation Dependencies option as long as the O/Rmapping option is selected

428

Page 441: Physical Data Model - SAP

Chapter 11. Generating Other Models from a PDM

Option Description

Convert Namesinto Codes

When selected, object codes are generated from namesusing the corresponding conversion script. This is use-ful when generating models with very different namingconventions since conversion macros are used to modifycodes. For example a Java class attribute code may be“customerName” whereas a PDM table column may be“CUSTOMER_NAME”. With this option selected, bothobjects will have their codes generated from their names.If you do not select this option, generated object codeswill be copied from original object codes

Enable transfor-mations

This button is used to activate transformations duringgeneration.

When you click this button, the Pre-generation tab isdisplayed if the source model contains transformations.You can select the transformations to execute beforegeneration.

The Extended Model Definitions tab also is displayed foryou to select extended model definition files to attach to thegenerated model. These files may contain post-generationtransformations, in this case, the Post-Generation tab isdisplayed to let you select the transformations you wantto be executed in the generated model. If the generationis an update, and the generated model contains extendedmodel definitions with post-generation transformations,the Post-generation tab automatically is displayed as soonas you click the Enable Transformations button

+ For more information on conversion scripts, see chapter Managingmodels in the General Features Guide.

Add package hierarchy When you reverse engineer a database into a PDM and then generate anOOM with the corresponding O/R mapping, you can use the Add PackageHierarchy feature to create the appropriate packages in the OOM. You selectthe Add Package Hierarchy command from the object model contextualmenu. For more information see chapter Generating for a language in theOOM User’s Guide .

429

Page 442: Physical Data Model - SAP

Generating an Object-Oriented Model from a Physical Data Model

Check model before generationIf you select the Check Model option, the procedure to generate an OOMstarts by checking the validity of the PDM . An OOM results when noerrors are found. You can set check options by selecting Tools ä CheckModel.

430

Page 443: Physical Data Model - SAP

Chapter 11. Generating Other Models from a PDM

Generating an XML Model from a Physical DataModel

This section explains how to generate an XML Model from a Physical DataModel.

Generating XML Model objects

When you generate an XML model from a PDM, PowerDesigner translatesPDM objects into specified XML model objects as follows:

PDM Object Generated object in an XML model

Domain Simple Type

Table Element

Column Attribute or element (see generation options)

View Element

View column Attribute

Key Key

Foreign Key When a foreign key is not a composition, it is gener-ated as a KeyRef constraint

Index Unique

Abstract data type Complex Type

XML model naming conventionsIf the code of the generated XML model objects does not correspond tothe target language naming conventions, you can define a code namingconvention script to convert object names into codes. For more informationon conversion scripts, see section .convert_name & .convert_code macrosin chapter Managing Models of the General Features Guide.

Generating and updating an XML Model

To generate an XML Model, you must choose between one of the followingmethods:

♦ Generate new XML Model

♦ Update existing XML Model

431

Page 444: Physical Data Model - SAP

Generating an XML Model from a Physical Data Model

You must indicate the following parameters when you generate a new XMLmodel:

Parameter Description

Schema language Target schema language

Share Schema language for the resulting XML model.It uses a shared schema language definition filestored in the XML Languages library

Copy Schema language for the resulting XML model. Ituses a copy of the schema language definition filestored in the XML Languages library

Name File name for the resulting XML model

Code Reference code for the resulting XML model

Configure Model Op-tions

Lets you specify model options for the model tobe generated. For example links to requirementsin the origin model are preserved, by default,in the generated model, unless you clear theEnable Links Requirements checkbox in theModel Options dialog box before starting thegeneration

+ For more information, see the “Linking and Synchronizing Models inPowerDesigner” chapter in the General Features Guide .

Defining XML Model generation options

The Detail tab of the XML Model Generation Options dialog box displaysthe following options:

432

Page 445: Physical Data Model - SAP

Chapter 11. Generating Other Models from a PDM

Option Description

Check model When selected, it verifies the model before generating theXML model, and stops generation if an error is found

Save generationdependencies

When selected, PowerDesigner keeps track of the identityof the origin of each generated object. It is useful whenmerging two XML models which have been generatedfrom the same PDM. Objects can be compared and rec-ognized as the same object, even if the object has beenmodified in the merged XML model. If not selected, originobjects have no link with generated objects

Convert namesinto codes

When selected, object codes are generated from namesusing the corresponding conversion script. This is use-ful when generating models with very different namingconventions. With this option selected, both objects willhave their codes generated from their names. If you do notselect this option, generated object codes will be copiedfrom original object codes

Generate map-ping

When selected, allows to define the current PDM as thedata source of the generated XML model and to createobject correspondence between PDM and XML model.If you select the Generate mapping option, the SaveGeneration Dependencies option is automatically selectedbecause the mapping uses object identifying numbers. Youcannot deselect the Save Generation Dependencies optionas long as the Generate mapping option is selected

Enable transfor-mations

This button is used to activate transformations duringgeneration. When you click this button, the Pre-generationtab is displayed if the source model contains transfor-mations. You can select the transformations to executebefore generation. The Extended Model Definitions tabalso is displayed for you to select extended model defi-nition files to attach to the generated model. These filesmay contain post-generation transformations, in this case,the Post-Generation tab is displayed to let you selectthe transformations you want to be executed in the gen-erated model. If the generation is an update, and thegenerated model contains extended model definitions withpost-generation transformations, the Post-generation tabautomatically is displayed as soon as you click the EnableTransformations button

Generatecolumns as ele-ments

When selected, columns in the PDM tables are generatedas child elements (instead of attributes) in the XML model.You can then set attributes to these child elements 433

Page 446: Physical Data Model - SAP

Generating an XML Model from a Physical Data Model

+ For more information on conversion scripts, see chapter ManagingModels in the General Features Guide .

Check model before generationIf you select the Check model option, the procedure to generate an XMLmodel starts by checking the validity of the PDM. An XML model resultswhen no errors are found. You can set check options by selecting Tools ä

Check Model.

Generating an XML model via the XML Builder Wizard

The XML Builder Wizard helps you build an XML model that will be usedto generate SQL/XML queries for retrieving data from databases. Unlike thestandard PDM to XML model generation, the XML Builder Wizardfacilitates the next operations:

♦ You can build your own hierarchy of elements and attributes from tables,views and columns

♦ A SQL/XML extended model definition is automatically attached to thegenerated XML model, therefore you can generate SQL/XML queriesfrom global elements, to retrieve data from relational databasessupporting SQL/XML (See “Generating SQL/XML queries” onpage 440)

♦ The generated XML model is automatically mapped to the PDM. Byattaching the appropriate extended model definition to the generatedXML model, you can generate an annotated schema to store or retrievedata in an XML format, from relational databases supporting XML (See“Generating annotated schemas” on page 440)

During the XML Builder Wizard process, you can perform the followingactions:

♦ Generate columns as elements or attributes

♦ Generate tables and views as elements by drag and drop or using thecontextual menu

♦ Display tables, views or columns property sheets

♦ Add Sequence, Choice or All group particles

♦ Rename elements or attributes

♦ Add new elements or attributes without mapping

♦ Delete elements, attributes or group particles

434

Page 447: Physical Data Model - SAP

Chapter 11. Generating Other Models from a PDM

v To generate an XML model via the XML Builder Wizard

1. Select Tools ä XML Builder Wizard.

2. Select generation options and click Next in each tab of the wizard.

3. Click Finish.

The different actions of the wizard are detailed in the following sections.

CautionThe following sections assume you have a PDM open in the workspace. Ifyou choose to work with an existing XML model, it must also be open inthe workspace.

Defining the XML model to generate

In the Model Selection tab, you select one of the following options:

♦ The new model option. Type a name and a code for the new model, andselect a language in the XML language list

♦ The existing model option. Select a model in the XML Model list

Selecting tables and views

In the Tables and Views Selection tab, you select tables and views togenerate in the XML model.

435

Page 448: Physical Data Model - SAP

Generating an XML Model from a Physical Data Model

All tables and views are selected by default. Click the Deselect All tool andselect the tables and views you want to generate into XML elements.

Building an XML hierarchy

In the XML Hierarchy Design tab, you build the structure of the generatedXML model.

The XML structure starts with the predefined Root element to which all firstgeneration elements should be linked, if you want your XML structure to bestrictly valid. For internal use, you can delete the Root element and start theXML structure from the Elements folder.

436

Page 449: Physical Data Model - SAP

Chapter 11. Generating Other Models from a PDM

Selecting the columnsoption

If you click the Element radio button, columns are created as elements,otherwise they are created as attributes.

Dragging and droppingitems

To create the XML hierarchy you have to click a table name and drag anddrop it to the Root or to an element folder in the right-hand pane. You canalso click the target element in the right-hand pane, right-click a table namein the left pane and select Add in the contextual menu.

If you chose to create columns as attributes, an element with the table nameis displayed in the right-hand pane with an attribute for each column. If youchose to create columns as elements, elements corresponding to the columnsare created under the table element. The child table is displayed as a childelement linked to its parent element via a sequence group particle.

437

Page 450: Physical Data Model - SAP

Generating an XML Model from a Physical Data Model

Building the XMLhierarchy Caution

You cannot create an XML hierarchy between two elements if there isno reference between their corresponding tables. The XML hierarchyrespects the PDM hierarchy: A parent table cannot be the child element ofan element corresponding to a child table.

You can use the following tools to build the hierarchy:

Tool Description

Adds the selected object in the left-hand pane to the selecteditem in the XML hierarchy.

Creates a default hierarchy for the selected category (for ex-ample when the Tables category is selected). This tool is alsoavailable when you no category or object is selected in theright-hand tree, it then creates the entire XML hierarchy.

You can create a group particle from a parent element in the right-handpane using the New ä Sequence (Choice or All) commands in the element’scontextual menu.

438

Page 451: Physical Data Model - SAP

Chapter 11. Generating Other Models from a PDM

The following actions are available in the XML Hierarchy Design tab of thewizard:

Action Description

Open tables and columns prop-erty sheets

Double-click or right-click a table or acolumn name and select Properties in thecontextual menu

Rename elements or attributes Click an element or an attribute name andtype a new name

Add new elements or attributeswithout mapping

Right-click the Elements folder or anAttributes folder and select New in thecontextual menu. Right-click a group par-ticle and select New ä Element (Sequence,Choice or All) in the contextual menu

Delete elements, attributes orgroup particles

Right-click an element name, an attributename or folder, a group particle name andselect Delete in the contextual menu

When you click Finish, the new XML model is displayed in the diagramwindow and the Browser tree view (not expanded). Expand the model in theBrowser tree view to reveal all its generated elements and attributes (or childelements).

In the case of an existing XML model, the generated elements appear next tothe existing elements.

The XML Builder Wizard attaches the SQL/XML extended modeldefinition to the new or existing XML model to generate SQL/XML queriesfrom global elements. (See next section)

439

Page 452: Physical Data Model - SAP

Generating an XML Model from a Physical Data Model

Generating SQL/XML queries

SQL/XML is an XML extension of the Structured Query Language. Itallows you to retrieve data from a relational database, and to present thequery results in an XML format.

As the XML Builder Wizard attaches the SQL/XML extended modeldefinition to the generated XML model, SQL/XML queries can beautomatically generated for global elements.

+ For more information on generating SQL/XML queries, see GeneratingSQL/XML queries, in chapter Exchanging data with databases supportingXML, in the XML Model User’s Guide .

Generating annotated schemas

Annotated schemas are XML-coded files, targeted with an XML languageand tagged with specific DBMS annotations, that allow you to store orretrieve data in an XML format, from relational databases supporting XML.

You can generate annotated schemas from XML models mapped or not withPDMs and linked with the appropriate DBMS extended model definition(XEM file). When a mapping is needed, you should use the XML BuilderWizard.

The following table lists the DBMS for which you can generate annotatedschemas:

Targeted DBMS Mapping withXML Builder Wiz-ard

Targeted XMLlanguage

Required XEMfile

Microsoft SQLServer 2000

Yes XSD or XDR Microsoft SQLServer

Oracle 9i2 No XSD Oracle 9i2

IBM DB2 v8.1 Yes DTD IBM DB2 DAD

+ For more information on generating annotated schemas, see chapterExchanging data with databases supporting XML, in the XML Model User’sGuide .

440

Page 453: Physical Data Model - SAP

PART II

WORKING WITHDATABASES

This part explains how to link your Physical Data Models to your databases,including how to generate a database from a PDM, and reverse-engineer a

PDM from a database.

Page 454: Physical Data Model - SAP
Page 455: Physical Data Model - SAP

CHAPTER 12

Generating a Database from a PDM

About this chapter This chapter explains how to connect to a database, and to generate andmodify databases via scripts or a live database connection.

Contents Topic: page

Connecting to a Database 444

Generating a Database 446

Using Test Data 480

Estimating Database Size 508

Modifying a Database 514

Accessing a Database 521

443

Page 456: Physical Data Model - SAP

Connecting to a Database

Connecting to a DatabasePowerDesigner provides various methods for connecting to your database.

Before connecting to your database for the first time, you will have toconfigure a PowerDesigner connection profile. Your choice will depend onthe interface that you have installed:

You have Configure a connection of type:

ODBC driver ODBC machine or file data source

DBMS client Native connection profile

JDBC driver JDBC connection profile

ADO.NET driver ADO.NET connection profile

OLE DB driver OLE DB connection profile

DirectConnect driver DirectConnect connection profile

+ For detailed information about creating, configuring, and usingconnection profiles, see “Connecting to a Database” in the Getting Startedwith PowerDesigner chapter of the General Features Guide .

v To connect to a database

1. Select Database ä Connect to open the Connect to a Data Sourcewindow:

2. Select one of the following radio buttons, depending on your chosen

444

Page 457: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

method for connecting to your database:♦ ODBC machine data source

♦ ODBC file data source

♦ Connection profile (for native, JDBC, ADO.NET, OLE DB orDirectConnect connections)

You can use the tools to the right of the data source field to browse to anew connection profile file or directory, and the Modify and Configurebuttons to modify or configure your data source connection.

3. Enter your user ID and password, and then click Connect. If prompted byyour database, you may need to enter additional connection parameters.

Connection timeYou stay connected until you disconnect or terminate the shell session.

Displaying information about a connected database

The extent of information available about a database depends on the DBMSand the connection profile in use.

v To display information about a connected database

1. Connect to a data source.

2. Select Database ä Connection Information.

Disconnecting from a data source

v To disconnect from a data source

1. Select Database ä Disconnect.

445

Page 458: Physical Data Model - SAP

Generating a Database

Generating a DatabaseThis section explains how to generate a database from a PDM.

PowerDesigner can generate a database creation script that you can run inyour DBMS environment or generate a database structure directly to a livedatabase connection.

v To generate a database

1. Select Database ä Generate Database to open the Database Generationdialog box (for more information, see ““Database Generation dialogGeneral tab” on page 448”).

2. Type a destination directory and a filename for the script file in theDirectory and File Name boxes.

3. Select the Script generation or Direct Generation radio button.

4. [optional] Click the Options tab, and specify creation options for yourdatabase objects (for more information, see ““Database Generationdialog Options tab” on page 451”).

5. [optional] Click the Format tab, and specify format options for yourdatabase objects (for more information, see ““Database Generationdialog Format tab” on page 464”).

6. [optional] Click the Selection tab, and specify the database objects to becreated (for more information, see ““Database Generation dialogSelection tab” on page 466”).

446

Page 459: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

7. [optional] Click the Summary tab to view the summary of your settingsand selections (for more information, see ““Database Generation dialogSummary tab” on page 467”).

8. [optional] Click the Preview tab to preview the database script to be used(for more information, see ““Database Generation dialog Preview tab” onpage 467”).

9. Click OK to begin the generation.

If you are creating a database script: The output window shows theprogress of the generation process, and indicates the syntax for runningthe script. At the end of script generation, a Result box is displayed. Itlists the file path of the generated script file. Click Edit to open the scriptin a text editor or Close to close the Result box.

If you are generating a database directly: If you are not currentlyconnected to a database, a dialog box asks you to identify a data sourceand connection parameters.

Select a machine data source or file data source, type your user ID andpassword and then click Connect. You may be prompted for additionalconnection parameters.

Advanced generation topicsAdvanced users may want to further customize database generation by,for example, customizing the order in which objects are generated, addingscripts to run before or after generation, and generating their own extendedobjects. For information on these and other advanced topics, see the DBMSReference Guide chapter in the Advanced User Documentation .

447

Page 460: Physical Data Model - SAP

Generating a Database

Database Generation dialog General tab

The General tab is the main tab for controlling database generation.

You can set the following options

Parameter Description

Directory [required] Specifies the destination directory for the scriptfile.

File name [required] Specifies the destination filename for the script file.

One file only Specifies that the generation script is created as a single file.By default, a separate script file is created for each table.

Generationtype

Specifies the type of generation to perform. You can choosebetween:♦ Script generation - generate a script to be executed on a

DBMS at a later time

♦ Direct generation – generate a script and execute it on alive database connection

Edit genera-tion script

[available only when Direct generation is selected] Opens thegeneration script in a text editor for review or editing beforeexecution on the database.

448

Page 461: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Parameter Description

Checkmodel

Specifies that a model check is performed before scriptgeneration.

Automaticarchive

Creates an archive version of the PDM after generation.

Quick launch selection and settings sets

The Quick Launch groupbox at the bottom of the General tab allows you toload pre-configured selections and settings sets for use when generating thedatabase.

Selection A selection comprises:

♦ a set of selections of database objects made on the Selection tab (see““Database Generation dialog Selection tab” on page 466”)

To save a selection, enter a name in the Selection bar at the bottom of theGeneral or Selection tab and then click Save. The selection is saved as partof the model file.

Settings set A settings set comprises:

♦ a set of options selected on the Options tab (see ““Database Generationdialog Options tab” on page 451”) and

♦ the format options specified on the Format tab (see ““DatabaseGeneration dialog Format tab” on page 464”)

v To save a settings set

1. Enter a name in the Settings set bar at the bottom of the General, Options,or Format tab and then click the Save tool.

2. When the Settings location dialog box opens, specify whether you wantto save the settings set as either:

♦ Inside the model

♦ As an external file

449

Page 462: Physical Data Model - SAP

Generating a Database

3. Click OK.

Managing settings sets You can review your settings sets at any time by clicking on the Settings SetManager tool to launch the Settings Set Manager:

The following tools are available:

Icon Use

Browse to the settings set directory.

Delete the selected settings set. Only available when an internally-saved settings set is selected. You can only delete a settings setsaved to an external file through Windows Explorer.

Export the selected settings sets to an external file. Only availablewhen an internally-saved settings set is selected.

Import the selected settings sets to inside the model. Only availablewhen an externally-saved settings set is selected.

Note that settings sets should not be copied and renamed outside ofPowerDesigner. If you want to create a variant of an existing settings set,then you should load it, make the necessary changes, and then save it under adifferent name.

450

Page 463: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Database Generation dialog Options tab

The Options tab allows you to specify what script elements to generate foreach object type.

By default, there is an entry in the left-hand pane under the meta-category“All Objects” for each object type present in your model, and all the possibleoptions are displayed in the right-hand pane. If you click on an object typein the left-hand pane, then the options are restricted to that object type.

Depending on the objects present in your model, some or all of the followingoptions will be available.

You can save your option settings via the Settings set bar at the bottom of thetab. For more information, see ““Quick launch selection and settings sets”on page 449”.

451

Page 464: Physical Data Model - SAP

Generating a Database

Database options

These options control the generation of the database.

Parameter Result of selection

Createdatabase

Generates database

Physical op-tions

Generates physical options for database

Begin script Inserts customized script before database creation

End script Inserts customized script after database creation

Opendatabase

Opens database

Closedatabase

Closes database

Dropdatabase

Deletes an existing database, before creating new database

Tablespace options

These options control the generation of tablespaces.

Parameter Result of selection

Create ta-blespace

Generates tablespaces

Begin script Inserts customized script before tablespace creation

End script Inserts customized script after tablespace creation

Comment Generates tablespace comments

Drop ta-blespace

Deletes an existing tablespace, before creating a new ta-blespace

452

Page 465: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Storage options

These options control the generation of storages.

Parameter Result of selection

Create stor-age

Generates storages

Comment Generates storage comments

Drop storage Deletes an existing storage, before creating a new storage

User options

These options control the generation of users.

Option Result of selection

Create user Generates users.

Physical op-tions

Generates physical options for users

Drop user Deletes the existing user before creating the new user.

Privilege Generates privileges for users.

Group options

These options control the generation of groups.

Option Result of selection

Create group Generates groups.

Drop group Deletes the existing group before creating the new group.

Privilege Generates privileges for groups.

Role options

These options control the generation of roles.

453

Page 466: Physical Data Model - SAP

Generating a Database

Option Result of selection

Create group Generates roles.

Drop group Deletes the existing role before creating the new role.

Privilege Generates privileges for roles.

Domain options

These options control the generation of domains/user-defined data types.

Parameter Result of selection

Create datatype

Generates user-defined data types

Default value Default value for user-defined data type

Check Generates check parameters and validation rules for user-defined data types

Comment Generates user-defined data type comments

Drop datatype

Deletes an existing user-defined data type, before creatingnew user-defined data type

Business rule options

These options control the generation of business rules.

Parameter Result of selection

Create rule Generates rules

Comment Generates rule comments

Drop rule Deletes an existing rule, before creating a new rule

454

Page 467: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Default options

These options control the generation of defaults.

Parameter Result of selection

Create de-fault

Generates default object

Comment Generates default comments

Drop default Deletes an existing default before creating a new defaultobject

If the Create and Drop check boxes are selected, the default objects will becreated/dropped before domains and tables.

+ For more information on the default generation statement, see sectionDefault in chapter DBMS Reference Guide in the Advanced UserDocumentation .

Abstract data type options

These options control the generation of abstract data types.

Parameter Result of selection

Create datatype

Defines an abstract data type which is stored on a server

Begin script Inserts customized script before data type creation

End script Inserts customized script after data type creation

Comment Generates data type comments

Drop datatype

Deletes an existing abstract data type, before defining aabstract data type

Install JAVAclass

Installs a Java class which is stored on a server

RemoveJAVA class

Deletes an existing Java class, before installing a new Javaclass

Permission Generates the permission statement for a given user duringdata type creation

455

Page 468: Physical Data Model - SAP

Generating a Database

Sequence options

These options control the generation of sequences.

Parameter Result of selection

Create se-quence

Generates sequence

Comment Generates sequence comments

Drop se-quence

Deletes an existing sequence, before creating a new sequence

Permission Generates the permission statement for a given user duringsequence creation

Creation parameters for tables & columns

These options control the generation of tables, columns, indexes, and keys.

Table options These options control the generation of tables.

Parameter Result of selection

Create table Generates tables.

Check Generates check parameters and validation rules for tables.If selected you can choose between:♦ Inside Table - checks are generated during table creation

♦ Outside - checks are generated with a separate SQL com-mand, generally using an ALTER command after the cre-ation of the table

The generation of checks outside the table is possible if theAddTableCheck entry exists in the Table category of thecurrent DBMS.

Physical op-tions

Generates physical options for tables.

Begin script Inserts customized script before table creation.

End script Inserts customized script after table creation.

Comment Generates table comments.

Permission Generates the permission statement for a given user duringtable creation.

456

Page 469: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Parameter Result of selection

Drop table Deletes the existing table before creating the new table.

Column options These options control the generation of columns.

Parameter Result of selection

User-definedtype

Generates user-defined data type for column

Default value Assigns default value to column at creation

Check Generates check parameters and validation rules for columns.If selected you can choose between:♦ Inside Table - checks are generated during table creation

♦ Outside - checks are generated with a separate SQL com-mand, generally using an ALTER command after the cre-ation of the table

The generation of checks outside the table is possible if theAddTableCheck entry exists in the Table category of thecurrent DBMS.

Comment Generates column comments

Physical op-tions

Generates physical options for column

Permission Generates the permission statement for the column duringcreation

Primary key options These options control the generation of primary keys.

Parameter Result of the selection

Create pri-mary key

Generates primary keys. If selected you can choose between:♦ Inside Table - primary keys are generated during table

creation

♦ Outside - primary keys are generated with a separate SQLcommand, generally using an ALTER command after thecreation of the table

The generation of primary keys outside the table is possibleif the Create entry exists in the PKey category of the currentDBMS.

457

Page 470: Physical Data Model - SAP

Generating a Database

Parameter Result of the selection

Physical op-tions

Generates physical options for primary keys

Comment Generates key comments

Drop primarykey

Deletes an existing primary key, before creating a newprimary key

Alternate key options These options control the generation of alternate keys.

Parameter Result of the selection

Create alter-nate key

Generates alternate keys. If selected you can choose be-tween:♦ Inside Table - alternate keys are generated during table

creation

♦ Outside - alternate keys are generated with a separateSQL command, generally using an ALTER command af-ter the creation of the table

The generation of alternate keys outside the table is possibleif the Create entry exists in the Key category of the currentDBMS.

Physical op-tions

Generates physical options for alternate keys

Comment Generates alternate key comments

Drop alter-nate key

Deletes an existing alternate key, before creating a newalternate key

Foreign keys options These options control the generation of foreign keys.

458

Page 471: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Parameter Result of selection

Create for-eign key

Generates foreign keys. If selected you can choose between:♦ Inside Table - foreign keys are generated during table cre-

ation

♦ Outside - foreign keys are generated with a separate SQLcommand, generally using an ALTER command after thecreation of the table

The generation of foreign keys outside the table is possibleif the Create entry exists in the Reference category of thecurrent DBMS.

Decl. In-tegrity

Generates declarative referential integrity for references thathave Declarative selected for referential integrity implemen-tation in the reference property sheet. You can specify anyor all of the following:♦ Update constraint restrict

♦ Update constraint cascade

♦ Update constraint set null

♦ Update constraint set default

♦ Delete constraint restrict

♦ Delete constraint cascade

♦ Delete constraint set null

♦ Delete constraint set default

Comment Generates foreign key comments

Drop foreignkey

Deletes an existing foreign key , before creating a newforeign key

Index options These options control the generation of indexes.

459

Page 472: Physical Data Model - SAP

Generating a Database

Parameter Result of selection

Create index Generates indexes. If selected you can choose between:♦ Inside Table - indexes are generated during table creationcreate table customer (

customer_id int not null,customer_name varchar(50)

)unique index CustomerIdx (customer_

id);

♦ Outside - indexes are generated with a separate SQL com-mand, generally using an ALTER command after the cre-ation of the table

create table customer (customer_id int not null,customer_name varchar(50)

);

create unique index CustomerIdx onCustomer(customer_id);

The generation of indexes outside the table is possible ifthe Create entry exists in the Index category of the currentDBMS.

Physical op-tions

Generates physical options for indexes

Comment Generates index comments

Drop index Deletes an existing index before creating a new index

Index Filter You can specify from none to all of:♦ Primary key - Generates primary key indexes

♦ Foreign key - Generates foreign key indexes

♦ Alternate key - Generates alternate key indexes

♦ Cluster - Generates cluster indexes

♦ Others - Generates indexes for all key columns with a de-fined index

Trigger options These options control the generation of triggers.

Parameter Result of selection

Create trigger Generates triggers

Drop trigger Deletes an existing trigger, before creating a new trigger

460

Page 473: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Parameter Result of selection

Comment Generates trigger comments

Trigger Filter You can specify the creation of triggers:♦ For insert

♦ For update

♦ For delete

View options

These options control the generation of views.

Parameter Result of selection

Create view Generates views

Force columnlist

Generates a view with a list of columns, even if this list isidentical to the corresponding columns in the SQL order.Allows you to generate the list of view columns with theview creation order. By default, the list of view columns isgenerated only if it is different from the list of columns ofthe view query. For example, in the following view query:select a, b from Table1

columns a and b are view columns by default. The defaultgeneration statement is:create view V1 as select a, b from

Table1

If you select the Force column list option, the generationstatement will become:create view V1(a,b) as select a, b

from Table1

Physical op-tions

Generates physical options for view

Begin script Inserts customized script before view creation

End script Inserts customized script after view creation

Drop view Deletes an existing view before creating a new view

Comment Generates view comments

461

Page 474: Physical Data Model - SAP

Generating a Database

Parameter Result of selection

Permission Generates the permission statement for the user during viewcreation

Synonym options

These options control the generation of synonyms.

Option Result of selection

Create syn-onym

Generates synonyms.

Drop syn-onym

Deletes the existing synonym before creating the new syn-onym.

Synonym Fil-ter

You can specify from none to all of:♦ Table - Generates table synonyms

♦ View - Generates view synonyms

♦ Procedure - Generates procedure synonyms

♦ Synonym - Generates synonym synonyms

♦ Database Package - Generates database package syn-onyms

♦ Sequence - Generates sequence synonyms

462

Page 475: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Join index options

These options control the generation of join indexes.

Parameter Result of selection

Create joinindex

Generates join indexes

Physical op-tions

Generates physical options for join indexes for those DBMSthat support it

Begin script Inserts customized script before join index creation

End script Inserts customized script after join index creation

Drop joinindex

Deletes an existing join index, before creating a new joinindex

Comment Generates join index comments

Procedure options

These options control the generation of procedures.

Option Result of selection

Create proce-dure

Generates procedures.

Begin script Inserts customized script before procedure creation

End script Inserts customized script after procedure creation

Drop proce-dure

Deletes the existing procedure before creating the newprocedure.

Comment Generates procedure comments

Permission Generates the permission statement for the procedure duringcreation

Database package options

These options control the generation of database packages.

463

Page 476: Physical Data Model - SAP

Generating a Database

Option Result of selection

Createdatabasepackage

Generates database packages.

Dropdatabasepackage

Deletes the existing database package before creating thenew database package.

Permission Generates the permission statement for the database packageduring creation.

Web service options

These options control the generation of web services.

Option Result of selection

Create webservice

Generates web services.

Drop webservice

Deletes the existing web service before creating the new webservice.

Permission Generates the permission statement for the web serviceduring creation.

Dimension options

These options control the generation of dimensions.

Option Result of selection

Create di-mension

Generates dimensions.

Drop dimen-sion

Deletes the existing dimension before creating the newdimension.

Permission Generates the permission statement for the dimension duringcreation.

Database Generation dialog Format tab

The options on the Format tab allow you to control the format of databasegeneration scripts.

464

Page 477: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Some of the following options may not be available, depending on yourtarget database.

You can save your format settings via the Settings set bar at the bottom ofthe tab. For more information, see “Quick launch selection and settings sets”on page 449.

Option Result of selection

Database pre-fix

Table and view names in the script are prefixed by thedatabase name.

Identifier de-limiter

Specifies the characters used to delimit identifiers (forexample, table and view names). Most DBMSs require adouble-quote character (“), but some permit other forms ofdelimiter.

Owner prefix Table and view names in the script are prefixed by theirowner names. For those DBMSs that support sequenceowners, this option will also prefix sequence names by theirowner names.

Title Each section of the script includes commentary in the formof titles (for example, Database Name: TUTORIAL).

465

Page 478: Physical Data Model - SAP

Generating a Database

Option Result of selection

Generatename inempty com-ment

For those DBMSs that support comments, this option allowsto generate the name in the comment when the commentbox is empty. This option applies to tables, columns, andviews. The comment generated using the object name willbe reversed as a comment.

Encoding Specifies an encoding format. You should select a format thatsupports the language used in your model and the databaseencoding format.

Charactercase

Specifies the case to use in the script. You can choosebetween:♦ Upper - all uppercase characters

♦ Lower - all lowercase characters

♦ Mixed - lowercase and uppercase characters

No accent Non-accented characters replace accented characters inscript

Database Generation dialog Selection tab

The Selection tab allows you to specify individual objects to generate.

By default, all the objects in the model except for those that belong to a

466

Page 479: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

package, or that are shortcuts from another model are listed and selected forgeneration.

You can save your selection via the Selection bar at the bottom of the tab.For more information, see ““Quick launch selection and settings sets” onpage 449”.

For more information about Selection windows, see the “Adding an itemfrom a selection list” section in the “Using the PowerDesigner Interface”chapter of the General Features Guide .

Database Generation dialog Summary tab

The Summary tab allows you to view a summary of your generation options.The option summary is not editable, but you can search, save, print, andcopy its contents.

Database Generation dialog Preview tab

The Preview tab allows you to view the SQL script. The script is noteditable, but you can search, save, print, and copy its contents.

467

Page 480: Physical Data Model - SAP

Generating a Database

Generating a Microsoft Access 97 database

PowerDesigner and MS Access 97 use .DAT files to exchange information.These files are created from the PDM files via the script generation. Theaccess.mdb database uses or creates .DAT files to generate or reverse Accessdatabases.

You can define the database generation parameters from the access.mdbdatabase window.

v To generate an MS Access database from a PowerDesigner PDM

1. Generate the database script from PowerDesigner.

2. Double-click access.mdb in the PowerDesigner \tools directory.

3. Select Generate Access Database from PowerDesigner Script File.

4. Type the destination database in the Select Database box.

5. Type the file created by PowerDesigner in the PowerDesigner File.

6. Click on the Create button.

Configuring tablespaces and storages

Tablespaces and storages are generic objects used to represent the physicallocation (in a named partition) of tables and indexes in a database or storagedevice:

468

Page 481: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

♦ a tablespace is a partition in a database

♦ a storage is a partition on a storage device

For some DBMSs, a tablespace can use a specified storage in its definition.

The following table lists the DBMSs that support tablespaces and storages,explains which concept they represent and indicates the commands thatimplement PowerDesigner tablespace and storage options:

DBMS Tablespace represents. . . Storage represents. . .

ADABAS NA NA

IBM DB2 UDBCommon Server

tablespacecreate tablespace

buffer poolcreate bufferpool

IBM DB2 UDBfor OS/390

table spacecreate tablespace

storage groupcreate stogroup

Informix NA NA

Ingres NA NA

InterBase NA NA

Microsoft Access NA NA

Microsoft SQLServer

NA filegroupalter database add filegroup...

MySQL NA NA

Oracle tablespacecreate tablespace

storage structure (notphysical storage)

PostgreSQL NA NA

Sybase ASA database spacecreate dbspace

NA

Sybase ASE NA segmentsp-addsegment

Sybase AS IQ database spacecreate dbspace

NA

469

Page 482: Physical Data Model - SAP

Generating a Database

DBMS Tablespace represents. . . Storage represents. . .

Teradata NA NA

Tablespace or storage not applicableWhen tablespace or storage options are not applicable for a DBMS, thecorresponding model menu item is grayed.

Creating a tablespace or storage

The lists of tablespace and storage options offer pre-defined parameters foreach DBMS where applicable. The lists show default values and value listsfor certain parameters which correspond to the recommended values for theDBMS.

+ For more information on tablespace and storage options for a particularDBMS, see its reference manual.

v To create a tablespace or storage

1. Select Model ä Tablespaces or Model ä Storages to open the List ofTablespaces or List of Storages.

2. Click the Add a Row tool to create a tablespace or storage and then clickthe Properties tool to open its property sheet.

3. Click the Physical Options tab, and select and set the necessary physicaloptions:

470

Page 483: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Simplified Physical Option tabsPowerDesigner offers simplified physical option tabs for some DBMSs.Consequently you may have the option of choosing between the PhysicalOptions (Common) and Physical Options (All) tabs.

For more information, see “Physical Options” in the Building PhysicalDiagrams chapter.

4. [optional] Click the Preview tab to review the SQL code to be generatedfor the tablespace or storage.

471

Page 484: Physical Data Model - SAP

Generating a Database

5. Click OK.

The selected options appear in Options column of the List of Tablespacesor List of Storages.

Customizing scripts

You can customize scripts as follows:

♦ Insert scripts at the beginning and end of database creation script

♦ Insert scripts before and after a table creation command

Customizing a creation script allows you to add descriptive informationabout a generated script, or manipulate the script in such a way that is notprovided by PowerDesigner.

Examples If a development project archives all the database creation scripts that aregenerated, a header script can be inserted before each creation script, whichmay indicate the date, time, and any other information specific to thegenerated script.

If an organization requires that generated scripts are filed using a namingsystem which may be independent from a script name, a header script coulddirect a generated script to be filed under a different name than the nameindicated in the creation script.

472

Page 485: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Access rights can be added as a footer to a table creation script.

Script toolbar properties

You can use the following tools and keyboard shortcut from the scripttoolbar:

Tool Description Keyboard shortcut

Editor context menu SHIFT + F11

Edit With. Opens the default editor youpreviously defined

CTRL + E

+ For more information on defining a default editor, see section Defining atext editor in the General Features Guide .

Inserting begin and end scripts for database creation

In a database creation script, you can insert the following scripts:

Script Where it is inserted

Begin script Before the command that creates the database

End script After the last command in the database creation script

You can use the following variables in these scripts:

Variable Description

%DATABASE% Name of the current PDM

%DATE% Date of script generation

%DBMSNAME% Name of the DBMS for the target database

%NAMESCRIPT% Filename of script file

%PATHSCRIPT% Filename and path of script file

%STARTCMD% Command that runs the script

%AUTHOR% Author of the current model

473

Page 486: Physical Data Model - SAP

Generating a Database

v To insert begin and end scripts for database creation

1. Select Model ä Model Properties.

or

Right click the diagram background.

Select Properties from the contextual menu.

The model property sheet is displayed.

2. Click the Create tool next to the Database box.

A confirmation box is displayed asking you to commit the creation of thedatabase script object.

3. Click Yes.

The database property sheet is displayed.

474

Page 487: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

4. Type a name and code for the database.

5. Click the Script tab.

The Script tab opens to the Begin tab.

6. Type the DBMS-specific commands to insert in the beginning of thescript.

7. Click the End tab at the bottom of the tab.

8. Type the DBMS-specific commands to insert at the end of the script.

9. Click OK in each of the dialog boxes.

Inserting begin and end scripts for table creation

For each table, you have the option to insert the following scripts:

Script Where it is inserted

Begin script Immediately before the table creation command (after thetable title)

End script Immediately after the table creation command

These scripts can appear in database creation scripts and databasemodification scripts.

475

Page 488: Physical Data Model - SAP

Generating a Database

You can use the following variables in these scripts:

Variable Description

%COLNLIST% Column list

%DATABASE% Code of the current PDM

%DATE% Date of script generation

%DBMSNAME% Code of the DBMS for the target database

%NAMESCRIPT% Filename of script file

%OWNER% Table owner

%OWNERPREFIX% Owner prefix of table owner

%PATHSCRIPT% Filename and path of script file

%STARTCMD% Command that runs the script

%TABLE% Name or code of current table (based on displaypreferences)

%TCODE% Code of the current table

%TLABL% Label of the current table

%TNAME% Name of the current table

%AUTHOR% Author of the current model

v To insert begin and end scripts for table creation

1. Double-click a table symbol.

The table property sheet is displayed.

2. Click the Script tab.

The Script tab opens to the Begin tab.

3. Type the DBMS-specific commands to insert in the beginning of thescript.

4. Click the End tab at the bottom of the tab.

5. Type the DBMS-specific commands to insert at the end of the script.

6. Click OK.

476

Page 489: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Inserting begin and end script for tablespace creation

For each tablespace, you have the option to insert the following scripts:

Script Where it is inserted

Begin script Immediately before the tablespace creation command (afterthe table title)

End script Immediately after the tablespace creation command

These scripts can appear in database creation scripts and databasemodification scripts.

You can use the following variables in these scripts:

Variable Description

%DATABASE% Code of the current PDM

%DATE% Date of script generation

%DBMSNAME% Code of the DBMS for the target database

%NAMESCRIPT% Filename of script file

%PATHSCRIPT% Filename and path of script file

%STARTCMD% Command that runs the script

%TABLESPACE% Code of the tablespace

%OPTIONS% Physical options of the tablespace

%AUTHOR% Author of the current model

v To insert begin and end scripts for tablespace creation

1. Double-click a tablespace in the list of tablespace.

The tablespace property sheet is displayed.

2. Click the Script tab.

The Script tab opens to the Begin tab.

3. Type the DBMS-specific commands to insert in the beginning of thescript.

4. Click the End tab at the bottom of the tab.

477

Page 490: Physical Data Model - SAP

Generating a Database

5. Type the DBMS-specific commands to insert at the end of the script.

6. Click OK.

Formatting variables in customized scripts

Variables have a syntax that can force a format on their values. Typical usesare as follows:

♦ Force values to lowercase or uppercase characters

♦ Truncate the length of values

♦ Enquote text

You embed formatting options in variable syntax as follows:

%[[?][-][width][.[-]precision][c][H][F][U|L][T][M][q][Q]:]<varname>%

The variable formatting options are the following:

Format option Description

? Mandatory field, if a null value is returned the translatecall fails

n (where n is aninteger)

Blanks or zeros added to the left to fill the width andjustify the output to the right

-n Blanks or zeros added to the right to fill the width andjustify the output to the left

width Copies the specified minimum number of characters tothe output buffer

.[-]precision Copies the specified maximum number of characters tothe output buffer

.L Lower-case characters

.U Upper-case characters

.F Combined with L and U, applies conversion to firstcharacter

.T Leading and trailing white space trimmed from thevariable

.H Converts number to hexadecimal

.c Upper-case first letter and lower-case next letters

478

Page 491: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Format option Description

.n Truncates to n first characters

.-n Truncates to n last characters

M Extracts a portion of the variable name, this option usesthe width and precision parameters to identify the portionto extract

q Enquotes the variable (single quotes)

Q Enquotes the variable (double quotes)

+ For more examples on variable formatting, see section Defining variableformatting options in chapter DBMS Reference Guide in the Advanced UserDocumentation .

479

Page 492: Physical Data Model - SAP

Using Test Data

Using Test DataTest data is sample data that you can define and generate for one or moretables in a PDM. When you generate test data, PowerDesigner automaticallygenerates rows of data in database tables.

You normally use test data to verify the performance of a database that isbeing developed. You can use test data to do the following:

♦ Verify the performance of the database when it is filled with largeamounts of data

♦ Verify the performance of the database when it is accessed by differentapplications or users

♦ Verify the operational performance of the database when it is accessed bydifferent applications or users

♦ Estimate the amount of memory space the database will take up

♦ Examine data formatting in the database

You can generate test data for selected tables in a PDM, or for all the tablesin a PDM.

You can add test data to an empty database or to a database that alreadycontains data.

Test Data profile You generate test data for a table based on test data profiles. A test dataprofile is a named class of data types that has a defined data generationsource. A test data profile can be assigned to one or more columns.

When you assign a test data profile to a column, it acts as a representative forthe data type of that column. Test data for the column is then generatedusing the data profile and its defined data source.

You can also select a test data profile to apply to a domain. You can thenchoose to have the profile automatically assigned to all columns that use thatdomain.

A test data profile can use one of the following:

♦ Number

♦ Character

♦ Date/Time

Example For a column named Employee Location, you create a test data profilenamed Address using the Character class. You then define a test data source

480

Page 493: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

for Address. You can also assign it to other columns, such as Store Location,and Client Address.

Default test data profiles If you do not assign a test data profile for a column, a default test data profileis assigned to the column when you generate test data for the table. Youdefine default test data profiles for each class used to generate test data.

Test data restrictions The following objects are not taken into account when you generate test data:

♦ Alternate keys

♦ Foreign keys

♦ Business and validation rules

♦ Binary, sequential, OLE, text or image data types

♦ Trigger contents

v To set up a test data profile

1. Create a test data profile for one or more columns.

2. Define a test data generation source for each data profile.

3. Define column fill parameters for columns that need to be populated withdata in a particular way.

4. Assign test data profiles to all relevant columns.

5. Use the test data profiles to generate test data.

Creating a test data profile

When you create a test data profile you need to define the followingproperties:

Property Description

Name Name of the profile

Code Code of the data profile

Profile class You can assign one of the following data type classes:

Number

Character

Date/Time

481

Page 494: Physical Data Model - SAP

Using Test Data

When you define the profile class, make sure it reflects the DBMSlimitations, for example, someDBMS do not support dates prior to a certaindate.

Generation source You define a test data generation source for each data profile. You can usethe following test data generation sources:

Generation source Test data values are generated

Automatic By PowerDesigner

List From a list of test data values

Direct From a live database connection

File From a source file

Each data generation source has its own set of options for defininggeneration parameters.

v To create a test data profile

1. Select Model ä Test Data Profiles.

The List of Test Data Profiles is displayed.

2. Click a blank line in the list.

3. Type a test data Profile name and a profile code.

4. Select a data type class from the Profile Class list.

Display the column you needIf you do not see the column you need, display it with the CustomizeColumns and Filter tool. For details, see the General Features Guide .

482

Page 495: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

5. Click Apply.

6. Double-click the new profile to display its property sheet.

7. Define generation source parameters.

8. Click OK in each of the dialog boxes.

Automatic test data generation source parameters

There are different automatic test data generation source parameters for eachprofile class.

Defining an automatic test data generation source for numbers

You have the following options to define generation source parameters forthe profile class Number:

Option Description

Random Indicates to generate random data

Sequential Indicates to generate sequential data

From/To Indicates the range for random or sequential data

Step Indicates interval between each sequential number step

Generate deci-mal numbers

Generates decimal numbers

Decimal digitsnumber

Indicates the maximum number of decimal places to begenerated

483

Page 496: Physical Data Model - SAP

Using Test Data

v To define an automatic data generation source

1. Select Model ä Test Data Profiles.

The List of Test Data Profiles is displayed.

2. Double-click a test data profile using numbers.

The Profile properties sheet opens to the General tab.

3. Select the Automatic radio button.

4. Click the Detail tab.

484

Page 497: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

The Detail tab is displayed.

5. Specify test data generation parameters.

6. Click OK in each of the dialog boxes.

Defining an automatic test data generation source for characters

You have the following options to define generation source parameters forthe profile class Character:

Option Parameter Description

Verify Valid characters List of authorized characters

All Accepts all characters

Invalid characters List of unauthorized characters

No accents Replaces accents with unaccented char-acters

Mask String of mask characters.

Case Upper

First uppercase

Lower

Mixed

Indicates authorized letter cases

485

Page 498: Physical Data Model - SAP

Using Test Data

Option Parameter Description

Length Exact You indicate exact character length

From/To You indicate character length range

Character selection You can specify valid characters to accept and invalid characters to refuse.You use a comma ( , ) to separate each single character, character interval, orstring.

The following syntax applies to valid and invalid characters.

Character set Syntax Example

Interval of charac-ters

Characters in single quotationmarks separated by a dash ’a’-’z’

Single character orCharacter string

Characters in quotation marks

"a" | "xyz"

Mask characters A mask character is a pre-defined character that indicates to users that theyneed to type a particular piece of information. The test data that is generatedrespects the following mask characters:

Maskcharacter

Prompts to type

A Letter

9 Number

? Any character

486

Page 499: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

v To define an automatic data generation source

1. Select Model ä Test Data Profiles.

The List of Test Data Profiles is displayed.

2. Double-click a test data profile using characters.

The Profile properties sheet opens to the General tab.

3. Select the Automatic radio button.

4. Click the Detail tab.

487

Page 500: Physical Data Model - SAP

Using Test Data

The Detail tab is displayed.

5. Specify test data generation parameters.

6. Click OK in each of the dialog boxes.

Defining an automatic test data generation source for date and time

You can define the following generation source parameters for the profileclass Date/Time:

Value Parameter Description

Date range From/To Indicates range of date values

Time range From/To Indicates range of time values

Step Date/Time step Indicates date and time intervals for sequen-tial data values.

Values Random Indicates to generate random data

Sequential Indicates to generate sequential data

488

Page 501: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

v To define an automatic data generation source

1. Select Model ä Test Data Profiles.

The List of Test Data Profiles is displayed.

2. Double-click a data profile using date and time.

The Profile properties sheet opens to the General tab.

3. Select the Automatic radio button.

4. Click the Detail tab.

489

Page 502: Physical Data Model - SAP

Using Test Data

The Detail tab is displayed.

5. Specify test data generation parameters.

6. Click OK in each of the dialog boxes.

Defining a list as a test data generation source

You can use information from a list to define a test data generation sourcefor a data profile.

v To define a list as a test data generation source

1. Select Model ä Test Data Profiles.

The List of Test Data Profiles is displayed.

2. Double-click a data profile.

The Profile properties sheet opens to the General tab.

3. Select the List radio button.

4. Click the Detail tab.

The Detail tab is displayed.

5. Select a Value profile.

490

Page 503: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

6. Type a value and label.

7. Click OK in each of the dialog boxes.

Defining a live database connection as a test data generation source

You can use information from a live database connection to define a test datageneration source for a data profile.

v To define a database as a test data generation source

1. Select Model ä Test Data Profiles to open the List of Test Data Profiles.

2. Double-click a data profile to open its property sheet.

3. Select the Database Generation radio button, and then click the Detail tab.

4. Click the Select a data source tool beside the Data source box and select amachine or file data source. For more information, see the Connecting toa Database chapter in the General Features Guide .

5. Type the login and password corresponding to your data source.

6. Type the name of the table and column to query in the data source.

The variables in the default query are replaced by the table and columnvalues.

491

Page 504: Physical Data Model - SAP

Using Test Data

You can also type a user-defined query in the Query box. Theuser-defined button indicates when the default query has been modified.You can click this button to recover the default query.

7. Click OK.

You return to the List of Test Data Profiles.

8. Click OK.

Defining a file as a test data generation source

You can import a CSV file to define a data generation source for a dataprofile. You can define the following generation source parameters for theCSV file:

Value Parameter Description

Values Random Indicates to import file lines in random order

Sequential Indicates to import file lines sequentially

CSV import restriction Each CSV file that you import for each data profile must come from thesame directory. If you have not previously used this directory as a CSV filetest data source, you will need to select the correct directory to define the filepath.

492

Page 505: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Example test data filesPowerDesigner provides example test data files in the \TESTDATA direc-tory.

v To define a file as a test data generation source

1. Select Model ä Test Data Profiles.

The List of Test Data Profiles is displayed.

2. Double-click a data profile.

The Profile properties sheet opens to the General tab.

3. Select the File radio button.

4. Click the Detail tab.

The Detail tab is displayed.

A dialog box asks you to select a file.

Specifying the CSV directoryIf you are importing a CSV file for the first time from a specificdirectory, you need to select the appropriate directory.

5. Select a file and click Open.

You return to the Detail tab.

493

Page 506: Physical Data Model - SAP

Using Test Data

6. Specify test generation parameters.

7. Click OK.

You return to the List of Test Data Profiles.

8. Click OK.

Defining column fill parameters

Fill parameters determine how a column is filled or populated with testdata. You can define column fill parameters when you assign a data profile tothe column, or as an independent procedure.

You can define the following fill parameters:

Value Description

Null values Percentage of column entries containing a null value

Distinct values Indication of the percentage of column rows that containunique entries. This is a maximum value, and can changeautomatically depending on the referential integrity param-eters of primary key columns. Alternately, a specific valuecan be entered, without a percentage sign, to indicate theexact number of column rows that contain unique entries.

Average LengthThe Average Length box is only used for the Estimate data base sizefunction. The value that is displayed by default, is the maximum length forthe data type defined for a selected column.

Indicated columnproperties

The following column properties are indicated on the Columns sheet:

Indicator Property When selected, indicates that. . .

M Mandatory Column must be assigned a value. The fillparameter Null value is automatically defined as0%

U Unique col-umn

Column is the only column in a primary key, al-ternate key, or unique index. The fill parametersNull Values and Distinct Values are automati-cally defined as 0% and 100% respectively

F Foreign Column is a foreign key column. You cannotassign a data profile to this column. It automati-cally takes the data profile of the correspondingprimary key column in the parent table

494

Page 507: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

v To define column fill parameters

1. Select Model ä Tables.

The List of tables is displayed.

2. Double-click a table from the list.

The Profile properties sheet opens to the General tab.

3. Select the Columns tab.

The Columns tab is displayed.

495

Page 508: Physical Data Model - SAP

Using Test Data

4. Double-click a column name.

The Column properties dialog box is displayed.

5. Select the Detail tab.

The Detail tab is displayed.

6. Select or type Column fill parameters.

7. Select a profile from the test data parameters dropdown list box.

8. Click OK in each dialog box.

You return to the Columns tab.

9. Click OK.

Assigning a data profile

When you assign a data profile to a column, the data profile defines the typeof test data that you generate for that column.

You can assign a data profile to each column in a table, except for the foreignkey columns. The data profiles for foreign keys are assigned by default.

When you assign a data profile to a column that contains check parameters,the generated test data respects the column constraints.

496

Page 509: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

There are three approaches to assigning data profiles:

♦ Assign a data profile from the list of tables

♦ Assign a data profile from the list of columns

♦ Select a data profile for a domain, so that all columns attached to thatdomain are automatically assigned the data profile.

+ For more information on how to select a data profile for a domain, seechapter Building Physical Diagrams.

Assigning a data profile from the list of tables

v To assign a data profile from the list of tables

1. Select Model ä Tables.

The List of tables is displayed.

2. Double-click a table in the list.

The table property sheet opens to the General tab.

3. Select the Columns tab.

The Columns tab is displayed.

497

Page 510: Physical Data Model - SAP

Using Test Data

4. Select a column in the list.

5. Select a test data profile from the dropdown list box.

Display the column you needIf you do not see the column you need, display it with the CustomizeColumns and Filter tool. For details, see the General Features Guide .

6. Click OK.

Assigning a data profile from the list of columns

498

Page 511: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

v To assign a data profile from the list of columns

1. Select Model ä Columns.

The List of Columns is displayed.

2. Select a column in the list.

3. Select a test data profile from the dropdown list box.

Display the column you needIf you do not see the column you need, display it with the CustomizeColumns and Filter tool. For details, see the General Features Guide .

4. Click OK.

Importing a data profile

You can import data profiles in XPF format from another PDM. Theimported profiles appear in the list of profiles.

v To import a data profile

1. Select Tools ä Test Data Profiles ä Import.

A standard Open dialog box is displayed.

2. Browse to the EXAMPLES/TUTORIAL directory.

3. Select or type a file name with the XPF extension.

499

Page 512: Physical Data Model - SAP

Using Test Data

4. Click Open.

Exporting a data profile

You can export data profiles to a XPF file. In another PDM, you can thenimport the data profiles defined in this XPF file.

v To export a data profile

1. Select Tools ä Test Data Profiles ä Export.

A Selection dialog box is displayed.

2. Select one or more data profiles that you want to export.

3. Click OK.

A dialog box is displayed.

4. Type a file name with the XPF extension.

500

Page 513: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

5. Click Save.

Generating test data

You can generate test data for all the tables in a PDM, or for selected tables.

You can generate data for either an empty database or for an existingdatabase.

Avoid generating triggersDo not implement triggers if you generate a new database. It is alsorecommended that you remove triggers from an existing test database.Triggers can considerably increase the time required to generate thedatabase and can block insertions. In addition, they are not needed for thetype of test we are performing.

v To generate test data

1. Assign data profiles to the columns in each table for which you want togenerate test data (see ““Assigning a data profile” on page 496”).

Default values for data profilesTest data generation is typically based on user-defined data profiles.If you have no data profile definitions, you are automatically providedwith default values. The default number of rows is set to 20 and thevalue <default> is displayed in each of the following three defaultprofile boxes.

2. Select Database ä Generate Test Data to open the Test Data Generationdialog box.

501

Page 514: Physical Data Model - SAP

Using Test Data

3. Specify a directory and filename for your test data file, and then choosebetween Script and Direct generation. For more information, see “TestData Generation General tab” on page 502.

4. [optional] To change the number of rows to be generated for specifictables, click the Number of Rows tab. For more information, see “TestData Generation Number of Rows tab” on page 504.

5. [optional] To modify script formatting options, click the Format tab. Formore information, see “Test Data Generation Format tab” on page 505.

6. [optional] To control which tables will have test data generated, click theSelection tab. For more information, see ““Test Data GenerationSelection tab” on page 507”.

7. Click OK to start the generation.

If you are generating a test data script : then a Result dialog box asksyou if you want to Edit or Close the newly generated file.

If you are generating test data to a live database connection , then aConnect to a Data Source dialog box opens.

Select a data source, and then click Connect.

A message in the Output window indicates that the test data generation iscompleted.

Test Data Generation General tab

The General tab allows you to set general generation options.

502

Page 515: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

The following options are available on this tab:

Option Result of selection

Directory Specifies the directory in which the file will besaved.

File name Specifies the name of the file.

Select the One file only checkbox to specify thatonly a single file can be generated.

Generation type Specifies how the test data will be generated. Thefollowing settings are available:♦ Script generation - in DBMS-specific syntax

♦ Direct generation – to a live database connec-tion

♦ Data file – as a set of values in a file

503

Page 516: Physical Data Model - SAP

Using Test Data

Option Result of selection

Commit mode Specifies when the data will be committed. Thefollowing settings are available:♦ Auto - automatically during script generation

♦ At end - at end of script generation

♦ By packet - at defined intervals during scriptgeneration

Data file format For use with the data file option. The followingsettings are available:♦ CSV – comma-separated values

♦ Custom delimiter – specify a custom delimiter

Delete old data Deletes existing data before generating new data..

Check model Checks the PDM before generating the testdatabase or script, and stops generation if anerror is found.

Automatic archive Creates an archive of any previous test data.

Default number of rows Specifies the default number of rows for table

Default number profile Specifies the default number profile for table

Default character profile Specifies the default character profile for table

Default date profile Specifies the default date profile for table

Test Data Generation Number of Rows tab

The Number of Rows tab allows you to specify the number of rows of testdata to generate. Enter the required number in the Test Number column.

504

Page 517: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Test Data Generation Format tab

The Format tab allows you to set script format options.

505

Page 518: Physical Data Model - SAP

Using Test Data

The following options are available on this tab:

Option Result of selection

Owner prefix Specifies that an owner prefix is added.

Titles Specifies that each section of the script includes commen-tary in the form of titles.

Encoding Specifies the encoding format to use for test data genera-tion. You should select the encoding format that supportsthe language used in your model and the database encod-ing format.

Character case Specifies the character case to use. The following settingsare available:♦ Upper - all uppercase characters

♦ Lower - all lowercase characters

♦ Mixed - both uppercase and lowercase characters

No accent Non-accented characters replace accented characters inscript.

506

Page 519: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Test Data Generation Selection tab

The Selection tab allows you to specify tables for which test data will begenerated.

+ For more information on selection windows, see the “Adding an itemfrom a selection list” section in the Using the PowerDesigner Interfacechapter in the General Features Guide.

507

Page 520: Physical Data Model - SAP

Estimating Database Size

Estimating Database SizeYou can estimate the size of a database for all the tables in the model or foronly selected tables throughout the model.

Basis of calculation You obtain an estimate based on the following elements:

♦ Estimated number of records in tables

♦ Columns in each table

♦ Indexes in the model

♦ Tablespaces in the model

♦ Database storage options

Estimation depends on parameters like DBMS type, physical options,column data types, indexes and keys. The estimation formula used in thisfeature proceeds from the DBMS documentation.

Records in tablesYou indicate a number of records in each table in your model.

Columns The estimated database size for a column is based on the following:

♦ Size of fixed length data types

♦ Average size of variable length data types

Indexes The estimate of the database size includes all indexes including primary keyindexes, foreign key indexes, alternate key indexes and database-specificindexes such as IQ join indexes.

Automatic index constraintsThe automatic indexing of keys is DBMS specific. If the target databasesupports the automatic indexing of keys, the resulting database size estima-tion includes these indexes.

Tablespace size The size of a tablespace associated with a table is estimated by default, andis displayed as a total of the following:

♦ All tables in the tablespace

♦ All indexes in the tablespace

+ For more information on how to associate a tablespace with an index ortable, see section Creating an Index in chapter Building Physical Diagrams.

508

Page 521: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Storage options Data storage options are DBMS specific. You define data storage optionssupported by the target database. These are included in the estimate ofdatabase size.

Indicating the number of records in a table

Before you estimate database size, you indicate the number of records ineach table that you generate.

v To indicate the number of records in a table

1. Select Model ä Tables.

The List of Tables is displayed.

2. Display the Test Number column.

Display the column you needIf you do not see the column you need, display it with the CustomizeColumns and Filter tool. For details, see the General Features Guide .

3. Type a value in the Test Number column for the table that requires anindication of the number of records.

509

Page 522: Physical Data Model - SAP

Estimating Database Size

4. Click OK.

Indicating average data type length

You can indicate the estimated average data type length for variable lengthdata types. This average length value is then used instead of the maximumdata type length when you estimate database size.

Average size must be carefully selectedThe average length value is particularly important for strings or long binarydata types. A Binary Long OBject (BLOB) such as a picture can representthe largest portion of the space actually taken by a table.

v To indicate average data type length

1. Select Model ä Tables.

The List of Tables is displayed.

2. Double-click a table name.

The Table Properties sheet opens to the General tab.

3. Click the Columns tab.

The Columns tab is displayed.

4. Double-click a column that uses a data type with variable length.

The Column Properties sheet opens to the General tab.

5. Click the Detail tab.

The Detail tab is displayed.

510

Page 523: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

6. Type a value in the Average length box.

7. Click OK in each of the dialog boxes.

Estimating the database size of a model

You can estimate the database size of all the tables in the model.

511

Page 524: Physical Data Model - SAP

Estimating Database Size

v To estimate the database size of all the tables in the model

1. Select Database ä Estimate Database Size.

The Database Size Estimation dialog box is displayed.

2. Click the Include Sub-Packages button.

3. Select all the tables from the list.

4. Click OK.

The output list displays the estimated database size.

Estimating the database size of selected tables

You can estimate the database size of selected tables in the model.

v To estimate the database size of selected tables in the model

1. Select Database ä Estimate Database Size.

The Database Size Estimation dialog box is displayed.

2. Select a package from the list.

The list of tables in the currently selected package is displayed.

3. Select one or more tables from the list.

512

Page 525: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

4. If required, repeat steps 2 and 3 until all the tables of interest have beenselected throughout the model.

5. Click OK.

A confirmation box is displayed asking if you want to keep all previouslyselected objects in the database size estimate.

6. Click OK.

The output list displays the estimated database size.

513

Page 526: Physical Data Model - SAP

Modifying a Database

Modifying a DatabaseYou can modify an existing database schema by synchronizing it with yourmodel. The existing schema can be in the form of:

♦ an archive model

♦ a live database connection

♦ a script file

♦ a model from the repository

The PDM (source model) and the existing database schema (target model)are merged using a database synchronization window, which allows you tochoose which objects are added, deleted, or updated in the target.

v To modify a database

1. Select Database ä Modify Database to open the Modify Database dialogbox.

2. Type a destination directory and filename for the script file in theDirectory and File Name boxes.

3. Specify the type of generation to perform. You can choose between ascript and a live database connection.

4. Specify how PowerDesigner will obtain the database schema to modify.You can choose between:

♦ Using an archive model – Click the button to the right to browse to thearchived model.

♦ Using a data source – Click the button to the right to connect to yourdata source.

♦ Using a script file – Select a script from the list or click the button tothe right to browse to the script.

♦ Using a model from repository – Click the Change Model Version toolto the right to browse to a version of the currently selected model.

5. If you want to retain your existing data, select the Backup Tables option.If this option is not selected, then all existing data will be erased. Fordetails of this and other options on this tab, see ““Modify Database dialogGeneral tab” on page 516”.

6. [optional] If you want to change the default generation options, then clickthe Options tab. For more information about these options, see ““ModifyDatabase dialog Options tab” on page 518”.

514

Page 527: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

7. [optional] If you want to change the format of your script, then click theFormat tab. This tab has the same functionality as in the DatabaseGeneration window (see ““Database Generation dialog Format tab” onpage 464”).

8. [optional] If you want to control which database objects will be modified,then click the Selection tab. This tab has the same functionality as in theDatabase Generation window (see ““Database Generation dialogSelection tab” on page 466”)

9. Click OK. If you are using a live database connection, then the ReverseEngineering window will open, allowing you to select or clear checkboxes in the target model for objects that you want to include or removefrom the source model. Make your selections and then click OK tocontinue.

10. The Database Synchronization window will open. Select or clear checkboxes in the target model for objects that you want to include or removefrom the model.

+ For more information on comparing and merging models, see chapterComparing and Merging Models in the General Features Guide .

11. Click OK.♦ If you are generating a script, at the end of generation a result box

opens listing the file path of the generated file. To open the script in atext editor, click the file in the result box and click the Edit button. Toclose the Result box, click the Close button.

515

Page 528: Physical Data Model - SAP

Modifying a Database

♦ If you are generating a database directly, a Data Source connection boxis displayed. Type your connection details and click the Connectbutton. A message box shows the progress of the generation process.At the end of generation click OK to close the box.

Modify Database options

The following sections give detailed information about the various optionsthat you can use to control database modification.

Modify Database dialog General tab

This tab controls the main options for database modification.

You can set the following options:

Option Description

Directory [required] Specifies the destination directory for thescript file.

516

Page 529: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Option Description

File name [required] Specifies the destination filename for thescript file.

One file only Specifies that the generation script is created as a singlefile. By default, a separate script file is created for eachtable.

Generation Type Specifies the type of generation to perform. You canchoose between:♦ Script generation - generate a script to be executed

on a DBMS at a later time

♦ Direct generation – generate a script and execute iton a live database connection

Edit generationscript

[available only when direct generation is selected]Opens the generation script in a text editor for review orediting before execution on a live database connection.

Obtains databaseschema

Select the kind of schema that the model will modify.You can choose between:♦ Using an archive model - Modified PDM is merged

with an archived PDM.

♦ Using a data source - Modified PDM is mergedwith a reverse engineered database schema for a livedatabase connection.

♦ Using a script file - Modified PDM script file ismerged with an existing database script file.

♦ Using a model from repository - Modified PDM ismerged with a selected version of a PDM consoli-dated in the repository.

Backup tables Specifies that any existing table will be copied totemporary backup tables during the modification, andthen restored to the updated tables. If this option is notselected, then all existing data will be erased.

Always use createstatements/

Use alter state-ments when possi-ble

Select a radio button to specify whether create state-ments should always be used to modify database tables,or whether alter statements should be used where pos-sible

517

Page 530: Physical Data Model - SAP

Modifying a Database

Option Description

Drop temporarytables

[available only when Backup Tables is selected] Speci-fies that the temporary backup tables are removed afterscript execution.

Use physical op-tions for temporarytables

[available only when Backup Tables is selected] Spec-ifies that the temporary backup tables are generatedwith their physical options.

Check model Specifies that a model check is performed before scriptgeneration.

Automatic archive Creates an archive version of the PDM after generation.

You can load option settings previously used for database generation via theSettings set bar at the bottom of the tab. For more information, see ““Quicklaunch selection and settings sets” on page 449”.

Modify Database dialog Options tab

This tab controls certain script options.

518

Page 531: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

These options are dependent on the selected DBMS and certain of them maybe unavailable.

Option Result of selection

Inside/

Outside

Specifies whether and where various constraints will be gen-erated. Note that if alter statements are used to modify tables,then constraints may be generated outside the table even if theinside radio button is selected here.

Index Fil-ter

Specifies which kinds of indexes to generate.

Comment Specifies whether comments are generated.

You can load option settings previously used for database generation via theSettings set bar at the bottom of the tab. For more information, see ““Quicklaunch selection and settings sets” on page 449”.

Modify Database dialog Format tab

This tab controls the format of your modification script. It has the same

519

Page 532: Physical Data Model - SAP

Modifying a Database

functionality as the equivalent tab in Database Generation (see ““DatabaseGeneration dialog Format tab” on page 464”).

Modify Database dialog Selection tab

The Selection tab allows you to specify individual objects to generate. It hasthe same functionality as the equivalent tab in Database Generation (see““Database Generation dialog Selection tab” on page 466”).

520

Page 533: Physical Data Model - SAP

Chapter 12. Generating a Database from a PDM

Accessing a DatabasePowerDesigner allows you to display data from the database thatcorresponds to your model, and to send SQL queries to a connected datasource.

Displaying data from a database

If the database corresponding to the PDM already exists, you can display thedata that corresponds to a table, view, or reference in the PDM.

v To display data from a connected database

1. Right-click a table, view, or reference.

A contextual menu is displayed.

2. Select View Data from the contextual menu.

A dialog box asks you to identify a data source and connectionparameters.

3. Select the Machine data source radio button.

Select a data source from the list.

or

Select the File data source radio button.

Browse to the directory containing the .DSN file.

Select the .DSN file.

521

Page 534: Physical Data Model - SAP

Accessing a Database

4. Type your user ID and password.

5. Click Connect and, if prompted by your data source, type additionalconnection parameters.

A Query Results windows list all the database records corresponding tothe selected table, view, or reference.

6. Click the Close button.

Executing SQL queries

You can send SQL queries to a database and display the results.

v To execute a SQL query

1. Select Database ä Execute SQL. If you are not already connected to adatabase, the Connect to Data Source window will open. Choose yourconnection profile and click Connect to proceed to the Execute SQLQuery dialog.

2. Type one or more SQL statements in the window, and click Run to applythem to the database.

The query results are displayed in the Results window.

522

Page 535: Physical Data Model - SAP

CHAPTER 13

Reverse Engineering a Database into aPDM

About this chapter This chapter describes how to reverse engineer database objects into a PDM.

Contents Topic: page

Getting Started with Reverse Engineering 524

Reverse Engineering from Scripts 525

Reverse Engineering from a Live Database 528

Reverse Engineering Options 532

Reverse Engineering Database Statistics 541

523

Page 536: Physical Data Model - SAP

Getting Started with Reverse Engineering

Getting Started with Reverse EngineeringReverse engineering is the process of generating a PDM (or certain PDMobjects) from an existing database schema. You can reverse engineer anexisting database schema into a new PDM or into an existing PDM.

There are two ways to reverse engineer a PDM from a database schema:

Generateusing

Description

Script file The script will normally be the script used to generate thedatabase but can also include other scripts.

If you use more than one script files, make sure that the orderof the files respects dependencies among objects (for example,trigger creation scripts must come after table creation scripts;and grant permission scripts must come after both table anduser creation scripts.

For more information, see the ““Reverse Engineering fromScripts” on page 525” section.

Datasource

You reverse engineer the schema for an existing database,specifying an data source, and connection information.You canselect to use administrator permissions in order to be able toselect the system tables that are reserved to a database admin.

For more information, see the ““Reverse Engineering from aLive Database” on page 528” section.

Set options appropriatelyWhen you reverse engineer a database, whether from a script or a datasource, make sure that you set the rebuild options appropriately. Click theOptions tab and select or clear the checkboxes to rebuild references and/orprimary keys according to your needs. By default, no rebuild options areselected.

524

Page 537: Physical Data Model - SAP

Chapter 13. Reverse Engineering a Database into a PDM

Reverse Engineering from ScriptsPowerDesigner can reverse engineer a PDM for one or more SQL script files.

Reversing from SQL files in EclipseWhen working with the PowerDesigner Eclipse plug-in you can, in additionto the procedure below, select any SQL file in the Navigator, right-click itand select Reverse Engineer from SQL File. You will be given the optionto reverse into an existing or new PDM.

v To reverse engineer objects one or more script files

1. To reverse engineer a script into an existing PDM, select Database ä

Reverse Engineer Database.

or

To reverse engineer a script and create a new PDM, select File ä ReverseEngineer ä Database to open the New Physical Data Model dialog box.Specify a model name, choose a DBMS from the list, and then click OK.

2. When the Database Reverse Engineering dialog box opens, click theUsing script files radio button.

Always place trigger script files after table script filesYou can add as many script files as necessary to the list. The reverseengineering process handles files sequentially. Trigger scripts mustalways be executed after table scripts. This is the only constraint forordering your files in the list, but it is essential for a successful reverseengineering of triggers. Use the Move tools to position the files correctlyin the list.

525

Page 538: Physical Data Model - SAP

Reverse Engineering from Scripts

3. Click the Options tab to specify any reverse engineering options. Formore details, see ““Reverse engineering Options tab” on page 532”.

4. Click the Target Models tab to specify any external shortcuts. For moredetails, see ““Reverse engineering Target Models tab” on page 535”.

5. Click OK to begin the process of reverse engineering. When the processis complete, a confirmation message is given in the Output window. Ifyou are reverse engineering to an existing PDM, then the Merge Modelsdialog box opens to help you merge the new objects into your PDM.

+ For more information on comparing and merging two models, see theComparing and Merging Models chapter in the General Features Guide .

Script file tools

The following tools are available to help you to select script files:

526

Page 539: Physical Data Model - SAP

Chapter 13. Reverse Engineering a Database into a PDM

Tool Description

Add Files – Opens a dialog box to allow you to browse for scriptsfiles. You can add as many files as necessary.

Move Up – Moves the selected file(s) up one row. This tool isgrayed if the selected file(s) are at the top of the list.

Move Down - Moves the selected file(s) down one row. This tool isgrayed if the selected file(s) are at the bottom of the list.

Clear All - Deletes all files from the list.

527

Page 540: Physical Data Model - SAP

Reverse Engineering from a Live Database

Reverse Engineering from a Live DatabasePowerDesigner can reverse engineer a PDM from a live database connection.

v To reverse engineer database objects from a live database con-nection1. To reverse engineer from a live database connection into an existing

PDM, select Database ä Reverse Engineer Database to open theDatabase Reverse Engineering dialog box.

or

To reverse engineer from a live database connection and create a newPDM, select File ä Reverse Engineer ä Database to open the NewPhysical Data Model dialog box. Specify a model name, choose a DBMSfrom the list, and then click OK.

2. When the Database Reverse Engineering dialog box opens, click theUsing a data source radio button.

528

Page 541: Physical Data Model - SAP

Chapter 13. Reverse Engineering a Database into a PDM

Data sourceA data source might be predefined, or you can type the name of anexisting data source. In both cases, when you click OK, a databaseconnection dialog box opens, if you need to specify additional connec-tion parameters. Click Connect and the Database Reverse Engineeringdialog box is displayed. (Go to step 9)

3. Click the Connect to a Data Source tool to open the Connect to anODBC Data Source dialog box.

4. Select the appropriate source, type a user ID and a password, and thenclick Connect to return to the Database Reverse Engineering dialog box.

5. If you want to select tables reserved to the database administrator, thenyou must select the Reverse using administrator’s permissions checkbox.

6. Click the Options tab to specify any reverse engineering options. Formore details, see “Reverse engineering Options tab” on page 532.

529

Page 542: Physical Data Model - SAP

Reverse Engineering from a Live Database

7. Click the Target Models tab to specify any external shortcuts. For moredetails, see “Reverse engineering Target Models tab” on page 535.

8. Click OK to open the ODBC Reverse Engineering dialog box. This boxallows you to specify a selection of objects to reverse engineer. Onlytables and triggers are selected by default.

For more information about selecting objects, see “Database Reverse

530

Page 543: Physical Data Model - SAP

Chapter 13. Reverse Engineering a Database into a PDM

Engineering Selection window” on page 536.

9. Click OK to begin the process of reverse engineering. When the processis complete, a confirmation message is given in the Output window. Ifyou are reverse engineering to an existing PDM, then the Merge Modelsdialog box opens to help you merge the new objects into your PDM.

+ For more information on comparing and merging two models, see theComparing and Merging Models chapter in the General Features Guide .

531

Page 544: Physical Data Model - SAP

Reverse Engineering Options

Reverse Engineering OptionsThe following sections give detailed information about the various optionsthat you can use to control reverse engineering.

Reverse engineering Options tab

When you reverse engineer a database schema using script files or a datasource, you can define rebuild options after reverse engineering.

The rebuild options automatically perform the following tasks after reverseengineering:

Reverse options Description

Automatically re-build referenceswhen no reference isreversed

Rebuilds references when no references are reverseengineered. The rebuild references feature starts bydetecting columns with identical name and data typein different tables. A reference is created betweeneach column belonging to a primary key and a col-umn, with identical name and data type, that does notbelong to a primary or a foreign key in another table.

Automatically re-build primary keysfrom unique indexeswhen tables have nokey and only oneunique index

Rebuilds primary keys using unique indexes whentables have no key and only one unique index.

Automatically re-verse tables refer-enced by selectedtables

Reverse engineers the parents of the selected childtables in order to complement the definition of thesechild tables.

532

Page 545: Physical Data Model - SAP

Chapter 13. Reverse Engineering a Database into a PDM

Reverse options Description

Create symbols Creates a symbol for each reversed object in thediagram. Otherwise, reversed objects are visible onlyin the browser.

The layout of the symbols in the diagram will beautomatically arranged. In cases where there are alarge number of objects with complex interactions,the auto-layout feature is likely to create synonymsof objects to improve the diagram readability. Forexample, if a table has a large number of references,the auto-layout feature will create a synonym of thistable in another location of the diagram in order toimprove the diagram presentation.

File encoding Specifies the default file encoding of the files toreverse engineer. Click the ellipsis to the right ofthe option to change the encoding (see ““Reverseengineering encoding format” on page 533”).

Block terminator Specifies the end of block character for the reversedscript. By default, displays the value defined in theDBMS, under Script\SQL\Syntax. You can modifythis value, in which case it will be saved in theRegistry for reuse in other models. You can restorethe DBMS value using the Restore from DBMS tool.

Command termina-tor

Specifies the end of command character for thereversed script. By default, displays the value definedin the DBMS, under Script\SQL\Syntax. You canmodify this value, in which case it will be saved in theRegistry for reuse in other models. You can restorethe DBMS value using the Restore from DBMS tool.

Case sensitivedatabase

Specifies that the database is case sensitive andenables the case sensitive option in the model.

+ For more information on indexes, rebuilding references and rebuildingprimary keys, see chapter Building Physical Diagrams.

Reverse engineering encoding format

If the code you want to reverse engineer is written with Unicode or MBCS(Multibyte character set), you should use the encoding parameters providedto you in the File Encoding box.

533

Page 546: Physical Data Model - SAP

Reverse Engineering Options

If you want to change these parameters because you know which encoding isused within the sources, you can select the appropriate encoding parameterby clicking the Ellipsis button beside the File Encoding box. This opens theText Input Encoding Format dialog box in which you can select theencoding format of your choice.

The Text Input Encoding Format dialog box includes the following options:

Option Description

Encoding hint Encoding format to be used as hint when reversing thefile.

Detection mode Indicates whether text encoding detection is to be at-tempted and specifies how much of each file should beanalyzed. When enabled, PowerDesigner analyzes a por-tion of the text, and uses an heuristic based on illegal bytessequences and/or the presence of encoding-specific tagsin order to detect the appropriate encoding that should beused for reading the text.

The following settings are available:♦ No detection - for use when you know what the encod-

ing format is

♦ Quick detection - analyzes a small part of the file. Foruse when you think that the encoding format will beeasy to detect

♦ Full detection – analyzes the whole file. For use whenyou think that the number of characters that determinethe encoding format is very small

534

Page 547: Physical Data Model - SAP

Chapter 13. Reverse Engineering a Database into a PDM

Option Description

On ambiguousdetection

Specifies what action should be taken in case of ambigu-ity. The following settings are available:♦ Use encoding hint and display warning - the encod-

ing hint format is used and a warning message is dis-played.

♦ Use encoding hint - the encoding hint format is usedbut no warning message is displayed.

♦ Use detected encoding - the encoding format detectedby PowerDesigner is used

Abort on charac-ter loss

Allows you to stop reverse engineering if characterscannot be identified and are to be lost in current encoding

Here is an example on how to read encoding formats from the list:

Reverse engineering Target Models tab

External shortcuts depend on their corresponding target objects located indifferent models. When you need several models to design a single database,you can use shortcuts to share objects between models.

During reverse engineering, PowerDesigner allows you to create externalshortcuts from target objects in target models. In the Database ReverseEngineering dialog box, the Target Models tab displays the list of detectedtarget models containing target objects for shortcuts in the current model toreverse.

This tab is always visible in the Database Reverse Engineering dialog box,even if the model does not contain shortcuts.

This tab is empty when you reverse engineer into a new model. This is to letyou add target models and create shortcuts instead of duplicating objects.

You can use the Target Models tab in the Database Reverse Engineeringdialog box to manage target models using the following tools:

535

Page 548: Physical Data Model - SAP

Reverse Engineering Options

Tool Tooltip Description

Change TargetModel

Displays a standard Open dialog box to let youselect another file as target model

Open Model Opens selected target model in current workspace

Add Models Opens a selection list with the models opened inthe current workspace. This tool is particularlyuseful when you reverse engineer into a newmodel where the target models are not defined

Delete Deletes the target model and the shortcuts in thecurrent model that reference the deleted targetmodel

When you reverse engineer a model, any target models should be open inyour workspace. If not, the following confirmation dialog box is displayedto let you open the target models:

Reverse engineeringfrom script

All the create statements in the script create objects, provided the scriptcontains a full definition of the object.

When the script only uses an object and does not define it, this object issought among the target objects in the target models and an external shortcutis created in the reversed model.

Reverse engineeringfrom data source

When you reverse engineer from a live database connection, externalshortcuts are created for all selected objects already existing in another targetmodel. These existing objects are deselected by default in the Selection tabof the Reverse Engineering dialog box, except the target objectscorresponding to shortcuts already existing in the reversed model.

Database Reverse Engineering Selection window

When you reverse engineer a database from a live database connection, youcan choose to generate a PDM for all, or just selected objects. You make thisselection in the Database Reverse Engineering Selection window:

536

Page 549: Physical Data Model - SAP

Chapter 13. Reverse Engineering a Database into a PDM

The object types that you can reverse engineer are DBMS-dependent.Unavailable object types do not appear for selection.

Filters You can restrict database objects to reverse engineer by selecting an owneror a database qualifier in the top area of the window:

Filter Description

Qualifier A qualifier is a database, or a partition in a database, thatcontains one or more tables. When a qualifier is selected as afilter, it restricts the objects available for reverse engineering tothe objects contained within the selected qualifier. For example,the DB2 DBMS authorizes the use of the qualifier field to selectwhich databases are to be reverse engineered from a list.

Owner Normally the creator of a database object is its owner. When anowner is selected as a filter; it restricts the objects available forreverse engineering to the objects owned by the selected owner.

You can filter on a qualifier and/or owner in either of the following ways:

♦ Select a qualifier in the Filter on object qualifier list and/or select a userID in the Filter on object owner list.

♦ Click the Select Qualifier and Owner tool, and type a qualifier and/orowner in the dialog box. This method is recommended if the selectedqualifier contains a large number of table owners, as opening the Ownerlist may take a very long time.

537

Page 550: Physical Data Model - SAP

Reverse Engineering Options

Note that only users that have creation rights are reverse engineered.

Selecting objects from multiple ownersTo reverse engineer objects from multiple owners, you can select All usersas a filter from the owner list. All the objects belonging to all ownersappear in the list, and you can select the objects for reverse engineeringregardless of their owner.

Objects and options You access different object types to select by clicking on the appropriatesub-tabs.

Tables and triggersWhen you select tables containing triggers from the Table tab, the corre-sponding triggers are automatically selected in the Trigger tab.

Certain object types have attributes, or options, that appear below the objectlists. These options depend on the selected object type and on the currentDBMS. Unavailable options appear grayed.

User-defined and abstract data typesYou can reverse engineer user-defined and abstract data types. In thegenerated PDM, the names of these data types appear in the List ofAbstract Data Types.

Selection list You can save your selections for re-use by entering a selection name in thelist at the bottom of the window and clicking the save tool to the right of thelist. Selections are saved with a .sel file extension, and are added to the listfor subsequent use. You can change the folder in which the files are saved byclicking the folder tool to the right of the list.

+ For more information on selection windows, see the “Adding an itemfrom a selection list” section in the Using the PowerDesigner Interfacechapter in the General Features Guide.

Reverse engineering a Microsoft Access 97 database

PowerDesigner and MS Access 97 use .DAT files to exchange information.These files are reversed into the PDM. The access.mdb database uses or

538

Page 551: Physical Data Model - SAP

Chapter 13. Reverse Engineering a Database into a PDM

creates .DAT files to reverse Access databases.

You can define the database reverse parameters from the access.mdbdatabase window.

v To reverse an MS Access database into a PowerDesigner PDM

1. Double-click ACCESS.MDB in the PowerDesigner \tools directory.

2. Select Reverse Engineer Access Database File to PowerDesigner Script.

3. Type the Access database name in the Select Database box.

4. Type the .DAT file to create in the PowerDesigner File.

5. Click the Create button.

6. Select DBMS ä Reverse Engineering Databases in PowerDesigner.

7. Select the newly generated script file to reverse.

8. Click OK.

Optimizing live database reverse engineering queries

Live database reverse engineering has been optimized in order to improveperformance. All queries run according to an optimization process rule. Thisprocess uses the following registry keys:

♦ RevOdbcMinCount defines a number of selected objects for reverseengineering. The default number is 100

♦ RevOdbcMinPerct defines a percentage of selected objects for reverseengineering. The default percentage is 10

These keys do not exist by default, you have to create and edit them in theRegistry under:

Current User \Software\Sybase\PowerDesigner <version>\FolderOptions\Physical Objects

During reverse engineering, PowerDesigner compares the total number ofcurrent objects for reverse engineering to the value of RevOdbcMinCount.

If the total number of listed items is lower than the value ofRevOdbcMinCount A global reverse query is executed.

If the total number of listed items is higher than the value ofRevOdbcMinCount The process uses key RevOdbcMinPerct.

539

Page 552: Physical Data Model - SAP

Reverse Engineering Options

♦ If the percentage of reversed items is lower than the percentage defined inRevOdbcMinPerct, then a global query is executed

♦ If the percentage of reversed items is higher than the percentage definedin RevOdbcMinPerct, then the same query is executed for each object

540

Page 553: Physical Data Model - SAP

Chapter 13. Reverse Engineering a Database into a PDM

Reverse Engineering Database StatisticsYou can reverse engineer statistics for an existing database, such as thenumber of distinct or null values in a column or the average length of acharacter field. These can provide helpful information when optimizing adesign.

You can reverse engineer the statistics as part of the general reverseengineering process by selecting the Statistics checkbox in the DatabaseReverse Engineering window (see “Reverse Engineering from a LiveDatabase” on page 528), or update them at any other time, using thededicated Update Statistics window.

v To update database statistics

1. Select Tools ä Update Statistics to open the Update Statistics window (ifPowerDesigner is not presently connected to a database via a livedatabase connection, you will be required to connect):

2. On the General tab, select or clear the checkboxes to specify whether youwant to update statistics for tables and/or columns.

3. [optional] Click the Selection tab and select or clear checkboxes tospecify for which tables you want to update statistics:

541

Page 554: Physical Data Model - SAP

Reverse Engineering Database Statistics

4. Click OK to begin the update. Progress appears in the Output window.For large updates, a progress dialog box opens, allowing you to cancelthe update at any time.

When the process is complete, you can view the updated statistics in theproperty sheets of your tables and columns.

542

Page 555: Physical Data Model - SAP

CHAPTER 14

DBMS-Specific Features

About this chapter PowerDesigner can be used with a number of DBMS with specific featuresoften requiring special procedures for certain tasks. This chapter describesthese DBMS-specific features and associated tasks.

+ For more information on DBMS definition file contents, see the DBMSReference Guide in the Advanced User Documentation .

Contents Topic: page

Working with PowerDesigner’s DBMS-Specific Features 544

Logical Model 545

IBM DB 2 548

Informix SQL 556

Ingres 557

Interbase 558

Microsoft Access 559

Microsoft SQL Server 7.x and 2000 560

Microsoft SQL Server 2005 574

MySQL 613

NonStop SQL 615

Oracle 616

PostgreSQL 642

Red Brick Warehouse 647

Sybase AS Anywhere 648

Sybase AS Enterprise 654

Sybase AS IQ 657

Sybase SQL Anywhere 671

Teradata 673

543

Page 556: Physical Data Model - SAP

Working with PowerDesigner’s DBMS-Specific Features

Working with PowerDesigner’s DBMS-SpecificFeatures

This chapter provides information on some of the more importantDBMS-specific features in PowerDesigner

PowerDesigner resourcefiles

PowerDesigner provides customized support for a wide range of databasefamilies through DBMS-specific resource files. These files have a .xdbextension, and are located in the “Resource Files\DBMS” directory insideyour PowerDesigner installation directory.

Resource files support, among others, three kinds of customization forPowerDesigner model objects:

♦ Assignment of standard objects to the specific syntax of a DBMS

♦ Definition of Extended Attributes for certain objects to allow forDBMS-specific object properties

♦ Definition of additional DBMS-specific model objects.

You can view and edit the resource file for your selected DBMS in theResource Editor by selecting Database ä Edit Current DBMS.

+ For more information about working with resource files and theResource File Editor, see the following chapters in the Advanced UserDocumentation :

♦ Resource Files and the Public Metamodel

♦ DBMS Reference Guide

♦ Managing Profiles

544

Page 557: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Logical ModelThe logical model (<Logical Model> DBMS) allows you to design adatabase structure and perform some database denormalization actions. Thismodel is independent from any DBMS physical requirement.

Why build a logical model?

The logical PDM is a physical model with standard objects, and withoutDBMS specific physical options and generation capabilities.

In the database design process, you use a logical model as an intermediarystep between conceptual and physical design:

♦ Start with a CDM containing entities, attributes, relationships, domains,data items and business rules

♦ Generate a logical model (PDM with the <Logical Model> DBMS).Create indexes and specify FK column names and other common features

♦ Generate a set of PDMs, each targeted to a specific DBMSimplementation. Define physical options and other DBMS specificfeatures

This design process allows you to keep everything consistent in a largedevelopment effort.

+ For more information on PDM generation, see the Generating OtherModels from a PDM chapter.

Inheritance in the logical PDM

The logical PDM contains only standard PDM objects and no DBMSspecific objects. The logical PDM also allows you to display inheritancelinks.

Displaying inheritance links in a PDM

You can display inheritance links in a logical PDM. An inheritance link is areference with a special symbol and with the IsInheritance extendedattribute set to True. Inheritance links proceed from inheritance andgeneralization links in a source CDM or OOM.

Inheritance links support different model notations as shown in the followingtable:

545

Page 558: Physical Data Model - SAP

Logical Model

Relational / Conceptual IDEF1X

v To display an inheritance link in a PDM

1. Double-click a reference link to display its property sheet, and then clickthe Detail tab.

2. Select the Inheritance Link checkbox, and then click OK.

The reference will now display an inheritance symbol.

Generating inheritance links

When you generate a logical PDM from a CDM or an OOM, you can recoverinheritance or generalization links and display them in the PDM diagram. Todo so, you need to enable a post generation transformation that will convertall inheritance and generalization links into PDM inheritance links.

+ For more information on transformations used during model generation,see the Generating Other Models from a PDM chapter.

+ If you do not enable transformations during generation, you can still usethe Apply Transformations feature to apply the inheritance symbol to allreferences proceeding from inheritance or generalization links.

+ For more information on how to apply transformations and retrieveinheritance symbols, see section “Applying transformations to retrieveinheritance symbols” on page 547.

v To generate inheritance links

1. Select Tools ä Generate Physical Data Model from a CDM or an OOM.

Make sure the DBMS of the target PDM is <Logical Model>.

2. Click the Details tab to display the corresponding tab.

3. Click the Enable Transformations button.

The Post-generation tab is displayed and displays a transformation profilewith a transformation designed to convert inheritance and generalizationobjects into references with a specific symbol.

4. Click OK in the generation dialog box.

The inheritance links are created in the generated PDM.

546

Page 559: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Applying transformations to retrieve inheritance symbols

+ In case you forgot to enable transformations during generation, you canstill use the Apply Transformations feature to apply the inheritance symbolto all references proceeding from inheritance or generalization links. Notethat this feature only applies to generated PDMs; furthermore the sourceCDM or OOM must be open in the workspace.

v To apply transformations to retrieve inheritance symbols

1. Select Tools ä Apply Transformations.

The Apply Transformations dialog box is displayed. The profilecorresponding to the source model of the generated PDM is selectedtogether with the corresponding transformation.

2. Click OK.

Inheritance symbols is displayed on references proceeding frominheritance and generalization links.

Logical model extended attributes

The following extended attributes are defined by default in the LogicalDBMS.

Reference The following extended attributes are available on the Detail tab:

Name Description

Inheritancelink

True if the reference is an inheritance link.

Scripting name: IsInheritance

547

Page 560: Physical Data Model - SAP

IBM DB 2

IBM DB 2The following table lists DB2 objects and their equivalents inPowerDesigner:

DB2 PowerDesigner

Bufferpool Storage

Database Partition Group Extended Object<<DatabasePartitionGroup>>

Distinct Type Domain

Function Procedure of “Function” type

Index Extension Extended Object <<IndexExtension>>

Method Abstract Data Type Procedure

Type Abstract Data Type

SuperView SubView of a View

Tablespace prefix

In IBM databases for OS/390, the physical options for a table can specify thetablespace in which a table resides as well as the database name.

To support this feature, the Options entry in the Table category contains theitem enabledbprefix.

548

Page 561: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

By default, this item is set to yes which means that the tablespace name willbe systematically prefixed by the database name. You declare a tablespace ina database from the Options tab of the tablespace property sheet.

In the following example, tablespace TBSP1 is declared in databaseMyBase:

549

Page 562: Physical Data Model - SAP

IBM DB 2

If you select TBSP1 in the table physical options, you can view that thetablespace name is prefixed by the name of the database.

550

Page 563: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

If the tablespace is not declared in any database, then the tablespace is notprefixed by any database name.

When you preview the table creation code, you can verify that the tablespaceis prefixed by the name of the database.

Database partition groups

Database partition groups are supported for DB2 v9.x and higher.

A partition group is a logical layer that provides for the grouping of one ormore database partitions. A partition can belong to more than one partitiongroup. When a database is created, DB2 creates three default partitiongroups, which cannot be dropped.

You can create a database partition group in any of the following ways:

♦ Select Model ä DatabasePartitionGroup Objects to access the List ofDatabasePartitionGroups, and click the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

DatabasePartitionGroup

You can modify an object’s properties from its property sheet. To open adatabase partition group property sheet, double-click its diagram symbol or

551

Page 564: Physical Data Model - SAP

IBM DB 2

its Browser entry in the DatabasePartitionGroup Objects folder.

The following extended attributes are available on the DB2 tab:

Property Description

Databasepartitions

Specifies the database partitions that are in the partition group.

When empty, the group includes all database partitions definedin the database at the time of its creation.

Scripting name: DBPartitionNumList

Index extensions

Index extensions are supported for DB2 v9.x and higher.

Index extensions are used with indexes on tables that have columns of astructured or distinct type.

The following options are available on the DB2 tab:

Property Description

Parameters Specifies a list of parameters (with data types) that is passedto the index extension at CREATE INDEX time to define theactual behavior of this index extension.

Scripting name: IndexExtensionParameters

Key gener-ation func-tion

Specifies how the index key is generated using a user-definedtable function. Multiple index entries may be generated for asingle source key data value.

Scripting name: KeyGenerationFunction

Parameter Specifies parameters for the key generation function.

Scripting name: KeyGenerationFunctionParameters

Searchmethods

Specifies the list of method details of the index search. Eachdetail consists of a method name, the search arguments, a rangeproducing function, and an optional index filter function.

Scripting name: SearchMethods

Source keyparameters

Specifies the parameter (and its data type) that is associatedwith the source key column.

Scripting name: SourceKeyParameters

Target keyparameters

Specifies the target key parameters that are the output of thekey generation function specified on the GENERATE KEYUSING clause.

Scripting name: TargetKeyParameters

552

Page 565: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

IBM DB 2 extended attributes

The following extended attributes are defined by default in the IBM DB 2Logical DBMS.

Column The following extended attributes are available on the DB2 tab. The list willvary depending on the database version and whether you are working withCommon Server or OS/390:

Name Description

Index Specifies that the uniqueness constraint does not apply to thekey value if any column of the key is null. This applies whenthe index is a primary key.

Scripting name: WhereNotNull

Lob option Specifies options for LOB data type columns.

Scripting name: ExtLobOption

For bit data Specifies that the content of the column is to be treated asbit (binary) data. This is only applicable on columns with acharacter datatype.

Scripting name: ExtForBitData

Expression Specifies that the definition of the column is based on anexpression.

Scripting name: ExtGenExpr

AlwaysGeneratevalue

When set to True (generated always), indicates that DB2 willalways generate a value for the column when a row is insertedinto the table or whenever the result value of the generation-expression may change.

When set to False (generated by default), indicates that DB2will generate a value for the column when a row is inserted intothe table, unless a value is specified.

Scripting name: ExtGenAlways

Field pro-cedurename

Defines the procedure that will be used as generator/cryptor ofvalues.

Scripting name: ExtFieldProcName

Charactersubtype

Specifies a subtype for a character string column (column witha CHAR,VARCHAR,or LONG VARCHAR data type). Thesubtype can proceed from the list defined in extended attributetype T_ForData.

Scripting name: ExtData

553

Page 566: Physical Data Model - SAP

IBM DB 2

Name Description

Generatedvalue

Indicates that DB2 generates values for the column using thecomputed column function. If you select Always, the serverwill send an error message if you try to type a value in thecolumn. If you select By Default, the server uses the computedcolumn value or the value typed for the column.

Scripting name: ExtGeneratedAs

Charactersubtype

Specifies a subtype for a character string column.

Scripting name: ExtSubtypeData

Domain The following extended attributes are available on the DB2 tab:

Name Description

CharacterSubtype

Specifies a subtype for a character string column.

Scripting name: ExtSubtypeData

Index The following extended attributes are available on the Extended Attributestab:

Name Description

[none] Specifies that the uniqueness constraint does not apply to thekey value if any column of the key is null. This applies whenthe index is a primary key.

Scripting name: WhereNotNull

Table The following extended attributes are available on the DB2 tab:

Name Description

Table Indicates what percentage of each tab to leave as free spaceduring load or reorganization.

Scripting name: ExtTablePctFree

Tablespace The following extended attributes are available on the Extended Attributestab:

554

Page 567: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Name Description

[none] Specifies the tablespace type, as defined in the extendedattribute type ExtTablespaceTypeList.

Scripting name: ExtTablespaceType

[none] Specifies the database that owns the tablespace.

Scripting name: TbspDatabase

555

Page 568: Physical Data Model - SAP

Informix SQL

Informix SQLThis section describes features specific to the Informix SQL family ofdatabases.

Informix SQL extended attributes

The following extended attributes are defined by default in the InformixSQL DBMS.

Columns The following extended attributes are available on the Informix tab:

Name Description

Serial Start Defines the initial value of the column with a SERIALdatatype.

Scripting name: ExtSerialStart

556

Page 569: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

IngresThis section describes features specific to the Ingres family of databases.

Ingres extended attributes

The following extended attributes are defined by default in the IngresDBMS.

Columns The following extended attributes are available on the Extended Attributestab:

Name Description

[none] Indicates the column needs a value. This generates the “notdefault” clause in the sql statement.

Scripting name: NotDefault

Users The following extended attributes are available on the Ingres tab:

Name Description

Defaultgroup

Specifies the default group the user belongs to.

Scripting name: DefaultGroup

Expirationdate

Specifies an optional expiration date associated with each user.Any valid date can be used. Once the expiration date is reached,the user is no longer able to log on. If the expire_date clause isomitted, the default is noexpire_date.

Scripting name: ExpireDate

Externalpassword

Allows a user’s password to be authenticated externally toIngres. The password is passed to an external authenticationserver for authentication.

Scripting name: ExternalPassword

Limitingsecuritylabel

Allows a security administrator to restrict the highest securitylabel with which users can connect to Ingres when enforcingmandatory access control (MAC).

Scripting name: LimitingSecurityLabel

Profile Allows a profile to be specified for a particular user. If theprofile clause is omitted, the default is noprofile.

Scripting name: Profile

557

Page 570: Physical Data Model - SAP

Interbase

InterbaseThis section describes features specific to the Interbase family of databases.

Interbase extended attributes

The following extended attributes are defined by default in the InterbaseDBMS.

Index The following extended attributes are available on the Interbase tab:

Name Description

Row sort Defines that the default value of the index (ascendingor descending) is defined on the index and not on thecolumn.

Scripting name: ExtAscDesc

Sequence The following extended attributes are available on the Interbase tab:

Name Description

First value Sequence first value for Interbase generator.

Scripting name: ExtStartWith

Increment value Sequence increment value for Interbase generator.

Scripting name: ExtIncrement

558

Page 571: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Microsoft AccessThis section describes features specific to the MS Access family ofdatabases. These features include:

♦ Specific reverse engineering

♦ Extended attributes

Reverse Engineering a MS Access 97 Database

PowerDesigner and MS Access 97 use .DAT files to exchange information.These files are reversed into the PDM. The access.mdb database uses orcreates .DAT files to reverse Access databases.

You can define the database reverse parameters from the access.mdbdatabase window.

v To reverse engineer a MS Access database into a PowerDesignerPDM1. Double-click access.mdb in the PowerDesigner \tools directory.

2. Select Reverse engineer Access database to Script.

3. Type the Access database name in the Select Database box.

4. Type the .DAT file to create in the PowerDesigner File.

5. Click on the Create button.

6. In PowerDesigner, select DBMS ä Reverse Engineer ä Database.

7. Select the newly generated script file to reverse.

8. Click OK.

MS Access extended attributes

Column The following extended attributes are available on the Access 2000 tab:

Name Description

Allow ZeroLength

Specifies whether a zero-length string (“”) is a valid entry ina table column.

Applies only to Text, Memo, and Hyperlink table fields.

Scripting name: ExtAllowZeroLength

559

Page 572: Physical Data Model - SAP

Microsoft SQL Server 7.x and 2000

Microsoft SQL Server 7.x and 2000This section describes features specific to the MS SQL Server family ofdatabases. For additional features available with SQL Server 2005, see“Microsoft SQL Server 2005” on page 574.

SQL Server 2000 Analysis Services

The OLAP Services feature from SQL Server v7.0 is called AnalysisServices in SQL Server 2000. PowerDesigner supports analysis servicesthrough an add-in.

Analysis Services provide the following capabilities:

♦ The Analysis server that manages, stores multidimensional informationand serves client application requests for OLAP data. The server storescube metadata (cube definition specifications) in a repository. Completedcubes can be stored in a variety of storage modes: multidimensionaldatabase files (MOLAP), tables in a relational database (ROLAP), or ahybrid of multidimensional database files and relational tables (HOLAP)

♦ A metadata repository that contains definitions of OLAP data objectssuch as cubes and their elements

♦ The PivotTable Service, which is an OLE DB for OLAP provider thatconnects client applications to the Analysis server and manages offlinecubes

♦ An object model called Decision Support Objects (DSO), that providessupport for the Analysis Manager user interface and for customapplications that manage OLAP metadata and control the server. DSOuses hierarchically arranged groups of objects to define basic elements ofOLAP data. PowerDesigner creates and manipulates DSO objects tomanage metadata for OLAP data.

Source data for multidimensional cubes resides in relational databases wherethe data has been transformed into a star or snowflake schema typically usedin OLAP data warehouse systems. Analysis Services can work with manyrelational databases that support connections using ODBC or OLE DB.

+ For more information on SQL Server Analysis Services, see yourDBMS documentation.

v To enable PowerDesigner support for Analysis Services

1. Select Tools ä General Options, and select the Add-ins category in theleft-hand pane.

560

Page 573: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

2. Select the Microsoft Analysis Services add-in (PdMsOlap.dll) and thenclick OK to install it and return to the model.

+ For more information, see “Managing add-ins” in the Using thePowerDesigner Interface chapter in the General Features Guide .

PowerDesigner and the DSO metamodel

DSO uses hierarchically arranged groups of objects to define basic elementsof Analysis Services data storage, as implemented by the Analysis server.

The following table lists the mappings between the objects contained withinthe DSO and PowerDesigner PDM metamodels:

DSO Object PowerDesigner PDM Object

clsDatabase Model

(Each model corresponds to a DSO Database.)

clsDataSource Data source

561

Page 574: Physical Data Model - SAP

Microsoft SQL Server 7.x and 2000

DSO Object PowerDesigner PDM Object

ClsDatabaseDimen-sion

Dimension

(As in the DSO model, PowerDesigner dimensionsare shared among cubes.)

clsCube Cube

(Cubes managed by PowerDesigner are only localcubes.)

clsCube Fact

(A Fact corresponds to a DSO cube in order to storemeasures.)

clsCubeMeasure Measure

clsDatabaseDimen-sion

Dimension hierarchy

(Each dimension hierarchy is generated as a DSODatabase Dimension. Attributes of a dimension hier-archy define levels of the corresponding DatabaseD-imension.)

clsDatabaseLevelclsCubeLevel

Dimension attribute

(Attributes of a dimension or dimension hierarchydefine levels in a database dimension.)

clsCubeDimension Cube dimension association

(In DSO, when the name of a Cube Dimensioncorresponds to the name of a Database Dimension,the Cube Dimension is automatically associatedwith the Database Dimension to be shared betweencubes.)

Generating cubes

The Microsoft Analysis Services add-in lets you generate cubes.

562

Page 575: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

v To generate cubes

1. Select Tools ä Microsoft Analysis Services ä Generate Cubes to openthe connection dialog box.

2. Enter a name for the server and database, and then click OK to open theCube Selection dialog box, which lists all the available cubes. The statecolumn indicates if the cube has already been generated. Cubes alreadygenerated are deselected by default.

3. Select the cubes you want to generate, and then click OK.

The cubes specified are generated. If a cube already exists in thedatabase, it is dropped before being recreated. If a dimension alreadyexists, the selected cube reuses it. To be fully generated, a cube musthave a complete mapping to a table before being generated.

Reverse Engineering cubes

The Microsoft Analysis Services add-in lets you reverse engineer cubes.

563

Page 576: Physical Data Model - SAP

Microsoft SQL Server 7.x and 2000

v To reverse engineer cubes

1. Select Tools ä Microsoft Analysis Services ä Reverse Engineer Cubes toopen the connection dialog box.

2. Enter a name for the server and database, and then click OK to open theSource Model Selection dialog box, which lists the models linked to theselected data source.

3. Select the appropriate source models and then click OK to open the CubeSelection dialog box, which lists all the available cubes The state columnindicates if the cube already exists in the current model. Cubes alreadyexisting are deselected by default.

564

Page 577: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

4. Select the cubes you want to reverse engineer, and then click OK.

Selected cubes are created or updated in the current model. If adimension or a cube already exists, it is updated.

MS SQL Server extended attributes

The following extended attributes are defined by default in the MS SQLServer DBMS.

Columns The following extended attributes are available on the Microsoft tab:

Name Description

Do not val-idate checkconstraintsduring repli-cation

Specifies that “NOT FOR REPLICATION” keywords areused to prevent the CHECK constraint from being enforcedduring the distribution process used by replication.

Scripting name: ExtCkcNotForReplication

Default con-straint name

Contains the name of the constraint that is used to applya default value to the column. If empty, the “constraint”keyword is not generated.

Scripting name: ExtDeftConstName

565

Page 578: Physical Data Model - SAP

Microsoft SQL Server 7.x and 2000

Name Description

Identity seedand incre-ment

Is a string composed of two integer values separated by acomma.

First value is the seed value of the identity column, meaningthe value to be assigned to the first row in the table.

Second value is the increment to add to the seed value forsuccessive rows in the table.

Scripting name: ExtIdentitySeedInc

Identity valuenot replicated

Indicates that the IDENTITY property should not be en-forced when a replication login inserts data into the table.

Scripting name: ExtIdtNotForReplication

Not null con-straint name

Contains the name of the constraint that is used to apply amandatory property of the column. If empty, the “constraint”keyword is not generated.

Scripting name: ExtNullConstName

Row globalunique iden-tifier

Indicates that the new column is a row global unique identi-fier column. Only one unique identifier column per table canbe designated as the ROWGUIDCOL column.

Scripting name: ExtRowGuidCol

Collationname

A single string that specifies the collation name for a SQLcollation.

Scripting name: ExtCollation

Cubes The following extended attributes are available on the Microsoft tab:

566

Page 579: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Name Description

Options You can choose between the following:♦ PASSTHROUGH: causes the SELECT clause to be passed di-

rectly to the source database without modification by Pivot-Table Service. If PASSTHROUGH is not specified, PivotTableService parses the query and formulates a set of queries equiv-alent to the original that is optimized for the source databaseand index structures. This set of queries is often more efficientthan the specified.

♦ DEFER_DATA: causes the query to be parsed locally and ex-ecuted only when necessary to retrieve data to satisfy a userrequest. DEFER_DATA is used to specify that a local cube hasto be defined in the ROLAP storage mode.

♦ ATTEMPT_DEFER: causes PivotTable Service to attempt toparse the query and defer data loading if successful, or, if thequery cannot be parsed, to process the specified query immedi-ately as if PASSTHROUGH had been specified.

♦ ATTEMPT_ANALYSIS: causes PivotTable Service to attemptto parse the query and formulate an optimized set of queries. Ifthe query cannot be parsed, PivotTable Services processes thequery immediately as if PASSTHROUGH had been specified.

Scripting name: Options

Dimensions The following extended attributes are available on the Microsoft tab:

Name Description

Hidden Indicates whether the dimension is hidden from clients.

Scripting name: IsHidden

Options Dimension options to manage member uniqueness and specifytheir storage. You can choose between:♦ UNIQUE_NAME: Member names are unique within the di-

mension.

♦ UNIQUE_KEY: Member keys are unique within the dimen-sion.

♦ NOTRELATEDTOFACTTABLE: Indicates that non-leafmembers cannot be associated with fact table data.

♦ ALLOWSIBLINGSWITHSAMENAME: Determineswhether children of a single member in a hierarchy can haveidentical names.

Scripting name: Options

567

Page 580: Physical Data Model - SAP

Microsoft SQL Server 7.x and 2000

Name Description

Subtype Indicates the subtype of a dimension. You can choose between:♦ PARENT_CHILD:Indicates that the dimension is a parent-

child dimension.

♦ LINKED: Indicates that the cube is linked to another cube ona remote Analysis server.

♦ MINING: Indicates that the dimension is based on the contentof an OLAP data-mining model that has been processed for acube.

Scripting name: SubType

Template Contains a template string that is used to generate captions forsystem-generated data members.

Scripting name: Template

568

Page 581: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Name Description

Time Indicates that a dimension refers to time (year, month, week, day,and so on). You can choose between:♦ TIME: Year, month, week, day, and so on. The only valid

levels in a time dimension are those defined in the LevelTypesenumeration.

The following values post-fixed by an asterisk (*) are additionalvalues that can be used by the add-in but do not exist in the MDXsyntax. You can choose between a dimension that contains:♦ ACCOUNT: (*) an account structure with parent-child rela-

tionships.

♦ BILLOFMATERIALS (*): a material/component break-down. The parent-child relationship implies a parent com-posed of its children.

♦ CHANNEL (*): a distribution channel.

♦ CURRENCY (*): currency information.

♦ CUSTOMERS (*): customer information. The lowest levelrepresents individual customers.

♦ GEOGRAPHY (*): a geographic hierarchy.

♦ ORGANIZATION (*): the reporting structure of an organiza-tion.

♦ PRODUCTS (*): product information. The lowest level rep-resents individual products.

♦ PROMOTION (*): marketing and advertising promotions.

♦ QUANTITATIVE (*): quantitative elements (such as exam-ple, income level, number of children, and so on).

♦ RATES (*): different types of rates (for example, buy, sell,discounted. and so on).

♦ SCENARIO (*): different business scenarios.Scripting name: TimeDef

Dimension Attributes The following extended attributes are available on the Microsoft tab:

Name Description

Rollupexpres-sion

Contains a Multidimensional Expressions (MDX) expressionused to override the default roll-up mode.

Scripting name: CustomRollupExpr

Formatkey

Name of the column or expression that contains member keys.

Scripting name: FormatKey

569

Page 582: Physical Data Model - SAP

Microsoft SQL Server 7.x and 2000

Name Description

Formatname

Name of the column or expression that contains member names.

Scripting name: FormatName

Hide val-ues

Options to hide level members. You can choose between:♦ BLANK_NAME: Hides a level member with an empty name.

♦ PARENT_NAME: Hides a level member when the membername is identical to the name of its parent.

♦ ONLY_CHILD_AND_BLANK_NAME: Hides a level mem-ber when it is the only child of its parent and its name is nullor an empty string.

♦ ONLY_CHILD_AND_PARENT_NAME: Hides a levelmember when it is the only child of its parent and is identicalto the name of its parent

Scripting name: HideValues

Hidden Indicates whether the level is hidden from client applications.

Scripting name: IsHidden

Options Options about member uniqueness, ordering and data source.You can choose between:♦ UNIQUE: Indicates that the members of a level are unique.

♦ UNIQUE_NAME: Indicates that their member name columnsuniquely identify the level members.

♦ UNIQUE_KEY: Indicates that their member key columnsuniquely identify the level members.

♦ NOTRELATEDTOFACTTABLE: Indicates that the levelmembers cannot be associated with fact table data.

♦ SORTBYNAME: Indicates that level members are ordered bytheir names.

♦ SORTBYKEY: Indicates that level members are ordered bytheir keys.

♦ SORTBYPROPERTY <property names>: Indicates thatmembers are ordered by their property <property names>.

Scripting name: Options

570

Page 583: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Name Description

Root val-ues

Determines how the root member or members of a parent-childhierarchy are identified. You can choose between:♦ ROOT_IF_PARENT_IS_BLANK: Only members with a

null, a zero, or an empty string in their parent key columnare treated as root members.

♦ ROOT_IF_PARENT_IS_MISSING: Only members with par-ents that cannot be found are treated as root members.

♦ ROOT_IF_PARENT_IS_SELF: Only members having them-selves as parents are treated as root members.

♦ ROOT_IF_PARENT_IS_BLANK _OR_SELF_OR_-MISSING: Members are treated as root members if theymeet one or more of the conditions specified by ROOT_IF_-PARENT_IS_BLANK, ROOT_IF_PARENT_IS_SELF, orROOT_IF_PARENT_IS_MISSING.

Scripting name: RootValues

Type Identifies the specific type of level. . You can choose between:♦ ALL: Indicates the top (All) level of a dimension (the one that

precalculates all the members of all lower levels).

♦ YEAR: a level that refers to years (Time dimension only).

♦ QUARTER: a level that refers to (calendar) quarters (Timedimension only).

♦ MONTH: a level that refers to months (Time dimension only).

♦ WEEK: a level that refers to weeks (Time dimension only).

♦ DAY: a level that refers to days (Time dimension only).

♦ DAYOFWEEK: a level that refers to days of the week (Timedimension only).

♦ DATE: a level that refers to dates (Time dimension only).

♦ HOUR: a level that refers to hours (Time dimension only).

♦ MINUTE: a level that refers to minutes (Time dimensiononly).

♦ SECOND: Indicates that a level refers to seconds (Time di-mension only).

Scripting name: Type

Dimension Hierarchies The following extended attributes are available on the Microsoft tab:

571

Page 584: Physical Data Model - SAP

Microsoft SQL Server 7.x and 2000

Name Description

Hidden Indicates whether the hierarchy is hidden from client applica-tions.

Scripting name: IsHidden

Fact Measures The following extended attributes are available on the Microsoft tab:

Name Description

Format Format used to display the values of the cube measure.

Scripting name: Format

Cube measurefunction type

A value corresponding to the type of aggregate functionused by the cube measure.

Scripting name: Function

Hidden Indicates whether the measure is visible to the client.

Scripting name: IsHidden

Member calcu-lating order

Order in which the calculated member will be solved whencalculated members intersect each other.

Scripting name: SolveOrder

Source columndata type

Returns a OLE DB enumeration constant that identifies theSourceColumn (in the fact table) data type.

Scripting name: Type

References The following extended attributes are available on the Microsoft tab:

Name Description

Do not validateforeign keyconstraint dur-ing replication

Specifies that “NOT FOR REPLICATION” keywords areused to prevent the FOREIGN KEY constraint from beingenforced during the distribution process used by replication.

Scripting name: ExtFkNotForReplication

Tables The following extended attributes are available on the Microsoft tab:

Name Description

Do not validatecheck con-straints duringreplication

Specifies that “NOT FOR REPLICATION” keywords areused to prevent the TABLE CHECK constraint from beingenforced during the distribution process used by replication.

Scripting name: ExtCktNotForReplication

572

Page 585: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Views The following extended attributes are available on the Microsoft tab:

Name Description

Encryptionoption

This extended attribute defines the encryption option of theview, respecting the view creation syntax.

Scripting name: WithOption

573

Page 586: Physical Data Model - SAP

Microsoft SQL Server 2005

Microsoft SQL Server 2005This section describes features specific to Microsoft SQL Server 2005. Forinformation about features available with earlier versions, see also“Microsoft SQL Server 7.x and 2000” on page 560.

The following new features are available for Microsoft SQL Server 2005:

♦ “Horizontal partitioning” on page 575 - implemented via:• “Partition functions” on page 575

• “Partition schemes” on page 576

♦ “Common Language Runtime (CLR) integration” on page 577 -implemented via:• “CLR assemblies” on page 577

• “CLR aggregate functions” on page 579

• “CLR user-defined types” on page 580

• “CLR procedures and functions” on page 581

• “CLR triggers” on page 582

♦ “Encryption” on page 583 – implemented via:• “Certificates” on page 583

• “Asymmetric keys” on page 584

• “Symmetric keys” on page 585

♦ “Full text search” on page 586 – implemented via:• “Full-text catalogs” on page 586

• “Full-text indexes” on page 587

♦ “XML indexing” on page 588 – implemented via:• “XML indexes” on page 588

♦ “XML data types” on page 589 – implemented via:• “XML schema collections” on page 589

• “XML table columns” on page 590

♦ “Synonyms” on page 602

♦ “Database mirroring” on page 591• “Databases” on page 591

• “Endpoints” on page 592

♦ “Service Broker” on page 593

574

Page 587: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

• “Message types” on page 594

• “Contracts” on page 595

• “Queues” on page 596

• “Event Notifications” on page 598

• “Services” on page 600

• “Routes” on page 600

• “Remote service bindings” on page 601

♦ “Microsoft SQL Server 2005 Analysis Services” on page 603 –generation and reverse-engineering of cubes

♦ “Miscellaneous additional features” on page 612

Horizontal partitioning

Horizontal positioning in MS SQL Server 2005 is a method for making largetables and indexes more manageable by dividing them horizontally andspreading them across more than one filegroup in a database.

PowerDesigner supports horizontal partitioning through the partitionfunction and partition scheme objects.

Partition functions

A partition function specifies how a table or index can be partitioned.PowerDesigner models partition functions as extended objects with astereotype of <<PartitionFunction>>.

Creating a partitionfunction

You can create a partition function in any of the following ways:

♦ Select Model ä PartitionFunction Objects to access the List ofPartitionFunctions, and click the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

PartitionFunction

Partition functionproperties

You can modify an object’s properties from its property sheet. To open apartition function property sheet, double-click its diagram symbol or itsBrowser entry in the PartitionFunction Objects folder.

The following extended attributes are available on the Microsoft tab:

575

Page 588: Physical Data Model - SAP

Microsoft SQL Server 2005

Name Description

Input ParameterType

Specifies the data type of the column used for parti-tioning. All data types are valid, except text, ntext,image, xml, timestamp, varchar(max), nvarchar(max),varbinary(max), alias data types, or CLR user-defineddata types.

Scripting name: InputParameterType

Interval Side Specifies to which side of each boundary value intervalthe boundary_value [,. . . n ] belongs. You can choosebetween:♦ left [default]

♦ rightInterval values are sorted by the Database Engine inascending order from left to right.

Scripting name: IntervalSide

Boundary Values Specifies the boundary values for each partition of apartitioned table or index. All values must be separatedby commas.

Scripting name: BoundaryValues

Partition schemes

A partition scheme maps the partitions produced by a partition function to aset of user-defined filegroups. PowerDesigner models partition schemes asextended objects with a stereotype of <<PartitionScheme>>.

Creating a partitionscheme

You can create a partition scheme in any of the following ways:

♦ Select Model ä PartitionScheme Objects to access the List ofPartitionSchemes, and click the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

PartitionScheme

Partition schemeproperties

You can modify an object’s properties from its property sheet. To open apartition scheme property sheet, double-click its diagram symbol or itsBrowser entry in the PartitionScheme Objects folder.

The following extended attributes are available on the Microsoft tab:

576

Page 589: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Name Description

Partition Func-tion

Specifies the partition function using the scheme. Parti-tions created by the partition function are mapped to thefilegroups specified in the partition scheme.

Scripting name: PartitionFunction

All Partitions Specifies that all partitions map to the filegroup specifiedby the File Groups property.

Scripting name: AllPartitions

File Groups Specifies the names of the filegroups to hold the parti-tions specified by the partition function. If [PRIMARY]is specified, the partition is stored on the primary file-group. If ALL is specified, only one filegroup name canbe specified.

Scripting name: Filegroups

Partitioning a table or an index

To partition a table or an index, specify a partition scheme and column onthe Microsoft tab of its property sheet.

Common Language Runtime (CLR) integration

CLR integration means that stored procedures, triggers, and user-definedtypes, functions, and aggregate functions can be written for SQL Server inany .NET language, such as VB .NET or C#.

PowerDesigner supports CLR integration with assemblies, aggregatefunctions, CLR types, procedures, functions, and triggers.

CLR assemblies

An assembly is a DLL file used to deploy functions, stored procedures,triggers, user-defined aggregates, and user-defined types that are written inone of the managed code languages hosted by the Microsoft .NETFramework common language runtime (CLR), instead of in Transact-SQL.PowerDesigner models assemblies as extended objects with a stereotype of<<Assembly>>.

Creating an assembly You can create an assembly in any of the following ways:

♦ Select Model ä Assembly Objects to access the List of Assemblies, andclick the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

577

Page 590: Physical Data Model - SAP

Microsoft SQL Server 2005

Assembly

Assembly properties You can modify an object’s properties from its property sheet. To open anassembly property sheet, double-click its diagram symbol or its Browserentry in the Assembly Objects folder.

The following extended attributes are available on the Microsoft tab:

Name Description

Authorization Specifies the name of a user or role as the owner of theassembly.

Scripting name: Authorization

File name Specifies the local path or network location where theassembly that is being uploaded is located, and also themanifest file name that corresponds to the assembly. Canbe entered as a fixed string or an expression evaluatingto a fixed string.

Scripting name: FileName

Permission set Specifies a set of code access permissions that aregranted to the assembly when it is accessed by SQLServer. You can choose between:♦ SAFE

♦ UNSAFE

♦ EXTERNAL_ACCESSScripting name: PermissionSet

Visibility Specifies that the assembly is visible for creating com-mon language runtime (CLR) functions, stored pro-cedures, triggers, user-defined types, and user-definedaggregate functions against it. You can choose between:♦ On

♦ OffScripting name: Visibility

Unchecked data By default, ALTER ASSEMBLY fails if it must verifythe consistency of individual table rows. This optionallows postponing the checks until a later time by usingDBCC CHECKTABLE.

Scripting name: UncheckedData

578

Page 591: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

CLR aggregate functions

An aggregate function performs a calculation on a set of values and returns asingle value. Traditionally, Microsoft SQL Server has supported onlybuilt-in aggregate functions, such as SUM or MAX, that operate on a set ofinput scalar values and generate a single aggregate value from that set. SQLServer integration with the Microsoft .NET Framework common languageruntime (CLR) now allows developers to create custom aggregate functionsin managed code, and to make these functions accessible to Transact-SQL orother managed code. PowerDesigner models aggregate functions asextended objects with a stereotype of <<Aggregate>>.

Creating an aggregatefunction

You can create an aggregate function in any of the following ways:

♦ Select Model ä Aggregate Objects to access the List of AggregateObjects, and click the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

Aggregate

Aggregate functionproperties

You can modify an object’s properties from its property sheet. To open anaggregate function property sheet, double-click its diagram symbol or itsBrowser entry in the Aggregate Objects folder.

The following extended attributes are available on the Microsoft tab:

Name Description

Owner Specifies the name of a schema as the owner of theaggregate function.

Scripting name: Owner

Assembly Specifies the assembly to bind with the aggregatefunction.

Scripting name: Assembly

Class name Specifies the name of the class in the assembly thatimplements the aggregate function.

If the class name is not specified, SQL Server assumesit is the same as the aggregate name.

Scripting name: Class

Parameter name Specifies the name of the input parameter.

Scripting name: InputParameterName

579

Page 592: Physical Data Model - SAP

Microsoft SQL Server 2005

Name Description

Type Specifies the type of the input parameter. All scalar datatypes or CLR user-defined types can be used, excepttext, ntext, and image.

Scripting name: InputParameterType

Return type Specifies the return type of the aggregate function. Allscalar data types or CLR user-defined types can be usedas return type, except text, ntext, and image.

Scripting name: ReturnType

CLR user-defined types

The introduction of user-defined types (UDTs) in SQL Server 2005 allowsyou to extend the scalar type system of the server, enabling storage of CLRobjects in a SQL Server database. UDTs can contain multiple elements andcan have behaviors, differentiating them from the traditional alias data typeswhich consist of a single SQL Server system data type.

Because UDTs are accessed by the system as a whole, their use for complexdata types may negatively impact performance. Complex data is generallybest modeled using traditional rows and tables. UDTs in SQL Server 2005are well suited to the following:

♦ Date, time, currency, and extended numeric types

♦ Geospatial applications

♦ Encoded or encrypted data

PowerDesigner models user-defined types as abstract data types.

Creating a user-definedtype

To create a user-defined type, you must have an OOM open in theworkspace, in order to specify the supertype.

v To create a user-defined type

1. Create an abstract data type by:♦ Select Model ä Abstract data types to access the List of abstract data

types, and click the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

Abstract Data Type

2. On the General Tab of its property sheet, select CLR from the list ofTypes.

580

Page 593: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

3. Click the Select Class tool to the right of the Class field, in order tospecify a supertype.

4. Click the Microsoft tab and select an assembly from the list to bind to thetype.

5. Click OK to close the property sheet.

User-defined typeproperties

You can modify an object’s properties from its property sheet. To open auser-defined type property sheet, double-click its diagram symbol or itsBrowser entry in the Abstract Data Types folder.

In addition to the standard abstract data type properties, a user-defined typehas the following additional properties available on the Microsoft tab:

Name Description

Assembly Specifies the assembly to bind with the abstract datatype.

Scripting name: Assembly

Mandatory Specifies whether the type can hold a null value.

Scripting name: Mandatory

CLR procedures and functions

In Microsoft SQL Server 2005, you can write user-defined functions in anyMicrosoft .NET Framework programming language, such as MicrosoftVisual Basic .NET or Microsoft Visual C#. PowerDesigner models CLRprocedures and functions as standard procedures that use a CLR template,and are linked to a method from an associated OOM.

Creating a CLRprocedure or function

To create a CLR procedure or function, you must have an OOM open in theworkspace, in order to specify an associated class method.

v To create a CLR procedure or function

1. Create a standard procedure or function.

2. On the Definition Tab of its property sheet, select CLR Procedure or CLRFunction from the template list. A Class method field will be displayed tothe right of the template list.

3. Click the Select Method tool to the right of the Class method field, inorder to specify the associated method.

4. Click the Microsoft tab and select an assembly from the list to bind to theprocedure or function.

581

Page 594: Physical Data Model - SAP

Microsoft SQL Server 2005

5. Click OK to close the property sheet.

CLR procedure orfunction properties

You can modify an object’s properties from its property sheet. To open aCLR procedure or function property sheet, double-click its diagram symbolor its Browser entry in the Procedures folder.

The following extended attributes are available on the Microsoft tab:

Name Description

Assembly Specifies the assembly where the class method is de-fined.

Scripting name: Assembly

CLR triggers

The Microsoft SQL Server integration with the .NET Framework commonlanguage runtime (CLR), allows you to use any .NET Framework languageto create CLR triggers. PowerDesigner CLR triggers as standard triggers thatuse a CLR template, and are linked to a method from an associated OOM.

Creating a CLR trigger To create a CLR trigger, you must have an OOM open in the workspace, inorder to specify an associated class method.

v To create a CLR trigger

1. Create a standard trigger.

2. On the Definition Tab of its property sheet, select CLR Trigger from thetemplate list. A Class method field will be displayed to the right of thetemplate list.

3. Click the Select Method tool to the right of the Class method field, inorder to specify the associated method.

4. Click the Microsoft tab and select an assembly from the list to bind to thetrigger.

5. Click OK to close the property sheet.

CLR trigger properties You can modify an object’s properties from its property sheet. To open aCLR trigger property sheet, double-click its Browser entry.

The following extended attributes are available on the SQL Server tab:

Name Description

Assembly Specifies the assembly where the class method is de-fined.

Scripting name: Assembly

582

Page 595: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Encryption

SQL Server 2005 uses a new security infrastructure that supportshierarchical encryption and key management.

PowerDesigner supports encryption with certificates and asymmetric andsymmetric keys.

Certificates

A public key certificate, usually just called a certificate, is a digitally-signedstatement that binds the value of a public key to the identity of the person,device, or service that holds the corresponding private key. Certificates areissued and signed by a certification authority (CA). The entity that receives acertificate from a CA is the subject of that certificate. PowerDesigner modelscertificates as extended objects with a stereotype of <<Certificate>>.

Creating a certificate You can create a certificate in any of the following ways:

♦ Select Model ä Certificate Objects to access the List of Certificates, andclick the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

Certificate

Certificate properties You can modify an object’s properties from its property sheet. To open acertificate property sheet, double-click its diagram symbol or its Browserentry in the Certificate Objects folder.

The following extended attributes are available on the Microsoft tab:

Name Description

Authorization Specifies the name of a user as the owner of the certifi-cate.

Scripting name: Authorization

Assembly Specifies a signed assembly that has already been loadedinto the database.

Scripting name: Assembly

Assembly File Specifies the complete path, including file name, to aDER encoded file that contains the certificate. The pathname can be a local path or a UNC path to a networklocation. The file will be accessed in the security contextof the SQL Server service account. This account musthave the required file system permissions.

Scripting name: AssemblyFile

583

Page 596: Physical Data Model - SAP

Microsoft SQL Server 2005

Name Description

Subject Specifies the value of the subject field in the metadata ofthe certificate as defined in the X.509 standard.

Scripting name: Subject

Active for begindialog

Specifies that the certificate is available to the initiatorof a Service Broker dialog conversation.

Scripting name: ActiveForBeginDialog

Asymmetric keys

An asymmetric key is made up of a private key and the corresponding publickey. Each key can decrypt data encrypted by the other. Asymmetricencryption and decryption are relatively resource-intensive, but they providea higher level of security than symmetric encryption. An asymmetric keycan be used to encrypt a symmetric key for storage in a database.PowerDesigner models OBJECTS as extended objects with a stereotype of<<AsymmetricKey>>.

Creating an asymmetrickey

You can create an asymmetric key in any of the following ways:

♦ Select Model ä Asymmetric Key Objects to access the List ofAsymmetric Keys, and click the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

Asymmetric Key

Asymmetric keyproperties

You can modify an object’s properties from its property sheet. To open anasymmetric key property sheet, double-click its diagram symbol or itsBrowser entry in the Asymmetric Key Objects folder.

The following extended attributes are available on the Microsoft tab:

Name Description

Authorization Specifies the name of a user as the owner of the asymmetrickey.

Scripting name: Authorization

Assembly Specifies the name of an assembly from which to load thepublic key.

Scripting name: Assembly

Assembly file Specifies the path of a file from which to load the key.

Scripting name: AssemblyFile

584

Page 597: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Name Description

Algorithm Specifies the algorithm used to encrypt the key

Scripting name: Algorithm

Encryptionpassword

Specifies the password with which to encrypt the private key.If this clause is not present, the private key will be encryptedwith the database master key.

Scripting name: EncryptionPassword

Symmetric keys

A symmetric key is one key that is used for both encryption and decryption.Encryption and decryption by using a symmetric key is fast, and suitable forroutine use with sensitive data in the database. PowerDesigner modelssymmetric keys as extended objects with a stereotype of<<SymmetricKey>>.

Creating a symmetric key You can create a symmetric key in any of the following ways:

♦ Select Model ä Symmetric Key Objects to access the List of SymmetricKeys, and click the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

Symmetric Key

Symmetric keyproperties

You can modify an object’s properties from its property sheet. To open asymmetric key property sheet, double-click its diagram symbol or itsBrowser entry in the Symmetric Key Objects folder.

The following extended attributes are available on the Microsoft tab:

Name Description

Authorization Specifies the name of a user or role as the owner of thekey.

Scripting name: Authorization

Certificate Specifies the name of the certificate that will be used toencrypt the symmetric key.

Scripting name: Certificate

Password Specifies a password from which to derive a TRIPLE_DESkey with which to secure the symmetric key. Passwordcomplexity will be checked. You should always use strongpasswords.

Scripting name: Password

585

Page 598: Physical Data Model - SAP

Microsoft SQL Server 2005

Name Description

Symmetric key Specifies a symmetric key to be used to encrypt the keythat is being created.

Scripting name: SymmetricKey

Asymmetrickey

Specifies an asymmetric key to be used to encrypt the keythat is being created.

Scripting name: AsymmetricKey

Key source Specifies a pass phrase from which to derive the key.

Scripting name: KeySource

Algorithm Specifies the algorithm used to encrypt the key

Scripting name: Algorithm

Identity value Specifies an identity phrase from which to generate aGUID for tagging data that is encrypted with a temporarykey.

Scripting name: IdentityValue

Full text search

SQL Server 2005 supports full-text queries against a table’s plain characterdata. PowerDesigner supports this feature through the full text catalog andfull text index objects.

Full-text catalogs

A full-text catalog contains zero or more full-text indexes. PowerDesignermodels full-text catalogs as extended objects with a stereotype of<<FullTextCatalog>>.

Creating a full-textcatalog

You can create a full-text catalog in any of the following ways:

♦ Select Model ä Full-Text Catalog Objects to access the List of Full-TextCatalogs, and click the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

Full-Text Catalog

Full-text catalogproperties

You can modify an object’s properties from its property sheet. To open afull-text catalog property sheet, double-click its diagram symbol or itsBrowser entry in the Full-Text Catalog Objects folder.

The following extended attributes are available on the Microsoft tab:

586

Page 599: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Name Description

Authorization Specifies the name of a user or role as the owner of the fulltext catalog.

Scripting name: Authorization

File group Specifies the name of the SQL Server filegroup (or storage)of which the new catalog will be part.

Scripting name: FileGroup

Path Specifies the root directory for the catalog.

Scripting name: Path

Accent sensi-tivity

Specifies whether the catalog is accent sensitive for full textindexing.

Scripting name: AccentSensitivity

Default Specifies that the catalog is the default catalog.

Scripting name: Default

Full-text indexes

A full-text index stores information about significant words and theirlocation within a given column. This information is used to quickly computefull-text queries that search for rows with particular words or combinationsof words. PowerDesigner models full-text indexes as table indexes with anindex type set to “Full Text”.

Creating a full-text index

v To create a full-text index

1. Create an index by opening the property sheet of a table, clicking theIndexes tab and clicking the Add a Row tool.

2. Open the property sheet of the new index by clicking the properties tool,and then select FULLTEXT from the list of Types on the General tab.

3. Click the Select Class tool to the right of the Class field, in order tospecify a supertype.

4. Click the Microsoft tab and select a catalog from the list and then specifythe type of change tracking required.

5. Click OK to confirm your changes and close the property sheet.

587

Page 600: Physical Data Model - SAP

Microsoft SQL Server 2005

Full-text index properties You can modify an object’s properties from its property sheet. To open afull-text index property sheet, double-click its Browser entry.

In addition to the standard index properties, a full-text index has thefollowing additional properties available on the Microsoft tab:

Name Description

Catalog Specifies the full text catalog where the full text index isdefined.

Scripting name: FullTextCatalog

Changetracking

Specifies whether or not SQL Server maintains a list of allchanges to the indexed data. You can choose between:♦ manual

♦ auto

♦ off

♦ off, no populationScripting name: ChangeTracking

XML indexing

SQL Server 2005 provides improvements in indexing XML data.PowerDesigner supports these new features through the XML index object.

XML indexes

PowerDesigner models XML indexes as table indexes with an index type setto “XML”.

Creating an XML index

v To create an XML index

1. Create an index by opening the property sheet of a table, clicking theIndexes tab and clicking the Add a Row tool.

2. Open the property sheet of the new index by clicking the properties tool,and then select XML from the list of Types on the General tab.

3. Click the Microsoft tab and specify any additional options.

4. Click OK to confirm your changes and close the property sheet.

XML index properties You can modify an object’s properties from its property sheet. To open anXML index property sheet, double-click its Browser entry.

588

Page 601: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

The following extended attributes are available on the Microsoft tab:

Name Description

Primary Specifies that this is the primary xml index.

Scripting name: XMLPrimary

Primary index Specifies the primary XML index to use in creating asecondary XML index.

Scripting name: PrimaryXMLIndex

SecondaryXML indextype

Specifies the type of the secondary XML index.

Scripting name: SecondaryXMLIndexType

XML data types

The new XML data type allows you to store XML documents and fragmentsin a SQL Server 2005 database. PowerDesigner supports this through newcolumn properties and the XML schema collection object.

XML schema collections

An XML schema collection provides the following:

♦ Validation constraints - Whenever a typed xml instance is assigned to ormodified, SQL Server validates the instance.

♦ Data type information about the instance data - Schemas provideinformation about the types of attributes and elements in the xml datatype instance. The type information provides more precise operationalsemantics to the values. For example, decimal arithmetic operations canbe performed on a decimal value, but not on a string value. Because ofthis, typed XML storage can be made significantly more compact thanuntyped XML.

PowerDesigner models XML schema collections as extended objects with astereotype of <<XMLSchemaCollection>>.

Creating an XMLschema collection

You can create a XML schema collection in any of the following ways:

♦ Select Model ä XML Schema Collection Objects to access the List ofXML Schema Collections, and click the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä XMLSchema Collection

589

Page 602: Physical Data Model - SAP

Microsoft SQL Server 2005

XML schema collectionproperties

You can modify an object’s properties from its property sheet. To open aXML schema collection property sheet, double-click its diagram symbol orits Browser entry in the XML Schema Collection Objects folder.

The following extended attributes are available on the Microsoft tab:

Name Description

Owner Specifies the name of a user, role, or schema as theowner of the schema collection.

Scripting name: Owner

XML model Specifies a PowerDesigner XML model to link to theschema.

Scripting name: XMLModel

Content Specifies the content of the xml schema. By defaultthis field contains the %xmlModelContent% template,which represents the content of the linked XML model.

Scripting name: Content

XML table columns

You can create columns with a type of XML and store XML instances inthem.

Creating an XML tablecolumn

v To create an XML table column

1. Create a column by opening the property sheet of a table, clicking theColumns tab and clicking the Add a Row tool.

2. Open the property sheet of the new column by clicking the propertiestool, and then select XML from the list of Data types on the General tab.

3. Click the Microsoft tab and specify an XLM schema collection andcontent type.

4. Click OK to confirm your changes and close the property sheet.

XML table columnproperties

You can modify an object’s properties from its property sheet. To open anXML table column property sheet, double-click its Browser entry.

The following extended attributes are available on the Microsoft tab:

590

Page 603: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Name Description

XML schemacollection

Specifies an XML schema collection for the type.

Scripting name: XMLSchemaCollection

Content type Specifies the nature of the content to be stored in thecolumn. You can choose between:♦ CONTENT – [default] the data can contain multiple

top-level elements.

♦ DOCUMENT – the data can contain only one top-level element.

Scripting name: ContentType

Database mirroring

SQL Server 2005 supports database mirroring, in which the principal serversends, in real-time, blocks of its database log records to the mirror instancewhich, in the event of failover, can be made available within a few seconds.

PowerDesigner supports database mirroring with the following modelobjects:

♦ Databases (Mirroring tab)

♦ Endpoints

Databases

For information about creating a database object, see the “Creating adatabase” section in the Physical Data Model Basics chapter.

The following extended attributes are available on the Mirroring tab:

Name Description

Enable mirroring Enables mirroring for the database.

Scripting name: EnableMirroring

591

Page 604: Physical Data Model - SAP

Microsoft SQL Server 2005

Name Description

Partner/ Witness Specifies the role that the database will play in themirroring relationship. You can choose between:♦ Partner – the database is either a principal or mirror

database.

♦ Witness – the database acts as a witness to a mirroringrelationship. A SET WITNESS clause affects bothcopies of the database, but can only be specified onthe principal server. If a witness is set for a session,a quorum is required to serve the database, regardlessof the SAFETY setting..

Scripting name: Partner, Witness

Options Specifies mirroring options for the database. You canchoose between:♦ <None>

♦ server

♦ off

♦ failover

♦ force_service_allow_data_loss

♦ resume

♦ safety full

♦ safety off

♦ suspend

♦ timeoutScripting name: MirrorOptions

Endpoints

An endpoint encapsulates a transport protocol and a port number, andenables SQL Server to communicate over the network.

Creating an endpoint You can create an endpoint in any of the following ways:

♦ Select Model ä EndPoint Objects to access the List of EndPoints, andclick the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

EndPoint

Endpoint properties You can modify an object’s properties from its property sheet. To open anendpoint property sheet, double-click its Browser entry.

592

Page 605: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

The following extended attributes are available on the Microsoft tab:

Name Description

Owner Specifies the owner of the endpoint.

Scripting name: Owner

State Specifies the state of the endpoint at creation. You canchoose between:♦ started

♦ stopped

♦ disabledScripting name: State

Protocol: Name Specifies the transport protocol to be used by the end-point. You can choose between:♦ http

♦ tcpScripting name: Protocol

Protocol: Argu-ment

Allows you to enter arguments for the chosen protocol.

Scripting name: ContentType

Language: Name Specifies the type of content to be sent. You can choosebetween:♦ soap

♦ tsql

♦ service_broker

♦ database_mirroringScripting name: Language

Language: Argu-ment

Allows you to enter arguments for the chosen language.

Scripting name: LanguageArgument

Service Broker

The service broker manages a queue of services. Applications that useService Broker communicate by sending messages to one another as part ofa conversation. The participants in a conversation must agree on the nameand content of each message. PowerDesigner supports service brokerthrough the following objects:

♦ Message types - define the type of data that a message can contain.

593

Page 606: Physical Data Model - SAP

Microsoft SQL Server 2005

♦ Contracts - define which message types an application uses to accomplisha particular task.

♦ Queues - store messages.

♦ Event notifications - execute in response to a DDL statements and SQLTrace events by sending information about these events to a ServiceBroker service

♦ Services - are specific tasks or sets of tasks.

Message types

Message types define the type of data that a message can contain. You createidentical message types in each database that participates in a conversation.

Message types specify the type of XML validation that SQL Server performsfor messages of that type. For arbitrary or binary data, the message type canspecify that SQL Server performs no validation.

Creating a message type You can create a message type in any of the following ways:

♦ Select Model ä MessageType Objects to access the List ofMessageTypes, and click the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

MessageType

Message type properties You can modify an object’s properties from its property sheet. To open amessage type property sheet, double-click its Browser entry.

The following extended attributes are available on the Microsoft tab:

Name Description

Authorization Specifies a database user or role as the owner of themessage type. If the current user is dbo or sa, this may bethe name of any valid user or role. Otherwise, it must bethe name of the current user, a user that the current userhas IMPERSONATE permission for, or a role to whichthe current user belongs. By default, the message typebelongs to the current user.

Scripting name: Owner

594

Page 607: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Name Description

Validation Specifies how the Service Broker validates the messagebody for messages of this type. You can choose between:♦ none [default] – no validation performed

♦ empty – message must contain no data

♦ well_formed_xml – message must contain well-formed XML

♦ valid_xml with schema collection – message mustconform to the specified XML schema

Scripting name: Validation

Schema Specifies the name of the schema to be used for validatingthe message contents.

Scripting name: SchemaCollectionName

Contracts

Contracts define the message types used in a Service Broker conversationand also determine which side of the conversation can send messages of thattype. Each conversation follows a contract. The initiating service specifiesthe contract for the conversation when the conversation begins. The targetservice specifies the contracts that the target service accepts conversationsfor.

You create an identical contract in each database that participates in aconversation.

Creating a contract You can create a contract in any of the following ways:

♦ Select Model ä Contract Objects to access the List of Contracts, andclick the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

Contract

Contract properties You can modify an object’s properties from its property sheet. To open acontract property sheet, double-click its Browser entry.

The following extended attributes are available on the Microsoft tab:

595

Page 608: Physical Data Model - SAP

Microsoft SQL Server 2005

Name Description

Authorization Specifies a database user or role as the owner of thecontract. If the current user is dbo or sa, this may be thename of any valid user or role. Otherwise, it must be thename of the current user, a user that the current user hasIMPERSONATE permission for, or a role to which thecurrent user belongs. By default, the contract belongs tothe current user.

Scripting name: Owner

MessageTypes tab The MessageTypes tab lists the message types included in the contract viaintermediary “message contract” objects. You can reuse an existing messagecontract or create a new one, using the tools on this tab.

Once you have added or created a message contract, double-click its entry toopen its property sheet.

The following extended attributes are available on the Microsoft tab:

Name Description

Sent by Specifies which endpoint can send a message of the in-dicated message type. Contracts document the messagesthat services can use to have specific conversations. Eachconversation has two endpoints: the initiator endpoint,the service that started the conversation, and the targetendpoint, the service that the initiator is contacting.

Scripting name: Sender

Message type Specifies the message type of the contract.

Scripting name: MessageType

Queues

When a message arrives for a service, Service Broker places the message onthe queue associated with the service

Creating a queue You can create a queue in any of the following ways:

♦ Select Model ä Queue Objects to access the List of Queues, and click theAdd a Row tool

♦ Right-click the model or package in the Browser, and select New ä

Queue

Queue properties You can modify an object’s properties from its property sheet. To open aqueue property sheet, double-click its Browser entry.

596

Page 609: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

The following extended attributes are available on the Microsoft tab:

Name Description

Owner Specifies the owner of the queue.

Scripting name: Owner

Status Specifies that the queue is available. This is the default.

If a queue is unavailable, no messages can be added toor removed from it. If you create a queue as unavailable,then no messages can be added to it until it is madeavailable with an ALTER QUEUE statement.

Scripting name: Status

Retention Specifies that all messages sent or received on con-versations using this queue are retained in the queueuntil the conversations have ended. This allows you toretain messages for auditing purposes, or to performcompensating transactions if an error occurs.

The default is to not retain messages in the queue in thisway.

Scripting name: Retention

Activation Specifies that a stored procedure is required to activatemessage processing for the queue.

Scripting name: Activation

Status (activation) Specifies that Service Broker activates the associatedstored procedure when the number of procedures cur-rently running is less than MAX_QUEUE_READERSand when messages arrive on the queue faster than thestored procedures receive messages.

This is the default.

Scripting name: ActivationStatus

Procedure Specifies the name of the stored procedure to activate toprocess messages in this queue.

Scripting name: ActivationProcedureName

MaxQueueRead-ers

Specifies the maximum number of instances of theactivation stored procedure that the queue can start atthe same time. Must be set to between 0 and 32767.

Scripting name: ActivationMaxQueueReaders

597

Page 610: Physical Data Model - SAP

Microsoft SQL Server 2005

Name Description

Execute as Specifies the user under which the activation storedprocedure runs. SQL Server must be able to checkthe permissions for this user at the time that the queueactivates the stored procedure. You can choose between:♦ SELF - the stored procedure executes as the current

user. (The database principal executing this CRE-ATE QUEUE statement.)

♦ OWNER - the stored procedure executes as theowner of the queue.

Scripting name: ActivationExecuteAs

File group Specifies the SQL Server filegroup on which to createthe queue.

Scripting name: FileGroup

Event Notifications

An event notification sends information about a database or server event to aservice broker service. Event notifications are created only by usingTransact-SQL statements.

Creating an eventnotification

You can create an event notification in any of the following ways:

♦ Select Model ä EventNotification Objects to access the List ofEventNotifications, and click the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

EventNotification

Event notificationproperties

You can modify an object’s properties from its property sheet. To open anevent notification property sheet, double-click its Browser entry.

The following extended attributes are available on the Microsoft tab:

598

Page 611: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Name Description

Applies on Specifies the scope of the event notification. You canchoose between:♦ database – the notification fires whenever the speci-

fied event in the FOR clause occurs anywhere in theinstance of SQL Server.

♦ server - the notification fires whenever the speci-fied event in the FOR clause occurs in the currentdatabase.

♦ queue - the notification fires whenever the spec-ified event in the FOR clause occurs in thecurrent queue. Can be specified only if FORQUEUE_ACTIVATION or FOR BROKER_-QUEUE_DISABLED is also specified.

Scripting name: AppliesOn

Queue Specifies the queue to which the event notificationapplies. Available only if Applies on is set to “queue”.

Scripting name: Queue

With fan in Instructs SQL Server to send only one message per eventto any specified service for all event notifications that:♦ are created on the same event

♦ are created by the same principal (as identified bySID).

♦ specify the same service and broker_instance_-specifier.

♦ specify WITH FAN_IN.Scripting name: WithFanIn

Events Specifies the name of the event type that causes the eventnotification to execute. Can be a Transact-SQL DDL,SQL Trace, or Service Broker event type.

Scripting name: Events

Service Specifies the target service that receives the event in-stance data. SQL Server opens one or more conversa-tions to the target service for the event notification. Thisservice must honor the same SQL Server Events messagetype and contract that is used to send the message. See“Services” on page 600.

Scripting name: Service

599

Page 612: Physical Data Model - SAP

Microsoft SQL Server 2005

Name Description

Instance Specifies a service broker instance against whichbroker_service is resolved. Use ‘current database’to specify the service broker instance in the currentdatabase.

Scripting name: Instance

Services

Services are specific tasks or set of tasks. Service Broker uses the name ofthe service to route messages, deliver messages to the correct queue within adatabase, and enforce the contract for a conversation.

Creating a service You can create a service in any of the following ways:

♦ Select Model ä Service Objects to access the List of Services, and clickthe Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

Service

Service properties You can modify an object’s properties from its property sheet. To open aservice property sheet, double-click its Browser entry.

The following extended attributes are available on the Microsoft tab:

Name Description

Authorization Specifies the owner of the service.

Scripting name: Owner

Queue Specifies the queue that receives messages for the ser-vice. The queue must exist in the same database as theservice.

Scripting name: Queue

The Contracts tab lists the contracts with which the service is associated.

Routes

Appears in the routing table for the database. For outgoing messages,Service Broker determines routing by checking the routing table in the localdatabase. For messages on conversations that originate in another instance,including messages to be forwarded, Service Broker checks the routes inmsdb.

Creating a route You can create a route in any of the following ways:

600

Page 613: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

♦ Select Model ä Route Objects to access the List of Routes, and click theAdd a Row tool

♦ Right-click the model or package in the Browser, and select New ä Route

Route properties You can modify an object’s properties from its property sheet. To open aroute property sheet, double-click its Browser entry.

The following extended attributes are available on the Microsoft tab:

Name Description

Owner Specifies the owner of the route.

Scripting name: Owner

Remote service Specifies the name of the remote service to which theroute points.

Scripting name: Service

Broker instance Specifies the database that hosts the target service.

Scripting name: BrokerInstance

Lifetime Specifies the amount of time, in seconds, that SQLServer retains the route in the routing table.

Scripting name: Lifetime

Address Specifies the network address for the route. The next_-hop_address specifies a TCP/IP address in the followingformat:

TCP://{ dns_name | netbios_name | ip_address } : port_-number

Scripting name: Address

Mirror address Specifies the network address for a mirrored databasewith one mirrored database hosted at the next_hop_-address. The next_hop_mirror_address specifies aTCP/IP address in the following format:

TCP://{ dns_name | netbios_name | ip_address } : port_-number

Scripting name: MirrorAddress

Remote service bindings

Creates a binding that defines the security credentials to use to initiate aconversation with a remote service.

601

Page 614: Physical Data Model - SAP

Microsoft SQL Server 2005

Creating a remoteservice binding

You can create a remote service binding in any of the following ways:

♦ Select Model ä RemoteServiceBinding Objects to access the List ofRemoteServiceBindings, and click the Add a Row tool

♦ Right-click the model or package in the Browser, and select New ä

RemoteServiceBinding

Remote service bindingproperties

You can modify an object’s properties from its property sheet. To open aremote service binding property sheet, double-click its Browser entry.

The following extended attributes are available on the Microsoft tab:

Name Description

Owner Specifies the owner of the binding.

Scripting name: Owner

Remote service Specifies the remote service to bind to the user identifiedin the WITH USER clause.

Scripting name: RemoteService

User Specifies the database principal that owns the certificateassociated with the remote service identified by the TOSERVICE clause.

Scripting name: User

Anonymous Specifies that anonymous authentication is used whencommunicating with the remote service.

Scripting name: Anonymous

Synonyms

PowerDesigner supports SQL Server 2005 synonyms through the standardsynonym object.

Synonyms can be created for the following types of objects:

♦ Assembly (CLR) Stored Procedure

♦ Assembly (CLR) Table-valued Function

♦ Assembly (CLR) Scalar Function

♦ Assembly Aggregate (CLR) Aggregate Functions

♦ Replication-filter-procedure

602

Page 615: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

♦ Extended Stored Procedure

♦ SQL Scalar Function

♦ SQL Table-valued Function

♦ SQL Inline-table-valued Function

♦ SQL Stored Procedure

♦ View

♦ Table

For more information about synonyms, see the “Building PhysicalDiagrams” chapter

Microsoft SQL Server 2005 Analysis Services

PowerDesigner, allows you to retrieve multiple dimension objects in a PDMin order to build Cubes, and to create a new multiple-dimension diagram.From this diagram, you can generate cubes to a Microsoft SQL Server 2005Analysis Server (SSAS).

SQL Server 2005 Management Tools requiredIn order to use the analysis services add-in to generate and reverse-engineercubes, you must have installed the SQL Server 2005 Management Toolsclient component.

v To enable PowerDesigner support for Analysis Services

1. Select Tools ä General Options, and select the Add-ins category in theleft-hand pane.

2. Select the Microsoft SQL Server 2005 Analysis Services add-in(PowerDesigner.AddIn.Pdm.SQLServer.dll) and then click OK to installit and return to the model.

+ For more information, see “Managing add-ins” in the “Using thePowerDesigner Interface” of the General Features Guide .

Generating cubes

The Microsoft SQL Server 2005 Analysis Services add-in enables thegeneration of cubes.

Before generating cubes, you must define a data source with an OLE DBconnection that will specify from where the cubes will be populated.

603

Page 616: Physical Data Model - SAP

Microsoft SQL Server 2005

v To specify a data source for a cube

1. Create a data source in your PDM from the List of data sources or byright-clicking the model in the browser and selecting New ä Data Sourcefrom the contextual menu.

2. Select the OLE DB tab and specify the kind of data provider

3. Click the ellipsis tool to the right of the connection string field to openthe provider-specific configuration dialog.

604

Page 617: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

4. Complete the parameters appropriately, click Apply to Connection String,and then Test Connection. Then click Ok to return to the data sourceproperty sheet.

5. Click OK to return to your model.

When you have created the appropriate data sources, you can proceed withgenerating your cubes.

605

Page 618: Physical Data Model - SAP

Microsoft SQL Server 2005

v To generate cubes

1. Select Tools ä Microsoft SQL Server 2005 Analysis Services ä GenerateCubes to open the wizard.

Click Next to continue.

2. Enter a server name, and select the database you want to generate to:

606

Page 619: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Click Next to continue.

3. The Select Cubes page lists the cubes available in the model, along withwhether they currently exist in the database. Select the cubes you want togenerate:

607

Page 620: Physical Data Model - SAP

Microsoft SQL Server 2005

Click Next to continue.

4. The Generate Cubes page lists the cubes to be generated:

Click Finish to begin generation. Progress is displayed in the wizard,which will close automatically after successful completion.

If a cube already exists in the database, it is dropped and recreated. If arelated dimension already exists, it is reused. To fully generate a cube,your model must include a complete mapping to a table.

Reverse engineering Microsoft SQL Server 2005 cubes

The Microsoft SQL Server 2005 Analysis Services add-in enables thereverse engineering of cubes.

Before reverse-engineering cubes, you should create one or more PDMs tomodel the tables which provide its data. As part of the reverse-engineeringprocess, PowerDesigner will create links from the reversed cubes to thesetables.

608

Page 621: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

v To reverse engineer cubes

1. Select Tools ä Microsoft SQL Server 2005 Analysis Services ä ReverseEngineer Cubes to open the wizard.

Click Next to continue.

2. Enter a server name, and select the database you want to reverse from:

609

Page 622: Physical Data Model - SAP

Microsoft SQL Server 2005

Click Next to continue.

3. The Select Cubes page lists the available cubes. Select the cubes youwant to reverse engineer and then click Next to continue:

610

Page 623: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

4. The Configure Data Sources page lists the data sources that are requiredto populate the selected cubes. For each source, select the Physical DataModel in which the tables are modeled, and then click Next to continue:

5. The Reverse Engineer Cubes page lists the cubes to be reversed:

611

Page 624: Physical Data Model - SAP

Microsoft SQL Server 2005

Click Finish to begin reverse-engineering. Progress is displayed in thewizard, which will close automatically after successful completion.

Miscellaneous additional features

The following additional features are also available for SQL Server 2005:

♦ User Schemas – Use the schema stereotype to specify that a user isactually a schema, belonging to another user (the “principal”).

♦ WithOption – Use the withoptions type to enable access to additionalphysical options when working with views.

♦ Support for multiple databases during live database reverse engineering.

612

Page 625: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

MySQLNote that when developing for MySQL and using double quotes as adelimiter, it is necessary to set the sql_mode to ANSI_QUOTES:

SET sql_mode=’ANSI_QUOTES’

This section describes features specific to the MySQL family of databases.

MySQL extended attributes

The following extended attributes are defined by default in the MySQLDBMS.

Columns The following extended attributes are available on the MySQL tab:

Name Description

Character set Character set (set of symbols and encodings).

Scripting name: CharSet

Collation Collation (set of rules for comparing characters in a characterset).

Scripting name: Collate

National A way to indicate that a CHAR column should use UTF8character set.

Scripting name: National

Unsigned Indicates negative values are not allowed for the column.

Scripting name: Unsigned

Retrievewith lead-ing zeros

When displayed, the default padding of spaces is replacedwith zeros. For example, for a column declared as INT(5)ZEROFILL, a value of 4 is retrieved as 00004.

If you specify ZEROFILL for a numeric column, MySQLautomatically adds the UNSIGNED attribute to the column.

Scripting name: ZeroFill

Indexes The following extended attributes are available on the Extended Attributestab:

Name Description

[none] Indicates that the index is a full text index.

Scripting name: FullText

613

Page 626: Physical Data Model - SAP

MySQL

Keys The following extended attributes are available on the Extended Attributestab:

Name Description

[none] When set to True, indicates that the key is unique. Falseimplies that the key allows duplicate values.

Scripting name: ExtUnique

Models The following extended attributes are available on the Extended Attributestab:

Name Description

[none] Indicates the type of the database, as specified in the extendedattribute type DatabaseType.

Scripting name: DatabaseType

References The following extended attributes are available on the Extended Attributestab:

Name Description

[none] Indicates the reference match type, as specified in the ex-tended attribute type ReferenceMatchType.

Scripting name: ReferenceMatch

614

Page 627: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

NonStop SQLThis section describes features specific to the NonStop SQL family ofdatabases.

NonStop SQL extended attributes

The following extended attributes are defined by default in the NonStopSQL DBMS.

Columns The following extended attributes are available on the Extended Attributestab:

Name Description

[none] Specifies an extended type for columns, listed in extendedattribute type TExtType.

Scripting name: ExtType

615

Page 628: Physical Data Model - SAP

Oracle

OracleThis section describes features specific to the Oracle family of databases.These features include:

♦ Variables for triggers

♦ Object and SQLJ object data types

♦ Bitmap join indexes

♦ Reverse engineering tablespace physical options

♦ Reverse engineering ASC/DESC indexes

♦ Dimensions management

♦ Transparent Data Encryption (TDE)

♦ Extended attributes

Special variables for triggers

You can use the following variables with Oracle:

♦ TRGBODY

♦ TRGDESC

Object and SQLJ object data types

Oracle v8 and higher allows you to specify a table type of “Object”, and tobase the table on an object or SQLJ object abstract data type, so that thetable uses the properties of the ADT and the ADT attributes become tablecolumns.

616

Page 629: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

+ For more information on ADTs, see your Oracle documentation.

v To create an object (or SQLJ object) data type

1. Select Model ä Abstract Data Types to open the List of Abstract DataTypes, and then click the Add a Row tool and enter a name for the newADT.

2. Click the Properties tool to open the new ADT property sheet.

3. Select OBJECT or SQLJ_OBJECT from the Type list.

Additional Attributes and Procedures tabs will be displayed in the ADTproperty sheet.

4. Click the Attributes tab, and then click the Add a Row tool:

617

Page 630: Physical Data Model - SAP

Oracle

5. Specify a name and code, and select a data type from the list.

Display the column you needIf you do not see the column you need, display it with the CustomizeColumns and Filter tool.

6. Add additional attributes as necessary, and then click OK to close each ofthe property sheets.

When you have created your new data type, you can base tables on it.

618

Page 631: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

v To base a table on an object (or SQLJ object) data type

1. Open a table property sheet, and select Object in the Type list.

2. Select the new object (or SQLJ object) data type in the Based on list.

3. Click Ok to close the property sheet and return to your model.

Bitmap join indexes

A bitmap join index is a bitmap index described through a join query. Itstores the row ids from one base table along with the indexed columns fromthe joined tables.

A bitmap join index is defined on a single table, called the base table.

+ For more information about bitmap join indexes, see your Oracledocumentation.

You can design a bitmap join index:

♦ Automatically, by creating bitmap join indexes from all references linkedto a fact table through the Rebuild join index command

619

Page 632: Physical Data Model - SAP

Oracle

♦ Manually, by creating a bitmap join index in the list of join indexes orfrom a table property sheet

Automatically creating bitmap join indexes through rebuilding

You can automatically generate a bitmap join index for each fact table andthe dimension tables that it references. Each generated bitmap join indexconsists of the references that link a fact table to all the dimension tableslocated on a single axis proceeding from the fact table.

A reference between two fact tables does not generate any bitmap join index.A bitmap join index is constrained and can only be defined for tables that areorganized in a connected tree.

v To rebuild bitmap join indexes for all references linked to a facttable1. Select Tools ä Rebuild Objects ä Rebuild Join Indexes to open the

Rebuild Join Indexes dialog box, and select one of the following modes:♦ Delete and Rebuild - all existing indexes are deleted before join index

rebuild.

♦ Preserve - preserves all existing join indexes in the PDM

2. Click the Selection tab, select one or more fact tables in the list, and thenclick OK.

A confirmation box asks if you want to continue.

620

Page 633: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

3. Click Yes to generate a bitmap join index for each fact table.

Displaying automatically generated bitmap join indexesAutomatically generated bitmap join indexes appear in the list of joinindexes. To display the list, select Model ä Join Indexes.

Manually creating bitmap join indexes

You can manually create bitmap join indexes from the list of join indexes orvia the base table property sheet.

v To create a bitmap join index in the list of join indexes

1. Select Model ä Join Indexes to open the List of Join Indexes.

2. Click the Add a Row tool and enter a bitmap join index name in theName column.

3. Click the Properties tool to open the new bitmap join index propertysheet.

4. Select a base table on the General tab, and then click the References tab.

5. Click the Add References tool to open a selection window, which lists theavailable references depending on the selected base table. Select one ormore references in the list, and then click OK.

The selected reference is displayed in the References list.

621

Page 634: Physical Data Model - SAP

Oracle

6. Click the Columns tab, and then click the Add Columns tool to open aselection window, which lists the available columns depending on theselected references. Select one or more columns in the list, and then clickOK.

The selected columns is displayed in the Columns list.

7. Click OK to complete the creation of the bitmap join index and return tothe model.

You can create a join index or a bitmap join index from the Join Index tab ofa table property sheet. The bitmap join index will be based on the table.

v To create a bitmap join index from the table property sheet

1. Open the property sheet of a table and click the Join Index tab.

2. Click the Insert a Row or the Add a Row tool to create a new bitmap joinindex associated with the table.

3. Click the Properties tool to display the new bitmap join index propertysheet. The Base table box is initialized with the selected table.

Bitmap join index properties

+ A bitmap join index has the following properties:

622

Page 635: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users.

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces.

Comment Additional information about the bitmap join index.

Stereotype Sub-classification among bitmap join indexes.

Owner Name of the user who created the bitmap join index.

Base table Name of the table that stores the bitmap join index.

Columns tab + The bitmap join index stores information about the columns used for theindex. These columns are displayed in the Columns tab of the bitmap joinindex property sheet.

Options tab You can define physical options for bitmap join indexes generation. Theseoptions override the default physical options defined in the model. You canchoose to generate these options by selecting the Physical Options checkbox in the Join Index groupbox in the Keys and Indexes tab of theGeneration dialog box.

Adding a column to a bitmap join index

+ You can define the list of columns involved in the bitmap join index.These columns proceed from the different dimension tables linked to thebase table.

+ When you create a bitmap join index manually, you have to selectcolumns using the list of columns in the bitmap index property sheet.

+ When you create a bitmap join index using the rebuild join indexfeature, the list of columns is initialized with all columns of the tablesinvolved in the join except foreign keys.

v To add a column to a bitmap join index

1. Open the bitmap join index property sheet and make sure the bitmap joinindex has a base table.

2. Click the Columns tab and then click the Add Columns tool.

A selection dialog box is displayed, which lists columns to include in thejoin depending on the selected references.

623

Page 636: Physical Data Model - SAP

Oracle

3. Select one or more columns in the list and click OK.

The columns appear in the list of bitmap join index columns.

4. Click OK.

Adding a reference to a bitmap join index

You can add a reference to any bitmap join index. You do this, for example,when you create a new reference that you want to include in an existingbitmap join index.

v To add a reference to a bitmap join index

1. Select Model ä Join Indexes to open the List of Join Indexes.

2. Select a bitmap join index in the list and then click the Properties tool toopen its property sheet.

3. Click the References tab, and then click the Add References tool.

A selection dialog box is displayed. It displays available referencesdepending on the selected base table.

4. Select one or several references in the list.

5. Click OK to add the new reference to the References list:

624

Page 637: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

6. Click OK to close the bitmap join index property sheet.

Database package

In Oracle, packages encapsulate related procedures, functions, andassociated cursors and variables together as a unit in the database. Packagesusually have two parts, a specification and a body. The specification is theinterface with your applications; it declares the types, variables, constants,exceptions, cursors, and subprograms available for use. The body fullydefines cursors and subprograms, and so implements the specification.

Packages provide advantages in the following areas:

♦ Encapsulation of related procedures and variables in a single named,stored unit in the database. This provides for better organization duringthe development process and makes privilege management easier

♦ Separation of public and private procedures, variables, constants, andcursors

♦ Better performance since entire package is loaded into memory when anobject from the package is called for the first time

Defining a database package

A database package is not a standard PowerDesigner package.

You define a database package with the following properties:

625

Page 638: Physical Data Model - SAP

Oracle

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users.

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces.

Comment Additional information about the database package.

Stereotype Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined.

Owner Name of database package owner. You choose an ownerfrom a list of users. A database package can only have oneowner at a time.

Privilege Lets you specify whether the functions and procedures inthe database package execute with the privileges and inthe schema of the user who owns it (definer), or with theprivileges and in the schema of CURRENT_USER (invoker).

The definition of a database package also includes the definition ofprocedures, variables, cursors, exceptions, types, and initializationparameters as explained in the following sections.

v To create a database package

1. Select Model ä Database Packages to open the List of DatabasePackages..

2. Click the Add a Row tool to add a database package to the list, and thenclick the Properties tool to display its property sheet.

3. Type a name and a code for the database package.

4. [optional] Select an Owner and/or Privilege for the database package.

626

Page 639: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

5. Click OK to complete the creation of the database package.

Inserting procedures in a database package

A database package is a set of related procedures. When you create adatabase package you have to declare the procedures it contains.

PowerDesigner differentiates between:

♦ A procedure created in the model

♦ A procedure created in a database package. This procedure only exists inthe database package and disappears when you delete the package. In thissection, we call it package procedure. You can create a packageprocedure from a model procedure using the copy feature

v To insert procedures in a database package

1. Click the Procedures tab in the database package property sheet todisplay the Procedures tab.

2. Click the Insert a Row tool if you want to create procedures in thedatabase package.

or

627

Page 640: Physical Data Model - SAP

Oracle

Click the Create from Procedure tool if you want to duplicate existingprocedures in the database package. Select the procedures and click OK.

The procedures appear in the list.

3. Click Apply.

4. Select a procedure in the list and click the Properties button to display itsproperty sheet.

5. Define the procedure in the property sheet.

6. Click OK in each of the dialog boxes.

Defining a package procedure

A package procedure is created in a database package and exists only in thispackage. If you delete the database package you also delete the procedures itcontains.

A package procedure has the following properties:

628

Page 641: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Property Description

Name The name of the item which should be clear and meaning-ful, and should convey the item’s purpose to non-technicalusers.

Code The technical name of the item used for generating codeor scripts, which may be abbreviated, and should notgenerally include spaces.

Comment Additional information about the package procedure.

Stereotype Sub-classification used to extend the semantics of anobject without changing its structure; it can be predefinedor user-defined.

DB Package Name of the database package to which the procedurebelongs.

Type Allows you to choose between procedure and function.

Return datatype

Allows you to define the return data type of a function.

Pragma Allows you to type a compiler directive, that is, a stringfor specifying compilation parameters for the procedure.

Public Allows you to declare the procedure in the packagespecification and to permit use from outside the databasepackage. A private procedure (check box deselected) isonly defined in the package body.

Parameters The Parameters tab lets you define the input and output values forprocedures.

For example, in the CREDIT procedure, you have to define the followingparameters:

629

Page 642: Physical Data Model - SAP

Oracle

Definition The Definition tab lets you define package procedures. Package proceduresare not built using the structure of templates defined in the DBMS. You haveto type the entire package procedure definition. To do so, you can useoperators and functions to insert script items into the cursor definition.

For example, the definition of the CREDIT package procedure is thefollowing:

CREATE PROCEDURE credit (Account_number NUMBER, Amount INNUMBER) AS

BEGINUPDATE accountsSET balance = balance + amountWHERE account_id = acc_no;END;

Defining variables in a database package

Variables can be declared within a package. A variable can be used in a SQLor PL/SQL statement to capture or provide a value when one is needed.

For example, you can define the variable in_stock with a boolean data typeto verify if a product is available or not.

630

Page 643: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Variables have the following properties:

Property Description

Name The name of the item which should be clear and meaning-ful, and should convey the item’s purpose to non-technicalusers.

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces.

Comment Additional information about the variable.

DB Package Name of the database package to which the variablebelongs.

Data Type Data type of the variable. You can use the Question Markbutton to display the list of Standard Data Types.

Mandatory If selected, indicates that the not null clause is set on thevariable, thus making it mandatory.

Length Allows you to define the variable length.

Precision Number of places after the decimal point, for data valuesthat can take a decimal point.

Default value Default value of the variable.

631

Page 644: Physical Data Model - SAP

Oracle

Property Description

Constant Indicates that the variable is a constant. A constant has avalue assigned. For example: Credit_Limit constant REAL:= 500 000;

Public Allows you to declare the variable in the package specifica-tion and to permit use from outside the database package.A private variable (check box deselected) is only defined inthe package body.

Defining cursors in a database package

In application development, a cursor is a multi-row query.

In Oracle, a cursor lets you name a work area and access its storedinformation.

Cursors have the following properties:

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users.

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces.

Comment Additional information about the cursor.

DB Package Name of the database package to which the cursor belongs.

Return DataType

Allows you to define the data type of a cursor result value.

Public Allows you to declare the cursor in the package specificationand to permit use from outside the database package. Aprivate cursor (check box deselected) is only defined in thepackage body.

Parameters The Parameters tab lets you define the input values for cursors.

For example, you can define a parameter “num” and use it in the cursor todefine the cursor input value. See example below.

Definition The Definition tab lets you define the cursor. You can use operators andfunctions to insert script items into the cursor definition.

632

Page 645: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

For example, the following cursor allows locating in table emp, theemployee number, name, and function in a given department and for a givenemployee number:

Defining exceptions in a database package

PL/SQL allows you to explicitly handle internal and user-defined errorconditions, called exceptions, that arise during processing of PL/SQL code.

You can create user-defined exceptions linked to the database packagebehavior.

Exceptions have the following properties:

Properties Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users.

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces.

Comment Additional information about the exceptions.

DB Package Name of the database package to which the exceptionbelongs.

Pragma Allows you to type a compiler directive, that is, a string forspecifying compilation parameters for the exception.

633

Page 646: Physical Data Model - SAP

Oracle

Defining types in a database package

A type is a user-defined composite datatype that encapsulates a datastructure along with the functions and procedures needed to manipulate thedata. You can also define subtypes of object types: a subtype contains all theattributes and methods of the parent type, it can contain additional attributesand can override methods from the type.

Types have the following properties:

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users.

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces.

Comment Additional information about the type.

DB Package Name of the database package to which the type belongs.

Type Allows you to declare the type as type or subtype.

Public Allows you to declare the type in the package specificationand to permit use from outside the database package. Aprivate type (check box deselected) is only defined in thepackage body.

Definition This tab is used to declare the type contents.

The following example defines the type bank_account:

CREATE TYPE Bank_Account AS OBJECT (acct_number INTEGER(5),balance REAL,status VARCHAR2(10),);

Defining database package initialization

The Initialization tab lets you define initialization code for the databasepackage body. Typically initialization holds statements that initializedatabase package variables. Initialization takes place after database packagecreation and compilation in the server.

In the following example, the variable bonus is declared in the initializationpart of the database package body:

634

Page 647: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Defining database package parameters

The Parameters tab lets you define the input and output values forprocedures and cursors.

For example, in the CREDIT procedure, you have to define the parametersAccount Number and Amount.

+ For more information on database package procedures, see “Defining apackage procedure” on page 628.

+ For more information on database package cursors, see “Definingcursors in a database package” on page 632.

Rebuilding database package procedures

You can rebuild database package procedure dependencies (along with otherprocedure dependencies) by selecting Tools ä Rebuild Objects ä RebuildProcedures Dependencies. For more information, see “Rebuilding proceduredependencies” in the Building Triggers and Procedures chapter.

Generating database packages

You can define generation parameters for database packages in the Database

635

Page 648: Physical Data Model - SAP

Oracle

Package tab of the Triggers and Procedures Generation dialog box. This tabis displayed when the current DBMS belongs to the Oracle family.

The following parameters are available:

Parameter Resulting generation command

Createdatabase pack-age

Create database package, as defined in the Oracle DBMS:create package %DBPACKAGE% [authid

%DBPACKAGEPRIV%][[%R%?[is][as]:as]

%DBPACKAGESPEC%

end [%DBPACKAGE%]/

[create package body %DBPACKAGE% AS

%DBPACKAGEBODY%

[BEGIN

%DBPACKAGEINIT%] ]

end [%DBPACKAGE%]

]

Drop databasepackage

Drop database package, as defined in the Oracle DBMS:drop package %DBPACKAGE%

Permission Generate the permission statement for a given user duringdatabase package creation.

+ For more information on the create and drop statements for databasepackages, see chapter DBMS Reference Guide in the Advanced UserDocumentation .

Reverse engineering database packages

You can select database packages to reverse engineer from the DatabasePackage tab of the Database Reverse Engineering dialog box.

When you reverse engineer a database package, the sub-objects (variable,procedure, cursor, exception, and type) are created from the specificationand the body of the database package.

Reverse engineering tablespace physical options

In Oracle, you cannot reverse engineer tablespace physical options via a livedatabase connection without a login “System”.

636

Page 649: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

If you do not have a login “System”, the list of tablespaces is reversedwithout the physical options of the objects.

If you want to cancel the reverse engineering of tablespace physical options,you have to clear the query SqlAttrQuery in the Tablespace category inthe Oracle DBMS.

Managing Oracle dimensions

You can design Oracle dimensions using dimensions in a PDMmultidimensional diagram.

In Oracle, the columns of the dimension table are called levels of thedimension hierarchy. These levels can have dependent columns, forexample, in dimension Time, level Quarter has a dependent column calledNumber of business days.

The following mapping is established between dimensions in Oracle andPowerDesigner:

Oracle object PowerDesigner object

Dimension Dimension

Hierarchy Dimension hierarchy

Level Dimension attribute used in a hierarchy

Attribute Dimension attribute used as detail attribute

Oracle dimension creation and deletion orders can be generated and reverseengineered in PowerDesigner. Both generation and reverse engineering canbe done by script or through a live database connection.

+ For more information on dimensions, see the Building MultidimensionalDiagrams chapter.

Generating Oracle dimensions

Dimensions are generated, along with all other types of objects by selectingDatabase ä Generate Database. For more information, see the “Generating aDatabase” section in the “Generating a Database from a PDM” chapter.

Transparent Data Encryption (TDE)

Oracle 10gR2 provides Transparent Data Encryption (TDE), encryption thatis transparent for the user.

When encrypting a column, Oracle creates an encryption key for the parent

637

Page 650: Physical Data Model - SAP

Oracle

table and encrypts text data in the column with a user-specified encryptionalgorithm. The table key is encrypted using a master key and placed in thedata dictionary. The master key is stored in a secure location called a wallet,which can be a file on the database server. When a user enters data into anencrypted column, Oracle retrieves the master key from the wallet, decryptsthe table key from the data dictionary, and uses it to encrypt the new data.

Creating a wallet password

In order to access the master key used to encrypt the table keys, you mustcreate a master password to open the wallet.

v To create a wallet password

1. Right-click the model in the Browser, and select Properties from thecontextual menu to open its property sheet.

2. Click the Oracle tab, and enter your wallet password in the PasswordEncryption field.

3. Click OK to close the model property sheet. The password will be usedto create alter statements for opening and closing the wallet.

Creating an encrypted table column

You can create one or more encrypted column in one or more tables. Youcan specify the encryption algorithm to be used, but all columns in aparticular table must use the same algorithm. If you create a secondencrypted column in a table, and specify a different algorithm, the lastspecified algorithm will be used for all columns in the table.

v To encrypt a table column

1. Create a column and open its property sheet.

2. On the General tab, specify any of the following types, which supportencryption:

♦ CHAR, NCHAR, VARCHAR2, and NVARCHAR2

♦ DATE and TIMESTAMP

♦ INTERVAL DAY TO SECOND and YEAR TO MONTH

♦ NUMBER

♦ RAW

3. Click the Oracle tab and select the Encryption checkbox.

4. Select an encryption algorithm from the list particular

638

Page 651: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

5. [optional] Select the With salt checkbox in order to add some random bitsto the encryption key.

6. Click OK to complete the column definition.

Oracle extended attributes

The following extended attributes are defined by default in the OracleDBMS.

Abstract Data Types The following extended attributes are available for attributes of abstract datatypes of type OBJECT or SQLJ_OBJECT on the Oracle tab:

Name Description

Declare REF Generates a REF modifier on attribute to declare references,which hold pointers to objects.

Scripting name: RefAttribute

Columns The following extended attributes are available on the Oracle tab:

Name Description

Deferred op-tion of checkconstraint

Defines the deferred option of a column constraint check. Itis used in the definition or create and add items statements.

Scripting name: ExtColumnDeferOption

Name of notnull con-straint

Defines the name of the not null constraint for a column.

Scripting name: ExtNotNullConstraintName

Deferred op-tion of notnull con-straint

Defines the deferred option of a column not null constraint.It is used in “create” and “add” statement items definition.

An empty value means “Not deferrable”.

Scripting name: ExtNotNullDeferOption

Database Packages The following extended attributes are available on the Oracle tab:

639

Page 652: Physical Data Model - SAP

Oracle

Name Description

Add serially_-reusable pragmaon package specifi-cation

When set to True, defines that the pragma serially_-reusable clause must be applied on the databasepackage specification.

Scripting name: IsSpecPragma

Add serially_-reusable pragmaon package body

When set to True, defines that the pragma serially_-reusable clause must be applied on the databasepackage body declaration.

Scripting name: IsPragma

References The following extended attributes are available on the Oracle tab:

Name Description

Deferred option offoreign key con-straint

Defines the deferred option of a reference. It is usedin the definition of create and add items statements.

Scripting name: ExtReferenceDeferOption

Tables The following extended attributes are available on the Oracle tab:

Name Description

Type Defines if the table is of type global temporary or not.

Scripting name: ExtTableType

Tablespaces The following extended attributes are available on the Oracle tab:

Name Description

Size specifi-cation

Specifies whether the tablespace is a bigfile or smallfiletablespace. This clause overrides any default tablespace typesetting for the database. You can choose from the followingsettings:♦ bigfile - contains only one datafile or tempfile. The maxi-

mum size of the single datafile or tempfile is 128 terabytes(TB) for a tablespace with 32K blocks and 32TB for a ta-blespace with 8K blocks.

♦ smallfile - a traditional Oracle tablespace.Scripting name: SizeSpecification

640

Page 653: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Name Description

Temporarytablespace

Use this option to create a locally managed temporarytablespace, which is an allocation of space in the databasethat can contain transient data that persists only for theduration of a session. This transient data cannot be recoveredafter process or instance failure.

Scripting name: Temporary

Undo ta-blespace

Use this option to create an undo tablespace. When you runthe database in automatic undo management mode, OracleDatabase manages undo space using the undo tablespaceinstead of rollback segments. This clause is useful if you arenow running in automatic undo management mode but yourdatabase was not created in automatic undo managementmode.

Scripting name: Undo

Views The following extended attributes are available on the Oracle tab:

Name Description

Super viewobject

Used in the UNDER clause to specify the superview thecurrent object view is based on.

Scripting name: ExtObjSuperView

Object viewkey

Specifies the attributes of the object type that will be used asa key to identify each row in the object view.

Scripting name: ExtObjOIDList

Object viewtype

Defines the type of the object view.

Scripting name: ExtObjViewType

Force When set to TRUE, allows you to create the view regardlessof the existence of the base tables or the owner privileges onthese tables.

Scripting name: ExtViewForce

641

Page 654: Physical Data Model - SAP

PostgreSQL

PostgreSQLThis section describes features specific to the PostgreSQL family ofdatabases.

PostgreSQL base and composite type domains

PowerDesigner supports the following special PostgreSQL data types:

♦ Base Type

♦ Composite Type

v To create a base or composite type

1. Select Model ä Domains to open the List of Domains

2. Click the Add a Row tool to create a new domain, and then click theProperties tool to open its property sheet.

3. Select either BaseType or CompositeType from the Stereotype list andclick Apply .

4. An additional tab called either Base Type or Composite Type will bedisplayed, allowing you to specify type-specific extended attributes. Seethe relevant section in the ““PostgreSQL extended attributes” onpage 642” section, for details of these properties.

PostgreSQL extended attributes

The following extended attributes are defined by default in the PostgreSQLDBMS.

Database The following extended attributes are available on the PostgreSQL tab:

Name Description

Template The name of the template from which to create the newdatabase, or DEFAULT to use the default template.

Scripting name: Template

Encoding Character set encoding to use in the new database. Specify astring constant (e.g., ‘SQL_ASCII’), or an integer encodingnumber, or DEFAULT to use the default encoding.

Scripting name: Encoding

Domain (Base Type) The following extended attributes are available on the Base Type tab:

642

Page 655: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Name Description

Array delim-iter

Delimiter character for the array.

Scripting name: ExtTypeDelimiter

Array Ele-ment type

Specifies the type of the array elements.

Scripting name: ExtTypeElement

Input func-tion

Name of a function, created by CREATE FUNCTION,which converts data from its external form to the internalform of the type.

Scripting name: ExtTypeInput

Length Literal value which specifies the internal length of the newtype.

Scripting name: ExtTypeLength

Output func-tion

Name of a function, created by CREATE FUNCTION,which converts data from its internal form to a form suitablefor display.

Scripting name: ExtTypeOutput

By Value Indicates that operators and functions which use this datatype should be passed an argument by value rather than byreference.

Scripting name: ExtTypePassedByValue

Receive func-tion

Name of a function, created by CREATE FUNCTION,which converts data of this type from a form suitable fortransmission from another machine to internal form.

Scripting name: ExtTypeReceive

Send function Name of a function, created by CREATE FUNCTION,which converts data of this type into a form suitable fortransmission to another machine.

Scripting name: ExtTypeSend

Domain (CompositeType)

The following extended attributes are available on the Composite Type tab:

643

Page 656: Physical Data Model - SAP

PostgreSQL

Name Description

Definition The composite type is specified by a list of attribute namesand data types. This is essentially the same as the row type ofa table, but using CREATE TYPE avoids the need to createan actual table when all that is wanted is to define a type. Astand-alone composite type is useful as the argument or returntype of a function.

Scripting name: CompositeDefinition

Groups The following extended attributes are available on the PostgreSQL tab:

Name Description

Group iden-tifier (id)

The SYSID clause can be used to choose the PostgreSQLgroup ID of the new group. This is normally not necessary,but may be useful if you need to recreate a group referencedin the permissions of some object.

Scripting name: SysId

Procedures The following extended attributes are available on the Language tab:

Name Description

Language The name of the language that the function is implementedin. May be SQL, C, internal, or the name of a user-definedprocedural language. (See also extended attribute typeProcLanguageList.)

Scripting name: ProcLanguage

References The following extended attributes are available on the PostgreSQL tab:

644

Page 657: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Name Description

Deferrable This controls whether the constraint can be deferred. Aconstraint that is not deferrable will be checked immediatelyafter every command. Checking of constraints that aredeferrable may be postponed until the end of the transaction.

Only foreign key constraints currently accept this clause. Allother constraint types are not deferrable.

Scripting name: Deferrable

Foreign keyconstraint

If a constraint is deferrable, this clause specifies the defaulttime to check the constraint.

False means the constraint is INITIALLY IMMEDIATE, it ischecked after each statement. This is the default.

True means the constraint is INITIALLY DEFERRED, it ischecked only at the end of the transaction.

Scripting name: ForeignKeyConstraintDeferred

Tables The following extended attributes are available on the PostgreSQL tab:

Name Description

Temporarystate

If specified, the table is created as a temporary table. Tempo-rary tables are automatically dropped at the end of a session,or optionally at the end of the current transaction.

Scripting name: Temporary

Tablespaces The following extended attributes are available on the PostgreSQL tab:

Name Description

Location The directory that will be used for the tablespace. Thedirectory must be specified by an absolute path name.

Scripting name: TbspLocation

Owner The name of the user who will own the tablespace. If omitted,defaults to the user executing the command. Only superusersmay create tablespaces, but they can assign ownership oftablespaces to non-superusers.

Scripting name: TbspOwner

Users The following extended attributes are available on the PostgreSQL tab:

645

Page 658: Physical Data Model - SAP

PostgreSQL

Name Description

Createdatabase

Defines a user’s ability to create databases.

If TRUE, the user is allowed to create databases.

Scripting name: CreateDB

Create user If TRUE, the user is allowed to create new users.

This option also turns the user into a superuser who canoverride all access restrictions.

Scripting name: CreateUser

Encryptedpassword

Control whether the password is stored encrypted in thesystem catalogs.

Scripting name: EncryptedPassword

User identi-fier (id)

The SYSID clause can be used to choose the PostgreSQL userID of the new user. This is normally not necessary, but maybe useful if you need to recreate the owner of an orphanedobject.

Scripting name: SysId

Validity This clause sets an absolute time after which the user’spassword is no longer valid. If this clause is omitted thepassword will be valid for all time.

Scripting name: Validity

646

Page 659: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Red Brick WarehouseThis section describes features specific to the Red Brick Warehouse familyof databases.

Red Brick Warehouse extended attributes

The following extended attributes are defined by default in the Red BrickWarehouse DBMS.

Columns The following extended attributes are available on the Red Brick tab:

Name Description

Unique Declares that duplicate values are not allowed in the column.

Declaring a column UNIQUE does not enforce uniquenesson the column; to enforce uniqueness, you must also build aBTREE index on the column.

Scripting name: IsUnique

Procedures The following extended attributes are available on the Red Brick tab:

Name Description

Macro Type A macro can be temporary, public, or private: see MacroType-List for details.

If neither temporary nor public is specified, a private macro iscreated by default.

Scripting name: MacroType

647

Page 660: Physical Data Model - SAP

Sybase AS Anywhere

Sybase AS AnywhereThis section describes features specific to the Sybase AS Anywhere familyof databases. These features include:

♦ Auto-increment columns

♦ Proxy tables

♦ Extended attributes

Note that from version 10, AS Anywhere is known as Sybase SQLAnywhere (see “Sybase SQL Anywhere” on page 671).

Auto-increment columns

Auto-increment columns are equivalent to identity columns in those DBMSthat support identity columns.

If you switch from Sybase ASA to a DBMS that supports identity columns,the Identity checkbox will be selected for each auto-increment column. Onthe other hand, if you switch to Sybase ASA, identity columns will beassigned the autoincrement default value.

When you reverse engineer a script containing identity columns (usingSybase ASE-compatible syntax), these are automatically converted intoauto-increment columns in Sybase ASA.

Working with proxy tables in Sybase ASA and ASE

A proxy table is used to access data in a remote table, it has all the attributesof the remote table, but it does not contain any data locally.

PowerDesigner can generate the script for a proxy table in order to run it in aSybase ASA or ASE database. To do so, you need to attach the ProxyTablesextended model definition to your model and then design proxy tables usingexternal shortcuts or replica.

After designing the proxy tables, you can use the build data source featurethat will create a data source for each target model of the current model.Target models are models containing the target tables of the replica orexternal shortcuts, they are also called remote servers.

Once the data sources are properly defined, you can use the extendedgeneration feature to generate the proxy table and remote server creationscripts.

648

Page 661: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Understanding the ProxyTables extended model definition

For an external shortcut or replica to be used as a proxy table you need toattach the ProxyTable extended model definition to the model.

v To attach the ProxyTables extended model definition to an exist-ing model

1. Select Model ä Extended Model Definitions.

2. Click the Import an Extended Model Definition tool.

A selection dialog box is displayed.

3. Select the ASA Proxy Tables or ASE Proxy Tables extended modeldefinition and click OK.

The extended model definition is displayed in the list.

4. Click OK.

Select ProxyTables XEM at model creationYou can also select the relevant Proxy Tables XEM in the Extended ModelDefinitions tab of the New dialog box

The ProxyTables extended model definition contains generation templates,extended attributes, custom checks and custom methods to support thedefinition of external proxy tables.

You can double-click the ProxyTables extended model definition in theBrowser to display its properties in the resource editor. The followingextensions must be defined in the Profile category to fully support proxytables:

Metaclass Extension types

BasePack-age

♦ Generation template - for generating proxy tables

649

Page 662: Physical Data Model - SAP

Sybase AS Anywhere

Metaclass Extension types

DataSource

♦ Connection information custom check - verifies that theconnection information is sufficient to connect to thedatabase. You must specify the data source name, userlogin and password in the Database Connection tab of thedata source property sheet

♦ GenerateAsProxyServer extended attribute - when set totrue, defines the data source model as the proxy remoteserver.

♦ [various templates] - used for proxy table generation.

Model

♦ Proxy Servers and Tables generated files - to generateproxy server and table script files

♦ Menu – provides a contextual menu for building datasources and commands in the Tools menu for rebuildingdata sources and generating proxy tables.

♦ BuildProxyTableDataSourcesand GenerateProxyTablesmethods - used in the menu.

♦ [various templates] - required for proxy server and proxytable script generation.

Shortcut

♦ Data source existence custom check - verifies that datasources are defined for the shortcuts.

Table

♦ Proxy table is child of reference custom check - verifiesthat the model replica is not the child of another table viaa reference link.

♦ [various templates] - required for proxy table, remoteserver and access definition creation syntax.

650

Page 663: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Creating a proxy table

You use external shortcuts and/or replica to design proxy tables in yourmodel.

An external shortcut is a non-modifiable reference to an object in anothermodel. For more information on shortcuts, see chapter Managing Shortcutsin the General Features Guide .

A replica is an exact copy of an object that can be updated when the originalobject is modified. For more information on shortcuts, see chapter ManagingObject Replications in the General Features Guide .

One interesting aspect of using replica, is that you can modify the replicacode in order to make it different from the target table. A custom checkverifies that replica are not used as child tables of a reference.

v To create a proxy table in a PDM

1. Select a table in a target model and drag it to the model where you wantto create proxy tables using the appropriate key combination to createeither an external shortcut or a replica.

2. Repeat this operation for each proxy table.

Defining the remote server of a proxy table

The remote server is the model containing the target tables of the externalshortcut or replica. The remote server is defined using a data source in theproxy tables model; this data source provides access to the remote data onthe server.

Note: the same data source can contain information for several models thatshare the same remote servers.

When you attach the ProxyTables extended model definition to the modelcontaining proxy tables, a specific contextual menu is displayed on thephysical data model item, this menu command is used for building the datasource of the proxy tables.

Note: This command does not build data sources for target models that areclosed in the workspace.

v To define the remote server of a proxy table

1. Create a new data source and set the GenerateAsProxyServer extendedattribute to True.

651

Page 664: Physical Data Model - SAP

Sybase AS Anywhere

2. Add the target models in the Models tab of the data source property sheet.

You can also right-click the model that contains replica and/or shortcutsin the Browser and select the Build Proxy Tables Data Sources command.A data source is automatically created for each target model.

3. Double-click a data source in the Browser to display its property sheet.

4. Click the Database Connection tab, and define the data source name,login and password.

5. Click OK.

6. Repeat steps 2 to 5 for each data source.

Generating the remote server and proxy tables creation scripts

You can generate the remote server and proxy tables creation scripts in orderto run them in the database. Generation must be started from the modelcontaining proxy tables.

The ProxyTables extended model definition contains the creation scriptsyntax for ASA or ASE.

v To generate the remote server and proxy tables creation scripts

1. Select Tools ä Proxy Tables ä Generate Proxy Tables.

The Generation dialog box opens.

2. Click the Options tab to display the corresponding tab.

3. Set a value for the UserReplica and UserShorcut options. This allows youto generate the proxy tables corresponding to replica and/or externalshortcuts.

4. Set a value for the Generate proxy servers option:

If you want to generate all proxy servers Set the Generate proxy serversoption to True in the Generation dialog box

If you do not want to generate all proxy servers Set the Generate proxyservers option to False in the Generation dialog box, this prevents servergeneration whatever the GenerateAsProxyServer extended attribute value

If you want to generate several proxy servers Set the Generate proxyservers option to True in the Generation dialog box, deselect the data sourcescorresponding to the proxy servers you do not want to generate

652

Page 665: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

1. Click OK.

Generation starts.

The generated script is displayed in the Result dialog box.

2. Double-click the generated SQL file or click the Edit button.

The script is displayed in a text editor.

You can now run this script on your database in order to create the proxytables.

Sybase AS Anywhere extended attributes

The following extended attributes are defined by default in the Sybase ASAnywhere DBMS.

Table The following extended attributes are available on the Sybase tab:

Name Description

Table Defines if table is a global temporary table or not.

Scripting name: ExtGlobalTemporaryTable

Web Services The following extended attributes are available on the Sybase tab:

Name Description

Port number Specifies the web service port number.

Scripting name: PortNumber

Server name Specifies the web service server name.

Scripting name: ServerName

Name prefix(dish servicesonly)

Specifies the web service name prefix (dish services only).

Scripting name: Prefix

653

Page 666: Physical Data Model - SAP

Sybase AS Enterprise

Sybase AS EnterpriseThis section describes features specific to the Sybase AS Enterprise familyof databases. These features include:

♦ Proxy tables

♦ Extended attributes

Working with proxy tables in Sybase ASE

For information about using proxy tables, see “Working with proxy tables inSybase ASA and ASE” on page 648.

Sybase AS Enterprise extended attributes

The following extended attributes are defined by default in the Sybase ASEnterprise DBMS.

Columns The following extended attributes are available on the Sybase tab:

Name Description

Store Java-SQL columnin row

Specifies whether a Java-SQL column is stored separate fromthe row (set to False) or in storage allocated directly in therow (set to True).

Scripting name: InRow

Computedcolumn ismaterialized

Specifies that the computed column is materialized.

Scripting name: Materialized

EncryptionKey

Specifies an encryption key name.

Scripting name: EncryptionKey

Extended Objects The following extended attributes are available for extended objects with astereotype of Encryption Key, on the Detail tab (version 12.5.3a only):

Name Description

Algorithm Advanced Encryption Standard (AES) is the only algorithmsupported.

Scripting name: Algorithm

654

Page 667: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Name Description

Default en-cryption key

Allows the System Security Officer to create a default key foruse on all encrypted columns which do not have a keynamespecified in create table or alter table. This is a databasespecific default key for use with tables in the same database.The default key is stored in the database sysencryptkeys table,the same as non-default keys.

Scripting name: Default

Initializationvector

Omits the use of an initialization vector when encrypting.

This makes the column suitable for supporting an index.When an initialization vector is used by the encryptionalgorithm, the ciphertext of two identical pieces of plaintextwill be different, which would prevent the cryptanalyst fromdetecting patterns of data but would render the data on diskuseless for indexing or matching without decryption.

Scripting name: InitVector

Key length Size in bits of the key to be created.For AES valid key lengthsare 128, 192 and 256 bits.

Scripting name: KeyLength

Padding ofdatatypes

To use padding of datatypes whose length is less than oneblock. Padding can be used instead of an initialization vectorto randomize the ciphertext. It is only suitable for columnswhose plaintext length is less than half the block length. Forthe default AES algorithm the block length is 16 bytes.

Scripting name: Pad

Keys The following extended attributes are available on the Sybase tab:

Name Description

Key index isdescending

Specifies if the index created for a constraint is to be createdin descending order for each column.

Scripting name: DescKey

Model The following extended attributes are available on the Encryption tab(version 12.5.3a only):

Name Description

Encryptionpassword

Global encryption password.

Scripting name: EncryptionPassword

655

Page 668: Physical Data Model - SAP

Sybase AS Enterprise

Table The following extended attributes are available on the Sybase tab:

Name Description

Number ofpartitions

Specifies the number of partitions for a table.

Scripting name: ExtTablePartition

656

Page 669: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Sybase AS IQThis section describes features specific to the Sybase AS IQ family ofdatabases.

Sybase Adaptive Server IQ (AS IQ) is a high-performance decision supportserver designed specifically for data warehousing.

Sybase AS IQ provides benefits that allow an interactive approach todecision support including:

♦ Intelligent query processing using index-only access plans to processonly the data needed to satisfy any type of query

♦ Truly interactive, ad hoc query performance on a uniprocessor as well ason parallel systems. An ad hoc query is a query about which the systemhas no prior knowledge and for which no explicit tuning is required. Adhoc queries are distinguished from standard or production reports, whereonly pre-defined variables, such as dates, are used to generate pre-definedreports on a regular basis.

♦ Fully-flexible schema support

♦ Efficient query execution without query-specific tuning by the SystemAdministrator (under most circumstances)

♦ Fast aggregations, counts, comparisons of data

♦ Stored procedures

♦ Entire database and indexing stored in less space than raw data

♦ Numerous index types

♦ Join indexes to improve overall query performance. Join indexesrepresent links between columns in different tables. They enable muchfaster query processing on multiple indexes in a very large database, andare usually applied instead of ad hoc queries.

IQ indexes

Before creating IQ indexes, you should consider the implications of varioustypes of indexes on the database server memory and disk space.

The set of indexes you define for any given column can have dramaticimpact on the speed of query processing. There are four main criteria forchoosing indexes:

♦ Number of unique values

657

Page 670: Physical Data Model - SAP

Sybase AS IQ

♦ Types of queries

♦ Disk space usage

♦ Data types

It is best to consider all criteria in combination, rather than individually. Todecide on indexes, look closely at the data in each column.

Try to anticipate the number of unique and total values, the query resultsusers will want from it, and whether the data will be used in ad hoc joins orjoin indexes.

+ For more information about choosing index types, see chapter AdaptiveServer IQ Indexes in the Adaptive Server IQ Administration andPerformance Guide.

Rebuilding IQ indexes

As you develop a PDM or modify an existing one, you may change datatypes, alter the percentage of distinct values or change the number of valuesin tables. You must then rebuild the IQ indexes to reflect these changes.

v To rebuild IQ indexes

1. Select Tools ä Rebuild Objects ä Rebuild Indexes to open the RebuildIndexes dialog box:

2. Select a default name to generates IQ indexes. You can use the followingvariables:

658

Page 671: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

♦ %COLUMN% - Column name

♦ %INDEXTYPE% - Type of index to be rebuilt

♦ %TABLE% - Name or code of table (based on display preferences)

3. Specify a mode to use. You can choose between:♦ Delete and Rebuild - All existing indexes are deleted before index

rebuild

♦ Preserve Indexes - Preserves all existing indexes

4. [optional] Select the Update statistics before rebuild checkbox to updatesuch statistics as the number of records in a table and the number ofdistinct values in a column before performing the rebuild. Selecting thisoption can help with optimizing the rebuild.

5. [optional] Click the Selection tab and select or clear checkboxes tospecify for which tables you want to rebuild indexes.

6. Click OK, and then Yes to confirm the rebuilding of your indexes.

Index types

When you rebuild indexes, PowerDesigner determines the index type basedon information contained from the table statistics. It uses the number field,which indicates the estimated number of records per table, and thepercentage of distinct values to compute the number of unique values. If the

659

Page 672: Physical Data Model - SAP

Sybase AS IQ

user has not specified a number of rows for the table, PD assumes that thetable will include at least 1 row of data.

Usually the rebuild process creates a FASTPROJECTION index for allcolumns. Otherwise, the following rules are applied:

Criteria Index type

If no statistics are provided and the column has anundefined data type

No index is created

Low number of unique values in a column

Column used in join predicate

LOWFAST

High number of unique values in a column

No COUNT DISTINCT, SELECT DISTINCT, orGROUP BY queries required

HIGHNON-GROUP

Column used in join predicate

High number of unique values in a column (more that1000)

Anticipate COUNT DISTINCT, SELECT DISTINCT,or GROUP BY queries

Column must enforce uniqueness

HIGHGROUP

Column without numeric datatype No index is created

Column with date type DATE

Column with time type TIME

Column with datetime or smalldatetime type DTTM

For example (IQ v12.5, Table A contains 1500 rows

Column % Distinct

values

Unique

values

Rebuild indexesgenerates

Col_1 integer 100 1500 HG index

Col_2 integer 50 750 LF index

Col_3 integer 0 0 no index

Col_4 char (10) 100 1500 no index

Col_5 char (10) 50 750 LF index

660

Page 673: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

IQ join indexes

A join index is a special type of index used in Sybase AS IQ, whichrepresents a full outer join of two or more tables. The query engine may usethis full outer join as a starting point for queries that include left outer, rightouter, and inner joins. A full outer join is one where all rows from both theleft and right specified tables are included in the result, with NULL returnedfor any column with no matching value in the corresponding column.

Join indexes are defined from references. You can create a join index for anyset of columns that your users commonly join to resolve queries.

While some references are based on keys, Sybase AS IQ allows you tocreate user-defined references to include the exact join required by yourforeseen queries.

You can define a join index:

♦ Automatically, by creating join indexes from all references linked to afact table

♦ Manually, by creating a join index in the list of join indexes

Facts and Dimensions A fact corresponds to the focus of a decision support investigation. Forexample, Sales, Revenue, and Budget are facts. A table containing facts isset as a fact table in the table property sheet.

A dimension defines the axis of the investigation of a fact. For example,Product, Region, and Time are the axes of investigation of the Sales fact. Atable containing dimensions is linked to a fact table and is set as a dimensiontable in the table property sheet.

+ For more information about setting table properties, see the BuildingPhysical Diagrams chapter.

Creating a join index from the table property sheet

You can create a join index or a bitmap join index from the Join Index tab ofthe table property sheet. The join index is automatically based on the currenttable.

v To create a join index from the table property sheet

1. Open the property sheet of a table.

2. Click the Join Index tab to display the Join Index tab.

3. Click the Insert a Row or the Add a Row tool.

661

Page 674: Physical Data Model - SAP

Sybase AS IQ

A join index is automatically added to the list of table join indexes.

4. Click Apply and click the Properties tool to display the join indexproperty sheet.

You can check that the Base table box is initialized with the selectedtable.

Creating a join index in the list of join indexes

If you need to create more join indexes than those automatically created bythe rebuild process, you can use the list of join indexes.

Several references can be made at onceThe following procedure shows how to create a join index in its simplestform: using one reference at a time. Once you become familiar with joinindex creation, you can select several references at once to reflect a morecomplex query plan.

v To create a join index in the list of join indexes

1. Select Model ä Join Indexes to open the List of Join Indexes .

2. Click the Add a Row tool, type a name in the Name column, and thenclick the Properties tool to open the property sheet of the new join index.

3. Click the References tab to display the list of references of the join index.The list is empty when you create a new join index.

4. Click the Add References tool to open a selection box listing all theavailable references in the PDM, select a reference, and then click OK toadd it to the Join Index references list:

662

Page 675: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

5. Click OK in each of the dialog boxes to complete the creation of the joinindex.

Join index properties

A join index has the following properties:

Property Description

Name The name of the item which should be clear and meaningful,and should convey the item’s purpose to non-technical users.

Code The technical name of the item used for generating code orscripts, which may be abbreviated, and should not generallyinclude spaces.

Stereo-type

Sub-classification used to extend the semantics of an objectwithout changing its structure; it can be predefined or user-defined.

Comment Descriptive label for the join index.

Base table Name of the table that stores the join index. You can use thetools to the right of the list to create an object, browse thecomplete tree of available objects or view the properties of thecurrently selected object.

663

Page 676: Physical Data Model - SAP

Sybase AS IQ

Rebuilding join indexes for all references linked to a fact table

You can automatically generate a join index for each selected fact table andthe dimension tables that it references. The rebuild process only applies tofact tables selected in the Selection tab of the Join Index Rebuild tab.

Each automatically generated join index consists of the references that link afact table to all the dimension tables located on a single axis proceedingfrom the fact table.

A reference between two fact tables does not generate any join index.

A join index is constrained and can only be defined for tables that areorganized in a connected tree.

Parameter Result of selection

Delete andRebuild

When selected all existing indexes are deleted before joinindex rebuild.

Preserve When selected, preserves all existing join indexes in thePDM.

The same feature applies to Oracle bitmap join indexes.

+ For more information on Oracle bitmap join indexes, see section“Automatically creating bitmap join indexes through rebuilding” onpage 620.

664

Page 677: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

v To rebuild join indexes for all references linked to a fact table

1. Select Tools ä Rebuild Objects ä Rebuild Join Indexes to open theRebuild Join Indexes dialog:

2. Click the Selection tab, and select one or more fact tables from the list:

3. Click OK, and then Yes to confirm rebuilding of the join indexes.

A join index is automatically generated for each fact table.

Displaying automatically generated join indexesAutomatically generated join indexes appear in the list of join indexes.To display the list, select Model ä Join Indexes.

Adding references to a join index

You can add a reference to any join index. You do this, for example, whenyou create a new reference that you want to include in an existing join index.

v To add a reference to a join index

1. Select Model ä Join Indexes to open the List of Join Indexes.

2. Select a join index in the list, and then click the Properties tool to open itsproperty sheet.

3. Select the References tab, and click the Add References tool to open aselection box listing all the available references in the PDM. Select theappropriate reference in the list and click OK to add it to the join index:

665

Page 678: Physical Data Model - SAP

Sybase AS IQ

4. Click OK in each of the dialog boxes to complete the addition of thereference to the join index.

Generating IQ data movement scripts

PowerDesigner provides the capability to generate data movement scripts topopulate your AS IQ data warehouse from your other databases. The scriptcan be used to:

♦ Generate a flat file for loading to the AS IQ data warehouse

♦ Create Insert Location statements for use with a proxy data base (for ASEand IQ only)

To create a data movement script, you must:

♦ Add the Data Movement IQ XEM to your AS IQ model

♦ Specify your data movement options

♦ [optional] Create a data source linked to a model of the database fromwhich you want to draw the data to be moved

♦ [optional] Specify mappings between the tables in your data source andyour AS IQ database

♦ Generate the data movement script

666

Page 679: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

v To add the Data Movement IQ XEM to your AS IQ model

1. Select Model ä Extended Model Definitions to open the List of ExtendedModel Definitions.

2. Click the Import an Extended Model Definition tool, select the DataMovement IQ and click OK to add this XEM to the model.

3. Click OK to close the List of Extended Model Definitions and return tothe model.

v To create a data source to populate your IQ data warehouse

1. Create a PDM to model your source database, and ensure that it is openin your workspace.

2. In your AS IQ PDM, right-click the model name in the Browser andselect New ä Data Source.

3. Enter a name for the source and then click the Models tab.

4. Click the Add Models tool, and select your source model.

5. Click the Database Connection tab, and complete the fields to enable aconnection to your source database.

6. Complete the fields on the Data Movement tab and click OK.

Data Source propertiesData Movement tab

The following fields are available on the Data Source properties sheet DataMovement tab:

Property Description

RemoteServer Name

Specifies the name of the remote server used in the interfacefile for IQ server

RemoteDatabaseName

Specifies the name of the remote database.

Data SourceName

Specifies the label given to the data source in the sql.ini file.

Dump filedirectory

Specifies the directory where the ‘dump’ file (external flatfile), that contains the data to be imported, will be created.

Local username

Specifies the database user name.

667

Page 680: Physical Data Model - SAP

Sybase AS IQ

v To specify data movement options

1. Right-click the model item in the Browser and select Properties from thecontextual menu.

2. Click the Data Movement tab and enter the appropriate values for themodel as a whole.

3. [optional] To override these global data movement options for a specifictable, open its property sheet and enter table-specific values on the DataMovement tab. This tab also allows you to specify a table-specific dumpfile for importing into the table

Model properties DataMovement tab

The following fields are available on the Model properties sheet DataMovement tab:

Property Description

Field Delim-iter

Specifies the delimiter to be used between fields in the dumpfile.

Row Delim-iter

Specifies the delimiter to be used between rows in the dumpfile.

MaximumImage orText Size

Specifies the maximum length of an image (or text) record, towhich it will be truncated if necessary.

Load filedirectory

Specifies the directory where the load file is located.

Table properties DataMovement tab

If the Data Movement Method generation option is set to Insert Location, aData Movement tab is available on each Table properties sheet, containingthe following fields:

Property Description

Dump filename

Specifies the name of the ‘dump’ file (external flat file) thatcontains the data to be imported.

Field Delim-iter

Specifies the delimiter to be used between fields in the dumpfile.

Row Delim-iter

Specifies the delimiter to be used between rows in the dumpfile.

MaximumImage orText Size

Specifies the maximum length of an image (or text) record, towhich it will be truncated if necessary.

668

Page 681: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

v To specify mappings between the tables in your data source andyour AS IQ database

1. Select Tools ä Mapping Editor to open the Mapping Editor

2. Create the necessary mappings and then click OK. For detailedinformation about using the Mapping Editor, see the “CreatingMappings” chapter in the General Features Guide .

v To generate the data movement script

1. Select Tools ä Extended Generation to open the Generation window.

2. Specify a directory in which to generate your data movement files.

3. [optional] Click the Selection tab and specify for which Tables and/orData Sources you want to generate a data movement script.

4. Click the Options tab and specify your data movement script generationoptions. You can set the following options:

♦ Use Mappings – specifies whether any previously-created mappingsshould be used for the data movement

♦ Data Movement Method – specifies which kind of script to generate.You can choose between:

• Insert Location – [IQ or ASE only] PowerDesigner will create aloadscript for connecting the source database to the IQ server. Notethat if the data source is not an IQ or ASE database, then noloadscript will be generated.

• External File – PowerDesigner will create a dump file from thesource database together with a loadscript to upload it to the IQserver.

5. [optional] Click the Generated Files tab to review the names andlocations of the files to be generated.

6. Click OK to begin the generation of the data movement script.

Sybase AS IQ events

PowerDesigner supports Sybase AS IQ events for v12.7 and higher. Fordetails, see “SQL Anywhere events” on page 671.

Sybase AS IQ extended attributes

The following extended attributes are defined by default in the Sybase IQDBMS.

669

Page 682: Physical Data Model - SAP

Sybase AS IQ

Columns The following extended attributes are available on the Sybase tab:

Name Description

Cardinality (Iqunique)

Defines the cardinality of the column (to optimize theindexes internally).

Scripting name: ExtIqUnicity

Tables The following extended attributes are available on the Sybase tab:

Name Description

Global tempo-rary table

Specifies that the table is a global temporary table.

Scripting name: ExtGlobalTemporaryTable

670

Page 683: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Sybase SQL AnywhereNote that Sybase SQL Anywhere is the new name for Sybase AS Anywhere(see “Sybase AS Anywhere” on page 648).

PowerDesigner provides support for the Event object.

SQL Anywhere events

This section also applies to Sybase AS IQ events.

Events allow you to automate and schedule actions. PowerDesigner modelsevents as extended objects with a stereotype of <<Event>>.

You can create an event in any of the following ways:

♦ Select Model ä Event Objects to access the List of Events, and click theAdd a Row tool

♦ Right-click the model or package in the Browser, and select New ä Event

You can modify an object’s properties from its property sheet. To open anevent property sheet, double-click its diagram symbol or its Browser entry inthe Event Objects folder.

The following extended attributes are available on the Sybase tab:

Name Description

Event isscheduled

Specifies that the server carries out a set of actions according toa schedule of times.

If selected, this option disables the “Event is triggered” option.

Scripting name: ScheduledEvent

Scheduledefinition

Enter the schedule of event trigger times here. Click the Newbutton to launch a dedicated editor window.

Scripting name: SchedulesText

Event istriggered

Specifies that the server carries out a set of actions when apredefined type of system event occurs.

This option is the default and, if selected, disables the “Eventis scheduled” option.

Scripting name: TypedEvent

671

Page 684: Physical Data Model - SAP

Sybase SQL Anywhere

Name Description

Event type The event-type is one of the listed set of system-defined eventtypes. The event types are case insensitive. To specify theconditions under which this event-type triggers the event, usethe WHERE clause.

Scripting name: EventType

Triggercondition

The trigger condition determines the condition under which anevent is fired. For example, to take an action when the diskcontaining the transaction log becomes more than 80% full, usethe following triggering condition:

WHERE event_condition( ‘LogDiskSpacePercentFree’ ) < 20

The argument to the event_condition function must be valid forthe event type.

You can use multiple AND conditions to make up the WHEREclause, but you cannot use OR conditions or other conditions.

Scripting name: TriggerCondition

Handler Each event has one handler.

The actions of an event handler are committed if no erroris detected during execution, and rolled back if errors aredetected.

Scripting name: Handler

Enable at(databases)

By default, event handlers are enabled. When DISABLE isspecified, the event handler does not execute even when thescheduled time or triggering condition occurs. A TRIGGEREVENT statement does not cause a disabled event handler tobe executed.

If you want to execute events at remote or consolidateddatabases in a SQL Remote setup, you can use this clauseto restrict the databases at which the event is handled. Bydefault, all databases execute the event.

Scripting name: Enable

672

Page 685: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

TeradataThis section describes features specific to the Teradata family of databases.these features include:

♦ Database permissions

♦ Primary indexes

♦ Extended attributes

Teradata database permissions

You can define multiple databases in a PDM for Teradata.

You can also define permissions on the database object in Teradata.

Object permissions are usage restrictions set on a particular object for aparticular user, group or role. Usually, you define permissions on tables,views, columns, procedures, and packages; in Teradata, you can also definepermissions on database.

+ For more information on permissions, see the “Building a DatabaseAccess Structure” chapter.

Primary indexes in Teradata

In Teradata, users tend to use indexes rather than key constraints.

v To create a primary index

1. Open the property sheet of an index from the Indexes tab of a table, orfrom the List of Indexes available by selecting Model ä Indexes.

2. Click the Teradata tab and select the Primary Index checkbox.

3. Click OK to close the index property sheet.

When a primary index is based on a key, it is automatically unique. Youcan make this primary index non-unique by detaching the index from thekey. To do so, select <None> in the Columns Definition list in theColumns tab of the index property sheet, and set the PrimaryIndexextended attribute of the index to True.

Once defined, you can decide to generate indexes or keys in the SQLscript, and you can also decide to generate them inside or outside thetable creation script.

673

Page 686: Physical Data Model - SAP

Teradata

Teradata extended attributes

The following extended attributes are defined by default in the TeradataDBMS.

Columns The following extended attributes are available on the Teradata tab:

Name Description

Case specific Indicates that character column comparison uses charactercase (upper and lower) to raise differences.

Scripting name: CaseSpecific

Character set Character set (set of symbols and encodings.)

Scripting name: CharSet

System gen-erated only

When set to true, identity column values are always system-generated; you cannot insert values into, nor update, anidentity column defined as GENERATED ALWAYS.

When false, identity column values are system-generated aslong as the user does not enter a non-null value.

Scripting name: ExtGenAlways

Compressedvalues

Compresses specified values and nulls in one or more columnsof a table to zero space. When the data in a column matches avalue specified in the COMPRESS phrase, then that value isstored only once in the table header regardless of how manytimes it occurs as a field value for the column, thus savingdisk storage space.

Attribute must be enclosed in parenthesis when it is composedof multiple values.

Scripting name: Compress

Databases The following extended attributes are available on the Teradata tab:

Name Description

Account Account ID identifiers.

Scripting name: Account

After journal Specifies the type of image to be maintained by default fordata tables created in the new database.

Scripting name: AfterJournal

674

Page 687: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Name Description

Default journaltable

Identifies the default table that is to receive the journalimages of data tables created in the new database.

Scripting name: DefaultJournalTable

Fallback Specifies whether to create and store a duplicate copy ofeach table created in the new database.

Scripting name: Fallback

Owner (Useror Database)

Name of the immediate owning user or database. Thedefault is the user name associated with the current session.

Scripting name: FromDatabaseName

Journal Specifies the number of before change images to be main-tained by default for each data table created in the newdatabase.

Scripting name: Journal

Permanentspace

Specifies the number of bytes to be reserved for permanentstorage of the new user database. The space is taken fromunallocated space in the database of the immediate owner.

Scripting name: PermanentSpace

Spool space Specifies the number of bytes (n) to be allocated for spoolfiles. The default is the largest value that is not greater thenthe owner spool space, and that is a multiple of the numberof AMPs on the system.

Scripting name: SpoolSpace

Temporaryspace

Allows you to define how much space (in bytes) is to beallocated for creating temporary tables by this user. Notethat temporary space is reserved prior to spool space forany user defined with this characteristic.

Scripting name: TemporarySpace

Indexes The following extended attributes are available on the Teradata tab:

Name Description

Retain rowID pointersfor each logi-cal row “all”keyword)

Specifies that a NUSI should retain row ID pointers foreach logical row of a join index (as opposed to only thecompressed physical rows).

Scripting name: AllIndex

675

Page 688: Physical Data Model - SAP

Teradata

Name Description

Generate in-dex name

Specifies that the index will be generated with its name (asTeradata allows index with no name).

Scripting name: NamedIndex

Row ordering Specifies the ordering of rows.

Scripting name: OrderByColumnList

Primary in-dex

Indicates that the index is a primary index.

Scripting name: PrimaryIndex

Tables The following extended attributes are available on the Teradata tab:

Name Description

On commitaction

Specifies the action to take with the contents of a globaltemporary table when a transaction ends.

DELETE ROWS clears the temporary table of all rows.

PRESERVE ROWS retains the rows in the table after thetransaction is committed.

Scripting name: CommitRowAction

Type Specifies whether the table to be created is a global temporarytable or a volatile table.

GLOBAL TEMPORARY specifies that a temporary tabledefinition be created and stored in the data dictionary forfuture materialization. You can create global temporarytables by copying a table WITH NO DATA, but not bycopying a table WITH DATA.

VOLATILE specifies that a volatile table be created, withits definition retained in memory only for the course of thesession in which it is defined.

Scripting name: GlobalTemporary

Duplicaterow control

Specifies duplicate row control.

If there are uniqueness constraints on any column or set ofcolumns in the table definition, then the table cannot haveduplicate rows even if it is declared as MULTISET.

Some client utilities have restrictions with respect to MULTI-SET tables.

Scripting name: SetOrMultiset

676

Page 689: Physical Data Model - SAP

Chapter 14. DBMS-Specific Features

Users (Database) The following extended attributes are available on the Database tab:

Name Description

Account Account ID identifiers.

Scripting name: Account

After journal Specifies the type of image to be maintained by default fordata tables created in the new database.

Scripting name: AfterJournal

Owner (Useror Database)

Database (or User) that owns the current user.

Scripting name: DBOwner

Default journaltable

Identifies the default table that is to receive the journalimages of data tables created in the new database.

Scripting name: DefaultJournalTable

Fallback Specifies whether to create and store a duplicate copy ofeach table created in the new database.

Scripting name: Fallback

Journal Specifies the number of before change images to be main-tained by default for each data table created in the newdatabase.

Scripting name: Journal

Permanentspace

Specifies the number of bytes to be reserved for permanentstorage of the new user database. The space is taken fromunallocated space in the database of the immediate owner.

Scripting name: PermanentSpace

Spool space Specifies the number of bytes (n) to be allocated for spoolfiles. The default is the largest value that is not greater thenthe owner spool space, and that is a multiple of the numberof AMPs on the system.

Scripting name: SpoolSpace

Temporaryspace

Allows you to define how much space (in bytes) is to beallocated for creating temporary tables by this user. Notethat temporary space is reserved prior to spool space forany user defined with this characteristic.

Scripting name: TemporarySpace

Users (Teradata) The following extended attributes are available on the Teradata tab:

677

Page 690: Physical Data Model - SAP

Teradata

Name Description

Collation Name of the collation to be used as the default for this user.

Scripting name: Collation

Default dateformat

Default format for importing and exporting DATE valuesfor the user.

Scripting name: DateForm

Default char-acter set

Sets the user default for character data type.

Scripting name: DefaultCharacterSet

Defaultdatabase

Default database name.

Scripting name: DefaultDatabase

Default role Defines the default role for the user.

Scripting name: DefaultRole

Profile Assigns a profile to the user.

Scripting name: Profile

Startup string Startup string.

Scripting name: Startup

Time zone Defines the default time zone displacement for the user.

Scripting name: TimeZone

Views The following extended attributes are available on the Teradata tab:

Name Description

Lock Type The type of lock to be placed.

Scripting name: LockType

Locked Class The type (class) of the object to be locked.

Scripting name: LockedClass

Locked object The name of the object to be locked.

Scripting name: LockedObjt

Abort state-ment if lockfailed

Specifies that if the indicated lock cannot be obtained, thestatement should be aborted.

Scripting name: NoWait

678

Page 691: Physical Data Model - SAP

CHAPTER 15

Writing SQL Statements in PowerDesigner

About this appendix This appendix provides a short introduction to writing SQL scripts inPowerDesigner and lists the variables and macros available for use in suchscripts.

Contents Topic: page

Introduction 680

Writing SQL with the PowerDesigner GTL 681

Writing SQL with the PDM Variables and Macros 683

PDM Macros 685

PDM Variables 696

PowerDesigner Formatting Variables 708

679

Page 692: Physical Data Model - SAP

Introduction

IntroductionPowerDesigner allows you to associate your own custom SQL statementswith many database objects.

You can write triggers and procedures, and also add begin and end scripts tomany database objects.

+ For more information, see:

♦ The “Building Triggers and Procedures” chapter

♦ The “Customizing scripts” section in the “Generating a Database from aPDM” chapter

Instead of hard coding the names of tables, columns, and other objects inyour SQL statements, you can use the PowerDesigner Generation TemplateLanguage (GTL) or the PDM variables and macros to obtain these valuesfrom the model.

While you can perform many tasks using the PDM variables and macros, theGTL is more powerful, as it allows you to access any information about anyobject in the model.

+ For more detailed information about the GTL, see the “GenerationReference Guide (GTL)” chapter in the Advanced User Documentation .

680

Page 693: Physical Data Model - SAP

Chapter 15. Writing SQL Statements in PowerDesigner

Writing SQL with the PowerDesigner GTLYou can use the PowerDesigner Generation Template Language (GTL) towrite SQL statements.

In the following example, a trigger written using GTL is attached to theExample table, and writes the contents of any insertion to HistoryTable.

See ““Writing SQL with the PDM Variables and Macros” on page 683” foran example of the same trigger written using the PowerDesigner macros andvariables:

The actual trigger code can be viewed on the Preview tab:

681

Page 694: Physical Data Model - SAP

Writing SQL with the PowerDesigner GTL

+ For more information, see the “Generation Reference Guide (GTL)”chapter in the Advanced User Documentation .

682

Page 695: Physical Data Model - SAP

Chapter 15. Writing SQL Statements in PowerDesigner

Writing SQL with the PDM Variables and MacrosYou can use the PDM Variables and Macros to write SQL statements.

In the following example, a trigger written using the PDM variables andmacros is attached to the Example table, and writes the contents of anyinsertion to HistoryTable.

See ““Writing SQL with the PowerDesigner GTL” on page 681” for anexample of the same trigger written using the PowerDesigner GTL:

The actual trigger code can be viewed on the Preview tab:

683

Page 696: Physical Data Model - SAP

Writing SQL with the PDM Variables and Macros

+ For lists of the available variables and macros, see ““PDM Macros” onpage 685”, ““PDM Variables” on page 696”, and ““PowerDesignerFormatting Variables” on page 708”.

684

Page 697: Physical Data Model - SAP

Chapter 15. Writing SQL Statements in PowerDesigner

PDM MacrosYou can use predefined macros in trigger templates, template items, triggers,and procedures. Macros perform specific functions.

AKCOLN

Description Repeats a statement for each alternate key in a table

Syntax

.AKCOLN("statement","prefix","suffix","last_suffix", "condition")

Argument Description

statement Statement to repeat for each column

prefix Prefix for each new line

suffix Suffix for each new line

last suffix Suffix for the last line

condition Alternate key code (if condition argument is left empty themacro returns a statement for each alternate key in the table)

Example In a trigger for the table TITLEAUTHOR, the following macro:

message .AKCOLN("’%COLUMN% is an alternate key column’","", "","", "AKEY1")

generates the following trigger script:

message ’TA_ORDER is an alternate key column’,

Column variable onlyFor columns, the macro AKCOLN only accepts the variable %COL-UMN%.

ALLCOL

Description Repeats a statement for each column in a table

Syntax

.ALLCOL("statement","prefix","suffix","last_suffix")

685

Page 698: Physical Data Model - SAP

PDM Macros

Argument Description

statement Statement to repeat for each column

prefix Prefix for each new line

suffix Suffix for each new line

last suffix Suffix for the last line

Example In a trigger for the table AUTHOR, the following macro:

.ALLCOL("%COLUMN% %COLTYPE%","",",",";")

generates the following trigger script:

AU_ID char(12),AU_LNAME varchar(40),AU_FNAME varchar(40),AU_BIOGRAPH long varchar,AU_ADVANCE numeric(8,2),AU_ADDRESS varchar(80),CITY varchar(20),STATE char(2),POSTALCODE char(5),AU_PHONE char(12);

DEFINE

Description Defines a variable and initializes its value.

Syntax

.DEFINE "variable" "value"

Argument Description

variable Variable name (without % signs)

value Variable value (may include another variable surrounded by %signs)

Example In a trigger for the table AUTHOR, the following macro:

.DEFINE "TRIGGER" "T_%TABLE%"message ’Error: Trigger(%TRIGGER%) of table %TABLE%’

generates the following trigger script:

message ’Error: Trigger(T_AUTHOR) of table AUTHOR’;

686

Page 699: Physical Data Model - SAP

Chapter 15. Writing SQL Statements in PowerDesigner

DEFINEIF

Description Defines a variable and initializes its value if the test value is not null

Syntax

.DEFINEIF "test_value" "variable" "value"

Argument Description

test_value Value to test

variable Variable name (without % signs)

value Variable value (may include another variable surrounded by %signs)

Example For example, to define a variable for a default data type:

%DEFAULT%.DEFINEIF "%DEFAULT%" "_DEFLT"" "%DEFAULT%"Add %COLUMN% %DATATYPE% %_DEFLT%

ERROR

Description Handles errors

Syntax

.ERROR (errno, "errmsg")

Argument Description

errno Error number

errmsg Error message

Example

.ERROR(-20001, "Parent does not exist, cannot insert child")

FKCOLN

Description Repeats a statement for each foreign key column in a table

Syntax

.FKCOLN("statement","prefix","suffix","last_suffix")

687

Page 700: Physical Data Model - SAP

PDM Macros

Argument Description

statement Statement to repeat for each column

prefix Prefix for each new line

suffix Suffix for each new line

last suffix Suffix for the last line

Example In a trigger for the table TITLEAUTHOR, the following macro:

message .FKCOLN("’%COLUMN% is a foreign key column’","",",",";")

generates the following trigger script:

message ’AU_ID is a foreign key column,TITLE_ISBN is a foreign key column;’

Column variable onlyFor columns, the macro FKCOLN only accepts the variable %COLUMN%.

FOREACH_CHILD

Description Repeats a statement for each parent-to-child reference in the current tablefulfilling a condition

Syntax

.FOREACH_CHILD ("condition")

"statement"

.ENDFOR

Argument Description

condition Reference condition (see below)

statement Statement to repeat

Condition Selects

UPDATE RESTRICT Restrict on update

UPDATE CASCADE Cascade on update

UPDATE SETNULL Set null on update

UPDATE SETDEFAULT Set default on update

688

Page 701: Physical Data Model - SAP

Chapter 15. Writing SQL Statements in PowerDesigner

Condition Selects

DELETE RESTRICT Restrict on delete

DELETE CASCADE Cascade on delete

DELETE SETNULL Set null on delete

DELETE SETDEFAULT Set default on delete

Example In a trigger for the table TITLE, the following macro:

.FOREACH_CHILD("DELETE RESTRICT")-- Cannot delete parent "%PARENT%" if children still exist in

"%CHILD%".ENDFOR

generates the following trigger script:

-- Cannot delete parent "TITLE" if children still exist in"ROYSCHED"

-- Cannot delete parent "TITLE" if children still exist in"SALE"

-- Cannot delete parent "TITLE" if children still exist in"TITLEAUTHOR"

FOREACH_COLUMN

Description Repeats a statement for each column in the current table fulfilling a condition

Syntax

.FOREACH_COLUMN ("condition")

"statement"

.ENDFOR

Argument Description

condition Column condition (see below)

statement Statement to repeat

689

Page 702: Physical Data Model - SAP

PDM Macros

Condition Selects

empty All columns

PKCOLN Primary key columns

FKCOLN Foreign key columns

AKCOLN Alternate key columns

NMFCOL Non-modifiable columns (columns that have Cannot Modifyselected as a check parameter)

INCOLN Triggering columns (primary key columns, foreign keycolumns; and non-modifiable columns)

Example In a trigger for the table TITLE, the following macro:

.FOREACH_COLUMN("NMFCOL")-- "%COLUMN%" cannot be modified.ENDFOR

generates the following trigger script:

-- "TITLE_ISBN" cannot be modified-- "PUB_ID" cannot be modified

FOREACH_PARENT

Description Repeats a statement for each child-to-parent reference in the current tablefulfilling a condition

Syntax

.FOREACH_PARENT ("condition")

"statement"

.ENDFOR

Argument Description

condition Reference condition (see below)

statement Statement to repeat

690

Page 703: Physical Data Model - SAP

Chapter 15. Writing SQL Statements in PowerDesigner

Condition Selects references defined with . . .

empty All references

FKNULL Non-mandatory foreign keys

FKNOTNULL Mandatory foreign keys

FKCANTCHG Non-modifiable foreign keys

Example In a trigger for the table SALE, the following macro:

.FOREACH_PARENT("FKCANTCHG")-- Cannot modify parent code of "%PARENT%" in child "%CHILD%".ENDFOR

generates the following trigger script:

-- Cannot modify parent code of "STORE" in child "SALE"-- Cannot modify parent code of "TITLE" in child "SALE"

INCOLN

Description Repeats a statement for each primary key column, foreign key column,alternate key column, or non-modifiable column in a table.

Syntax

.INCOLN("statement","prefix","suffix","last_suffix")

Argument Description

statement Statement to repeat for each column

prefix Prefix for each new line

suffix Suffix for each new line

last suffix Suffix for the last line

Example In a trigger for the table TITLE, the following macro:

.INCOLN("%COLUMN% %COLTYPE%","",",",";")

generates the following trigger script:

TITLE_ISBN char(12),PUB_ID char(12);

JOIN

Description Repeats a statement for column couple in a join.

691

Page 704: Physical Data Model - SAP

PDM Macros

Syntax

.JOIN("statement","prefix","suffix","last_suffix")

Argument Description

statement Statement to repeat for each column

prefix Prefix for each new line

suffix Suffix for each new line

last suffix Suffix for the last line

Example In a trigger for the table TITLE, the following macro:

.FOREACH_PARENT()where .JOIN("%PK%=%FK%", " and", "", ";")message ’Reference %REFR% links table %PARENT% to %CHILD%’.ENDFOR

generates the following trigger script:

message ’Reference TITLE_PUB links table PUBLISHER to TITLE

Primary key, alternate key, and foreign keys variables onlyFor columns, the macro JOIN only accepts the variables %PK%, %AK%,and %FK%.

NMFCOL

Description Repeats a statement for each non-modifiable column in a table.Non-modifiable columns have Cannot Modify selected as a check parameter.

Syntax

.NMFCOL("statement","prefix","suffix","last_suffix")

Argument Description

statement Statement to repeat for each column

prefix Prefix for each new line

suffix Suffix for each new line

last suffix Suffix for the last line

Example In a trigger for the table TITLE, the following macro:

.NMFCOL("%COLUMN% %COLTYPE%","",",",";")

692

Page 705: Physical Data Model - SAP

Chapter 15. Writing SQL Statements in PowerDesigner

generates the following trigger script:

TITLE_ISBN char(12),PUB_ID char(12);

PKCOLN

Description Repeats a statement for each primary key column in a table

Syntax

.PKCOLN("statement","prefix","suffix","last_suffix")

Argument Description

statement Statement to repeat for each column

prefix Prefix for each new line

suffix Suffix for each new line

last suffix Suffix for the last line

Example In a trigger for the table TITLEAUTHOR, the following macro:

message .PKCOLN("’%COLUMN% is a primary key column’","",",",";")

generates the following trigger script:

message ’AU_ID is a primary key column’,’TITLE_ISBN is a primary key column’;

Column variable onlyFor columns, the macro PKCOLN only accepts the variable %COLUMN%.

CLIENTEXPRESSION and SERVEREXPRESSION

Description Uses the client and/or server expression of a business rule in the triggertemplate, template item, trigger, and procedure script.

Syntax

.CLIENTEXPRESSION(code of the business rule)

.SERVEREXPRESSION(code of the business rule)

Example The business rule ACTIVITY_DATE_CONTROL has the following serverexpression:

activity.begindate < activity.enddate

693

Page 706: Physical Data Model - SAP

PDM Macros

In a trigger based on template AfterDeleteTrigger, you type the followingmacro in the Definition tab of the trigger:

.SERVEREXPRESSION(ACTIVITY_DATE_CONTROL)

This generates the following trigger script:

activity.begindate < activity.enddateend

SQLXML

Description Avoids typing a SQL/XML query in the definition of a trigger, a procedureor a function. Use one of the following tools:

♦ The Insert SQL/XML Macro tool opens a selection dialog box whereyou choose a global element from an XML model open in the workspace,mapped to a PDM, and linked with the SQL/XML extended modeldefinition. Click OK in the dialog box and the SQLXML macro isdisplayed in the definition code, with the code of the XML model(optional) and the code of the global element

♦ The Macros tool, where you select .SQLXML( ) in the list. TheSQLXML macro is displayed empty in the definition code. You must fillthe parentheses with the code of an XML model (optional), followed by ::and the code of a global element. The XML model, from which youchoose a global element, must be open in the workspace, mapped to aPDM, and linked with the SQL/XML extended model definition

694

Page 707: Physical Data Model - SAP

Chapter 15. Writing SQL Statements in PowerDesigner

After generation, the SQLXML macro is replaced by the SQL/XML queryof the global element.

Syntax

.SQLXML(code of an XML model::code of a global element)

Note: the code of an XML model is optional.

Example In a trigger for the table EMPLOYEE, the following macro:

.SQLXML(CorporateMembership::DEPARTMENT)

generates the following trigger script:

select XMLELEMENT( NAME "Department", XMLATTRIBUTES(DEPNUM,DEPNAME),

(select XMLAGG ( XMLELEMENT( NAME "Employee",XMLATTRIBUTES (DEPNUM,EMPID,FIRSTNAME,LASTNAME)) )

from EMPLOYEEwhere DEPNUM = DEPNUM))

from DEPARTMENT

695

Page 708: Physical Data Model - SAP

PDM Variables

PDM VariablesMany objects have both a code variable and a generated code variable.

The code variable is the attribute code that is defined in the object propertysheet.

The generated code variable is computed from the attribute code accordingto available generation options. The values for the code and generated codevariables can be different in the following situations:

♦ When the Code is a reserved word or it contains invalid characters, thegenerated code is quoted

♦ When the code is longer than authorized by the database, the generatedcode is truncated

Note:

To access variables of sub-objects (columns in a table for example) you haveto use loop macros or GTL macros to browse the list of sub-objects. Forexample, in a trigger the following macro loops on table columns and foreach column with the CannotModify attribute outputs the code of thecolumn followed by “cannot be modified”:

.foreach_item(Table.Columns)

.if(%CannotModify%)-- "%Code%" cannot be modified

.endif

.next

+ For more information, see “Using macros” in the chapter “BuildingTriggers and Procedures”.

Common variables for allnamed objects

The following variables can be used for all named object definitions:

Variable name Comment

@OBJTNAME Object name

@OBJTCODE Object code

@OBJTLABL Object comment

@OBJTDESC Object description

Common variables forobjects

The following variables can be used in all object definitions:

696

Page 709: Physical Data Model - SAP

Chapter 15. Writing SQL Statements in PowerDesigner

Variable name Comment

COMMENT Object comment. If no comment is defined the objectname is used

OWNER Generated code of the object owner, or the object parent

DBPREFIX Database prefix of object (name of database + ‘.’ ifdatabase defined)

QUALIFIER Whole object qualifier (database prefix + owner prefix)

OPTIONS SQL text defining physical options for object

CONSTNAME Object constraint name

CONSTRAINT Object constraint SQL body. For example(A <= 0) AND(A >= 10)

RULES Concatenation of server expression for business ruleassociated with object

Table variables The following variables can used in a table definition:

Variable name Comment

TABLE Generated code of the table

TNAME Table name

TCODE Table code

TLABL Table comment

PKEYCOLUMNS List of primary key columns. For example: A, B

TABLDEFN Complete body of the table definition. It containsdefinition of columns, checks and keys

CLASS Abstract data type name

CLUSTERCOLUMNS List of columns used for the cluster

Variables for domain andcolumn checks

The following variables can be used in domain check parameter and columncheck parameter definitions:

Variable name Comment

UNIT Standard check unit attribute

697

Page 710: Physical Data Model - SAP

PDM Variables

Variable name Comment

FORMAT Standard check format attribute

DATATYPE Data type. For example int, char(10) or numeric(8, 2)

DTTPCODE Data type code. For example int, char or numeric

LENGTH Data type length. For example 0, 10 or 8

PREC Data type precision. For example 0, 0 or 2

ISRDONLY TRUE if the read-only attribute of standard check isselected

DEFAULT Default value

MINVAL Minimum value

MAXVAL Maximum value

VALUES List of values. For example(0, 1, 2, 3, 4, 5)

LISTVAL SQL constraint associated with a list of values. Forexample C1 in (0, 1, 2, 3, 4, 5)

MINMAX SQL constraint associated with minimum and maximumvalues. For example(C1 <= 0) AND (C1 >= 5)

ISMAND TRUE if the domain or column is mandatory

MAND Contains the keywords “null” or “not null” depending onif the attribute is mandatory or not mandatory

NULL Contains keyword “null” if the domain or column is notmandatory

NOTNULL Contains Keyword “not null” if the domain or column ismandatory

IDENTITY Keyword “identity” if the domain or column is identity(Sybase specific)

WITHDEFAULT Keyword “with default” if the domain or column is withdefault

ISUPPERVAL TRUE if the upper-case attribute of standard check isselected

ISLOWERVAL TRUE if the lower-case attribute of standard check isselected

698

Page 711: Physical Data Model - SAP

Chapter 15. Writing SQL Statements in PowerDesigner

Column variables The following variables can be used in a column definition:

Variable name Comment

COLUMN Generated code of the column

COLNNO Position of Column in List of columns of Table

COLNNAME Column name

COLNCODE Column code

PRIMARY Contains Keyword “primary” if the column is a primarykey column

ISPKEY TRUE if the column is part of a primary key

FOREIGN TRUE if the column is part of a foreign key

COMPUTE Compute constraint text

Abstract data typevariables

The following variables can be used in an abstract data type definition:

Variable name Comment

ADT Generated code of the abstract data type

TYPE Type of Abstract data type. For example “array”, or “list”

SIZE Abstract data type size

ISARRAY TRUE if the abstract data type is of type array

ISLIST TRUE if the abstract data type is of type list

ISSTRUCT TRUE if the abstract data type is of type structure

ISOBJECT TRUE if the abstract data type is of type object

ISJAVA TRUE if the abstract data type is of type JAVA class

ADTDEF Contains definition of the abstract data type

Abstract data typeattribute variables

The following variable can be used in an abstract data type attributedefinition:

Variable name Comment

ADTATTR Generated code of an abstract data type attribute

Domain variables The following variable can be used in a domain definition:

699

Page 712: Physical Data Model - SAP

PDM Variables

Variable name Comment

DOMAIN Generated code of a domain (also available for columns)

Business rule variables The following variables can be used in a business rule definition:

Variable name Comment

RULE Generated code of a business rule

RULENAME Rule name

RULECODE Rule code

RULECEXPR Rule client expression

RULESEXPR Rule server expression

Index variables The following variables can be used in an index definition:

Variable name Comment

TABLE Generated code of the parent of an index, can be a tableor a query table (view)

INDEX Generated code of the index

INDEXNAME Index name

INDEXCODE Index code

UNIQUE Contains keyword “unique” when an index is unique

INDEXTYPE Contains the index type (DBMS dependant)

CIDXLIST List of index columns. For example A asc, B desc, C asc

INDEXKEY Contains keywords “primary”, “unique” or “foreign”depending on an index origin

CLUSTER Contains keyword “cluster” when an index is a clusteredindex

INDXDEFN Used for defining an index within a table definition

Index column variables The following variables can be used in index column definitions:

700

Page 713: Physical Data Model - SAP

Chapter 15. Writing SQL Statements in PowerDesigner

Variable name Comment

ASC Contains keywords “ASC” or “DESC” depending on thesort order

ISASC TRUE if the index column sort is ascending

Reference variables The following variables can be used in a reference definition:

Variable name Comment

REFR Generated code of the reference

PARENT Generated code of the parent table

PNAME Parent table name

PCODE Parent table name

PQUALIFIER Parent table qualifier. See also QUALIFIER

CHILD Generated code of a child table

CNAME Child table name

CCODE Child table code

CQUALIFIER Child table qualifier. See also QUALIFIER

REFRNAME Reference name

REFRCODE Reference code

FKCON-STRAINT

Foreign key (reference) constraint name

PKCON-STRAINT

Constraint name of the primary key used to referencethe object

CKEY-COLUMNS

List of parent key columns. For example: C1, C2, C3

FKEY-COLUMNS

List of child foreign key columns. For example: C1, C2,C3

UPDCONST Update declarative constraint. This can be any of thefollowing keywords

Restrict

Cascade

Set null

Set default

701

Page 714: Physical Data Model - SAP

PDM Variables

Variable name Comment

DELCONST Delete declarative constraint. This can be any of thefollowing keywords

Restrict

Cascade

Set null

Set default

MINCARD Minimum cardinality

MAXCARD Maximum cardinality

POWNER Parent table owner name

COWNER Child table owner name

CHCKONCMMT TRUE when check on commit is selected on a reference(ASA 6.0 specific)

JOINS Reference joins

REFRNO Reference number in the child table collection of refer-ences

Reference columnvariables

The following variables can be used in reference column definitions:

Variable name Comment

CKEYCOLUMN Generated code of the parent table column (primary key)

FKEYCOLUMN Generated code of a child table column (foreign key)

PK Generated code of a primary key column

PKNAME Primary key column name

FK Generated code of a foreign key column

FKNAME Foreign key column name

AK Alternate key column code (same as PK)

AKNAME Alternate key column name (same as PKNAME)

COLTYPE Primary key column data type

DEFAULT Foreign key column default value

HOSTCOLTYPE Primary key column data type used in procedure decla-ration. For example: without length

702

Page 715: Physical Data Model - SAP

Chapter 15. Writing SQL Statements in PowerDesigner

Key variables The following variables can be used in a key definition:

Variable name Comment

COLUMNSCOLNLIST

List of key columns. For example”A, B, C”

ISPKEY TRUE when a key is the primary key for the table

PKEY Primary key constraint name

AKEY Alternate key constraint name

KEY Key constraint name

ISMULTICOLN True if the key has more than one column

CLUSTER Cluster keyword

Variables for views The following variables can be used in a view definition:

Variable name Comment

VIEW Generated code of the view

VIEWNAME View name

VIEWCODE View code

VIEWCOLN List of columns of a view. For example: “A, B, C”

SQL SQL text of a view. For example Select * from T1

VIEWCHECK Contains the keyword “with check option” if this optionis selected in the view property sheet

SCRIPT Complete view creation order. For example create viewV1 as select * from T1

Trigger variables The variables listed below can be used in a trigger definition. You can alsouse owning table variables in a trigger definition.

Variable name Comment

ORDER Order number of Trigger (where the current DBMSsupports more than one trigger of one type)

TRIGGER Generated code of the trigger

REFNO Reference order number in the list of references for thetable

ERRNO Error number for standard error

703

Page 716: Physical Data Model - SAP

PDM Variables

Variable name Comment

ERRMSG Error message for standard error

MSGTAB Name of a table containing user-defined error messages

MSGNO Name of a column containing error numbers in a user-defined error table

MSGTXT Name of a column containing error messages in auser-defined error table

SCRIPT SQL script of trigger or procedure.

TRGBODY Trigger body (only for Oracle live database reverseengineering)

TRGDESC Trigger description (only for Oracle live databasereverse engineering)

TRGDEFN Trigger definition

Database, trigger, andprocedure generationvariables

The following variables can be used for database, procedure, and triggergeneration:

Variable name Comment

DATE Generation date & time

USER Login name of the user executing the generation

PATHSCRIPT Path where the file script will be generated

NAMESCRIPT Name of the file script where SQL orders will be written

STARTCMD Description explaining how to execute a generated script

ISUPPER TRUE if upper case generation option is set

ISLOWER TRUE if lower case generation option is set

DBMSNAME Name of the DBMS associated with the generated model

DATABASE Code of the database associated with the generated model

Reverse engineeringvariables

The following variables can be used when reverse engineering a databaseinto a PDM:

704

Page 717: Physical Data Model - SAP

Chapter 15. Writing SQL Statements in PowerDesigner

Variable name Comment

R Set to TRUE during reverse engineering

S Allows to skip a word. The string is parsed for reverseengineering but is not generated

D Allows to skip a numeric value. The numeric value isparsed for reverse engineering but is not generated

A Allows to skip all text. The text is parsed for reverseengineering but is not generated

ISODBCUSER True if the current user is the connected user

CATALOG Catalog name that will be used in live database reverseengineering queries

SCHEMA Schema that will be used in live database reverse engi-neering queries

SIZE Data type size of a column or a domain. Used for livedatabase reverse engineering, when a data type length isnot defined in the system tables

VALUE One value from the list of values in a column or domain

TRGTYPE Variable used in the Create order of a trigger. Triggertype uses keywords for each trigger type, for example“BeforeInsert”, or “AfterUpdate”

TRGEVENT Variable used in the Create order of a trigger. Triggerevent uses keywords for each trigger event, for example”Insert”, “Update”, and “Delete”

TRGTIME Variable used in the Create order of a trigger. Timing oftrigger uses the keywords “Null”, “Before”, and “After”

Databasesynchronization variables

The following variables can be used for database generation whensynchronizing a modified PDM with an existing database:

Variable name Comment

OLDOWNER Old owner name of the object. See also OWNER

NEWOWNER New owner name of the object. See also OWNER

OLDQUALIFIER Old qualifier of the object. See also QUALIFIER

NEWQUALIFIER New qualifier for the object. See also QUALIFIER

705

Page 718: Physical Data Model - SAP

PDM Variables

Variable name Comment

OLDTABL Old code of the table

NEWTABL New code of the table

OLDCOLN Old code of the column

NEWCOLN New code of the column

Database securityvariables

The following database security variables are available:

Variable name Comment

PRIVLIST List of privileges for a grant/revoke order

PERMLIST List of permissions for a grant/revoke order

GRANTEE Name of the user, group, or role for a grant/revokeorder

ID Name of the user

GROUP Name of the group

ROLE Name of the role

OBJECT Database objects (table, view, column, and so on)

PERMISSION SQL grant/revoke order for a database object

PRIVILEGE SQL grant/revoke order for an ID (user, group, orrole)

GRANTOPTION Option for grant: with grant option / with adminoption

REVOKEOPTION Option for revoke: with cascade

Metadata variables The following metadata variables are available:

Variable name Comment

@CLSSNAME Localized name for an object class. For example: Table,View, Column, Index

@CLSSCODE Object class code. For example: TABL, VIEW, COLN,INDX

DBMS, database optionsvariables

The following DBMS and database options variables are available:

706

Page 719: Physical Data Model - SAP

Chapter 15. Writing SQL Statements in PowerDesigner

Variable name Comment

TABLESPACE Generated code of a tablespace

STORAGE Generated code of a storage

Variables for ASE & SQLServer

The following DBMS specific variables are available for Sybase AdaptiveServer Anywhere and Microsoft SQL Server:

Variable name Comment

RULENAME Name of a business rule object associated with adomain

DEFAULTNAME Name of a default object associated with a domain

USE_SP_PKEY Use sp_primary key to create primary keys (SQLServer)

USE_SP_FKEY Use sp_foreign key to create foreign keys (SQLServer)

Sequence variable The following variable can be used in a sequence definition:

Variable name Comment

SQNC Name of sequence

Procedure variables The following variables can be used in a procedure definition:

Variable name Comment

PROC Generated code of a procedure (also available for triggerwhen a trigger is implemented with a procedure)

FUNC Generated code of a procedure where the procedure is afunction (with a return value)

Join index variables (IQ) The following variables can be used in a join index definition:

Variable name Comment

JIDX Generated code for join index

JIDXDEFN Complete body of join index definition

REFRLIST List of references (for live database connection)

RFJNLIST List of reference joins (for live database connection)

707

Page 720: Physical Data Model - SAP

PowerDesigner Formatting Variables

PowerDesigner Formatting VariablesVariables have a syntax that can force a format on their values, as follows:

♦ Force values to lower-case or upper-case characters

♦ Truncate the length of values

When a variable does not specify formatting, its values have the same formatas in the PDM.

Format code Format of variable value in script

.L Lower-case characters

.T Removes blank spaces

.U Upper-case characters

.c Upper-case first letter and lower-case next letters

.n Maximum length where n is the number of characters

n Justifies to fixed length where n is the number of characters

-n Right justify variable text to fixed length where n is thenumber of characters

You embed formatting options in variable syntax as follows:

%.format:variable%

For example:

%.L:TABLE%

The table below shows formatted variables and their results in a script for thetable EMPLOYEE.

Template statement with variable Resulting script statement

create trigger %TABLE% create trigger EMPLOYEE

create trigger %.L:TABLE% create trigger employee

create trigger %.U:TABLE% create trigger EMPLOYEE

create trigger %.4:TABLE% create trigger EMPL

create trigger %.4L:TABLE% create trigger empl

708

Page 721: Physical Data Model - SAP

CHAPTER 16

Migrating from ERwin to PowerDesigner

About this appendix This appendix explains how to migrate from ERwin to PowerDesigner. Youwill learn about the differences between the two design environments andhow to import your models into PowerDesigner.

Contents Topic: page

Introducing the ERwin Import Process 710

Preparing to Import your ERwin models 712

The Import Process 713

After Importing 715

Getting Started Using PowerDesigner 720

709

Page 722: Physical Data Model - SAP

Introducing the ERwin Import Process

Introducing the ERwin Import ProcessYou can easily import a model built with ERwin into PowerDesigner with noloss of metadata. PowerDesigner allows complete flexibility through reliablelinking and synchronization between conceptual, physical andobject-oriented model approaches, providing outstanding model clarity andflexibility.

File types

PowerDesigner supports the import of the following ERwin file types:

♦ ERwin v3.x (.erx)

♦ ERwin v4.x (.xml)

♦ ERwin v7.x (.xml) – the ERwin model must be saved as “Standard XMLFormat”, and you must uncheck the “Only save minimum amount ofinformation” check box in the ERwin Save as XML File dialog box.

Versions 4.x or 7.x are recommended, as they contain more metadata.

ERwin and PowerDesigner implement database design in different ways.

♦ An ERwin logical model can be imported into either:• a PowerDesigner conceptual data model (CDM), or

• a PowerDesigner logical data model

♦ An ERwin Physical Model is imported into a PowerDesigner physicaldata model (PDM)

In the PowerDesigner Physical Data Model you can use two design levels:the logical model allows you to design the database structure and performsome database denormalization actions without taking into account anyDBMS physical requirement. The physical model allows you to design thedatabase taking into account the physical requirements of a given DBMS

710

Page 723: Physical Data Model - SAP

Chapter 16. Migrating from ERwin to PowerDesigner

Limitations

You cannot import the following ERwin objects:

♦ ERwin triggers and stored procedures (not directly possible, but see theprocess in ““Post-import checklist” on page 717”)

♦ ERwin reports

♦ ER1 files

♦ ERwin data sources

♦ ERwin target clients

While PowerDesigner can import all your object display preferences andwill retain color and font information, it does not support multiple colors forcolumns in a single table. The default column color will be used during theimport.

711

Page 724: Physical Data Model - SAP

Preparing to Import your ERwin models

Preparing to Import your ERwin modelsThis section provides a list of suggestions for how to prepare your ERwinfiles and set up your PowerDesigner environment:

♦ We recommend that you import from an ERwin 4.x file (.xml) rather thana 3.x file (.erx), due to the greater amount of metadata available in thenewer ERwin files.

♦ Review your ERwin model to see if any model object names areduplicated. It is good practice to avoid using duplicate names, andPowerDesigner will automatically attach a suffix to any duplicate objectsthat it encounters during the import process.

712

Page 725: Physical Data Model - SAP

Chapter 16. Migrating from ERwin to PowerDesigner

The Import ProcessPowerDesigner provides a wizard to automatically import your ERwin files.

v To import an ERwin model into PowerDesigner

1. Select File ä Import ä ERwin File.

2. Select or browse to the directory that contains the ERwin file, select it,and then click Open.

3. If the ERwin file contains only a physical model, you will be prompted tochoose whether to import references as triggers. Select Yes or No tobegin the import.

Alternatively, if the ERwin file contains a logical model or a combinedlogical and physical model, the ERwin model import dialog box opens:

The options available depend on the type of ERwin model that you areimporting. The traditional approach to data modeling in PowerDesigneris to create a Conceptual Data Model synchronized with a Physical DataModel. The full set of options is as follows:

♦ A Conceptual Data Model can be created when you are importing anERwin Logical Model. It provides a platform-independentrepresentation of a system, giving an abstract view of its static datastructures, and permitting real normalized data structures withmany-to-many and inheritance relationships.

♦ A Logical Data Model can be created when you are importing anERwin Logical Model. It allows you to resolve many-to-many andsuper/sub-type relationships, de-normalize your data structures, anddefine indexes, without specifying a particular RDBMS. InPowerDesigner, a Logical Data Model is an RDBMS-independentversion of a Physical Data Model.

713

Page 726: Physical Data Model - SAP

The Import Process

♦ A Physical Data Model can be created when you are importing anERwin Physical Model. It is a representation of a real database andassociated objects running on a server with complete information onthe structure of the physical objects, such as tables, columns,references, triggers, stored procedures, views, and indexes.

Select the checkbox for each type of models that you want to create.

4. If your ERwin model contains a logical model, and you want to create aconceptual data model, then you can choose to merge identical dataitems. This is a powerful metadata management technique that is notavailable in the ERwin environment.

For example, your ERwin logical model may contain multiple entitiesthat contain an attribute “address”. By default, PowerDesigner will createa separate data item for each of these entity attributes. However if youselect the Merge identical data items checkbox, then a single data itemwill be created, and adjustments to it will automatically cascade down toall the associated entity attributes.

5. If your ERwin model contains a physical model, then you can choosewhether to implement referential integrity using triggers.

6. Click OK to begin the import. When the process is complete, theimported models will appear in the Browser.

714

Page 727: Physical Data Model - SAP

Chapter 16. Migrating from ERwin to PowerDesigner

After ImportingThis section describes what you should expect in your newly-importedmodels.

PowerDesigner object terminology

PowerDesigner and ERwin use a different terminology to speak about manyof their model objects. The following sections compare how these two toolsrefer to model objects.

General PowerDesigner model objects

The import process converts general ERwin model objects intoPowerDesigner objects as follows:

ERwin PowerDesigner

Model Model

Stored display and subjectarea

Diagram

Business rule Business rule

Domain Domain

Symbols ( including symbolsize and position)

Symbols ( including symbol size and posi-tion)

Description Description

Notes Annotation

Text block Text symbol

IE notation Entity/Relationship notation

IDEF1X notation IDEF1X notation

User-defined properties Imported as extended attributes stored into aspecific extended model definition embeddedin the model. The name of this extendedmodel definition is Imported Attributes, youcan manage it from the resource editor. Formore information, see the Extended ModelDefinitions Reference Guide chapter in theAdvanced User Documentation .

715

Page 728: Physical Data Model - SAP

After Importing

PowerDesigner conceptual data model objects

The import process converts ERwin logical model objects into conceptualdata model (CDM) objects as follows:

ERwin logical model PowerDesigner CDM

Attribute Data item, entity attribute

Key group Identifier

Entity Entity

Relationship Relationship

Subtype relationship Inheritance link

Subtype category Inheritance

PowerDesigner physical data model objects

The import process translates ERwin physical model objects into physicaldata model (PDM) objects as follows:

ERwin physical model PowerDesigner PDM

Column Column

Key Key

Table Table

Relationship Reference

Index Index

View table View

Fact, dimension, outrigger Table

Target database Current DBMS

Valid value Check parameter

Tablespace Tablespace

Segment Storage

716

Page 729: Physical Data Model - SAP

Chapter 16. Migrating from ERwin to PowerDesigner

Post-import checklist

This section lists a series of recommended post-import checks and processes.

Import triggers: Triggers cannot be directly imported from ERwin. Thereare, however, two methods for transferring your constraint triggerinformation to PowerDesigner:

♦ Automatically generate triggers: To do this, select Tools ä RebuildObjects ä Rebuild Triggers. Creating triggers in this way ensures thatthey will be synchronized automatically by PowerDesigner, but the actualcode may be different from that which you are used to in ERwin.

♦ Reverse engineer triggers: To do this, generate the triggers from ERwin,and then reverse engineer them into PowerDesigner. Creating triggers inthis way ensures that they use exactly the same code as before, but theywill not be automatically synchronized by PowerDesigner.

Import procedures: Procedures cannot be directly imported from ERwin.You can, however transfer them by generating the triggers from ERwin, andthen reverse engineering them into PowerDesigner.

Set up your object naming conventions and other model options: Tocontrol the naming conventions of model objects in PowerDesigner, selectTools ä Model Options, and then click on the object entry in the NamingConvention category in the Category pane:

717

Page 730: Physical Data Model - SAP

After Importing

You can control other object creation defaults by clicking on the object entryin the Model Settings category:

718

Page 731: Physical Data Model - SAP

Chapter 16. Migrating from ERwin to PowerDesigner

Differences to Expect

This section lists certain differences that you may encounter when workingwith your imported ERwin model in PowerDesigner.

Why do I see errors in Check Model when my ERwin model was clean?PowerDesigner performs stricter checks than ERwin. For example, duplicateobjects are not permitted in PowerDesigner, and the existence of orphaneditems will generate a warning.

Why do some of my object symbols appear with numeric suffixes? If anobject is required to appear more than once in a diagram (for, example, toimprove readability), PowerDesigner will create a graphical synonym torepresent it. Thus, if the table “Purchase” is displayed twice in a diagram,the two symbols will be labeled as “Purchase: 1” and “Purchase: 2”.

719

Page 732: Physical Data Model - SAP

Getting Started Using PowerDesigner

Getting Started Using PowerDesignerThis section lists some common tasks that you will want to perform withPowerDesigner:

Objects How do I find objects? All the objects in the model are listed, organized bytype, in the Browser. PowerDesigner provides various methods for locatingyour objects:

♦ To find the symbol for an object in the Browser: Right-click the objectin the Browser and select Find in Diagram from the contextual menu.

♦ To find the browser entry for an object symbol: Right-click the symbolin the diagram and select Find in Browser from the contextual menu.

♦ To search for an object: Type CTRL+F to open the Find Objects dialogbox. Enter the text to search for (you can use the asterisk as a wild card)and click Find Now. Right-click any of the results choose whether to findit in the Browser or Diagram.

How do I edit objects? You can edit the name of an object by selecting itssymbol in the diagram and typing F2. To edit other object properties,double-click the symbol or the object entry in the Browser and enter thenecessary information in its property sheet.

How do I share objects? You can share objects between packages andmodels using shortcuts and replications. For more information see the“Managing Shortcuts” and “Managing Object Replications” chapters in thePowerDesigner General Features Guide .

Packages/Subject Areas How do I create subject areas? In PowerDesigner, you can create multipleviews of your model by adding additional diagrams. You can also divideyour model into smaller subdivisions using packages.

♦ To add a diagram to your model: Right-click the diagram backgroundand select Diagram ä New Diagram ä [Diagram Type] from thecontextual menu.

♦ To convert a diagram into a package: Right-click the diagrambackground and select Diagram ä Convert to Package. The ConvertDiagram to Package wizard will open, permitting you to name thepackage and select objects to move into it. The package will appear in theBrowser with its own diagram and associated objects. For moreinformation about packages, see the “Managing Models” chapter in thePowerDesigner General Features Guide .

Reports How do I create a report? PowerDesigner provides wizards to create twodifferent types of report:

720

Page 733: Physical Data Model - SAP

Chapter 16. Migrating from ERwin to PowerDesigner

♦ To create a report about a specific type of object: Select Report ä ListReport Wizard and follow the wizard instructions.

♦ To create a report about multiple object types or the whole model:Select Report ä Report Wizard and follow the wizard instructions.

For more information about PowerDesigner reports, see the Working withReports .

Databases How do I create a model from a database? Select File ä Reverse Engineerä Database and complete the dialog box. For more information, see the“Reverse Engineering a Database into a PDM” chapter.

How do I update my model from a database? Select Database ä ReverseEngineer ä Database and complete the dialog box. A Merge window willopen to allow you to verify the changes to be made before committing them.For more information, see the “Reverse Engineering a Database into aPDM” chapter.

How do I generate a database from my model? Select Database ä

Generate Database and complete the dialog box. For more information, seethe “Generating a Database from a PDM” chapter.

How do I update a database from my model? Select Database ä ModifyDatabase and complete the dialog box. A Database Synchronization windowwill open to allow you to verify the changes to be made before committingthem. For more information, see the “Generating a Database from a PDM”chapter.

Models How do I compare two models? Select Tools ä Compare Models andcomplete the dialog box. For more information, see the “Comparing andMerging Models” chapter in the PowerDesigner General Features Guide .

How do I merge two models? Select Tools ä Merge Model and completethe dialog box. For more information, see the “Comparing and MergingModels” chapter in the PowerDesigner General Features Guide .

721

Page 734: Physical Data Model - SAP

Getting Started Using PowerDesigner

722

Page 735: Physical Data Model - SAP

Index

Aabort on character loss in reverse engineering 533abstract data type 29, 76

abstract object 327attribute variable 699categories 76check 327code uniqueness 327create 77, 455drop 455instantiable object 327link to Java class 81name uniqueness 327properties 77use in PowerDesigner 76variable 699

abstract data type procedurecheck 327code uniqueness 327definition 327name conflict with attribute 327name uniqueness 327return type 327

accessdatabase 254, 521

Access 97 468, 538, 559access.mdb 468, 559add

column to key 47package hierarchy 429reference to join index 665template item to trigger template 213

add-in MS SQL Server 560admin option 258administrator permission 524AKCOLN 685alias 276all permission 262ALLCOL 685alter

permission 262script 514

alternate key 22column 45constraint 47, 48define 42designate 45display 180generate 456, 458generate index 54index 50, 53, 459name 46number 48, 180physical option 458variable 48

ambiguous detection in Java reverse engineering 533analysis

server 560services 560

annotated schema 440apm 7apply transformation 547archive 7ASK column default 33assign

data profile 496test data profile 480

association 136, 151create 151display preferences 176properties 151

association (multidimensional diagram) 360check 340existence of hierarchy 340

asymmetric key 584attach procedure to table 230attribute 136, 142

create 142properties 142

attribute (multidimensional diagram) 360check 339mapping not defined 338name uniqueness 339

auto-arrange join order 92

723

Page 736: Physical Data Model - SAP

Index

auto-increment column in Sybase ASA 648auto-layout during reverse engineering 532automatic

archive 7generate test data 483, 486, 488rebuild triggers 190trigger creation 190

auto-migrate 87check parameter 87column 88columns (model option) 166default join 91domain 87validation rule 87

auto-reuse columns 88, 166

Bbase object 276based on 29begin script 452, 456, 463, 473, 475, 477bend

reference 99bibliography xibinary data type 67, 419bitmap data type 67, 419bitmap index 53bitmap join index 619

add reference 624check model 340column 623create 621options in Oracle 622properties 622rebuild 620table 622

BLOB average size 510block terminator 532boolean data type 65, 417buffer pool 468build

index 54reference 97

business rule (PDM) 398, 399apply 124, 408check model 309constraint 402create 400

definition 400domain 68expression 124, 401fact 400formula 400property 399type 399, 400validation 124, 400, 454, 456, 457variable 700

byte data type 65, 417

Ccandidate key 42cardinality

format 95maximum 95minimum 95reference 95, 178referential integrity 95

case sensitivity (model option) 160CDM

data type 417generate 420, 421generate PDM 423generation options 420, 421import 710modify 417open in current version 423preserve 417serial data type 71update 417

CDM objects translated from PDM 417CDM/PDM pair 713certificate 583change parent allowed model option 166change target database 156character

data profile 486format 465, 518mask 486script 465, 518

check modelabstract data type 327abstract data type procedure 327association 340attribute (multidimensional diagram) 339bitmap join index 340

724

Page 737: Physical Data Model - SAP

Index

business rule (PDM) 309column 317cube 336cursor 332data source object 335database package 329default 342dimension 338dimension hierarchy 340domain (PDM) 314exception 333extended link 345extended object 345fact 337fact measure 337file object 335group 312horizontal partitioning 306index 320join index 340key 323package (PDM) 309package procedure 331package type 333PDM 306procedure 334reference 324replication (PDM) 341role 313sequence 342storage 343synonym 328table 315table collapsing 307tablespace 344trigger 324user 311variable 332vertical partitioning 308view 326view index 321view reference 325Web operation 345Web service 345

check on commit model option 166check parameter

additional 123

auto-migrate 87column 40, 122, 124, 457constraint 31, 40data profile 496data type 37define 122domain 68, 122, 124generate 454, 456, 457property 122standard 122table 31, 456type 122validation 124validation rule 122, 398, 399

child table 48change 99

circular extended dependency 115, 247clear index 54client

business rule (PDM) 401expression 124, 401

CLIENTEXPRESSION 693close

database 452CLR aggregate function 579CLR assembly 577CLR function 581CLR integration 577CLR procedure 581CLR trigger 582CLR user-defined type 580cluster

key 43referential integrity 95

clustered index 50, 53CODASYL 100code maximum length

Web operation 345Web service 345

code uniquenessextended link 345extended object 345Web operation 345Web service 345

collapse tables 388column 22, 33

add 39

725

Page 738: Physical Data Model - SAP

Index

add to key 47additional checks 33alternate key 45assign default 59attach domain 38auto-migrate 88auto-reuse 88average length 34bitmap join index 623check model 317check parameter 122, 124, 457check parameter variable 697comment 457computed 33, 36computed expression 34constraint 40constraint business rule 409create 33, 39, 456, 457data type 37, 180, 183default 33details 33, 34display 180distinct values 34domain 68domain coherence 68duplicate 39fill parameter 494foreign key 33, 46generate 456, 457identity 33, 180indicated property 494indicator 180link to key 92list 41migrate 92non-divergence from domain 68null 180null values 34options 33permission 265, 267primary key 33, 43properties 33, 103property 33reuse 92sequence for 71sort 41standard checks 33

statistics 541table 180test data 34test data parameter 34validation rule 124, 457variable 124, 688, 698view 102, 183with default (DB2) 33

column denormalization 393delete replica 395duplicate columns 393generate PDM 395replication 393revert 395select column 393wizard 393

column mandatory by default (model option) 165command

storage 470tablespace 470

commentcolumn 457generate name for empty comment 465package (PDM) 20script 465, 518table 456view 461

composite view 19computed column 33, 36conceptual data type 65, 156configure

CDM options 421OOM options 427storage 468tablespace 468

connectdatabase 445, 521, 522

connection profile 444constant 630constraint

alternate key 47, 48business rule 402column 40delete 95, 218foreign key 47, 48generate 45insert 217

726

Page 739: Physical Data Model - SAP

Index

link index 50name 31, 40, 47, 48primary key 47table 31unique 45update 95, 218

constraint business rule 402apply to table or column 409column 409create 404generate 406reverse engineer 407table 409

constraint namedefault 48, 49display 178label 178

contract 595convert external sources 362CSV file

import 492import restriction 492

cube 136, 138, 360check 336create 138display preferences 177duplicated association 336existence of association 336existence of fact 336generate cube data 357generate in MS SQL Server 562generate in MS SQL Server 2005 603name uniqueness 336properties 138rebuild 350reverse engineer in MS SQL Server 563reverse engineer in MS SQL Server 2005 608

cube data generation 357data fields 358define query 357dimension 358member 358text file 358

cursorcheck 332code uniqueness 332database package 329

definition 332, 632in database package 632name uniqueness 332parameters 332, 632public 632return data type 632return type 332

customizefunction 222procedure 222script 452, 456, 472, 473, 475, 477

Ddata access 372data fields 358data movement script

Sybase IQ 666data profile

assign 496assign from table 497, 498check parameter 496data source 482date/time 483define 480export 500foreign key 496import 499

data source in a PDM 362automatic 483check 335CSV file 492database 491differing DBMS 335disconnect 445existence of PDM 335list 490name uniqueness 335test data 482

data type 63, 64average length 510binary 67, 419bitmap 67, 419BLOB 510boolean 65, 417byte 65, 417character 66column 37, 180, 183

727

Page 740: Physical Data Model - SAP

Index

conceptual 417convert to conceptual 156create 454date 66, 419decimal 65, 417display 180domain 64, 68drop 454float 65, 417image 67, 419integer 65, 417length 63, 64money 65, 417number 65, 417OLE 67, 419OOM 426precision 63, 64select 37serial 65, 417time 66, 419translate 156, 417undefined 37, 67, 419view 183

data warehousefeature comparison 360migrate 360

database 7access 254, 521add user to group 274change 156checks 346close 452connect 445, 521, 522create 8, 10, 446, 452, 472create script 452, 473define 9denormalization 372display 445, 521, 522drop 452estimate size 508generate 446, 472, 514generate PDM 536generate privileges 261group 255, 273information 445modify 514MS Access 97 468, 538, 559

open 452optimize reverse engineering 539options variable 706owner 256parameter 516permission 262physical option 452prefix tablespace in DB2 OS/390 130, 548preserve object 156privilege 257property 9quick launch 449reverse engineer 524reverse engineer tablespace physical options in

Oracle 636role 255, 270script 446, 514select 156settings sets 449size 508statistics 541synchronization variable 705target 156test data 491user 255variable 704

database mirroring 591database package 625

body 625check 329code length 329code uniqueness 329create during generation 635default owner 175define 625define cursors 632define exceptions 633define procedure 628define types 634define variables 630drop during generation 635existence of cursor 329existence of exception 329existence of procedure 329existence of type 329existence of variable 329generate 635

728

Page 741: Physical Data Model - SAP

Index

initialization 634insert procedure 627name length 329name uniqueness 329owner 625privilege 625reverse engineer 636specification 625

database package cursor 632database package exception 633database package procedure 627

check 331code uniqueness 331definition 331, 628name uniqueness 331parameters 331, 628public 628replication of stored procedure 627return data type 628return type 331type 628

database package procedure dependenciesrebuild 228

database package type 634check 333code uniqueness 333definition 333name uniqueness 333

database partition group 551database space 468DATE 660date

data profile 483data type 66, 419

DB2 548column default 33reverse engineer 536

DBCreateAfter 115, 247DBMS 12, 155

editor 12, 155logical model 413non supported object 156overview 12, 155physical option 127preserve options 414trigger template 206

decimal data type 65, 417

decision support object 560default 58

assign 59automatic rebuild 60check model 342code maximum length 342column 33constraint name 48, 49create 58, 455delete and rebuild 60drop 455generate 455name uniqueness 342physical option 127physical options objects 127properties 58rebuild 60reuse 60same value 342test data profile 481value empty 342

default constraints delete model option 166default constraints update model option 166default data type

model option 165default implementation model option 166default link on creation model option 166DEFINE 686DEFINEIF 687definition business rule (PDM) 400delete permission 262denormalization 372

column denormalization 393horizontal partitioning 373table collapsing 388vertical partitioning 380

dependency procedure 224dependency trigger 224detail attribute 143detail column 34detection mode in reverse engineering 533dimension 136, 140, 358

check 338create 140default hierarchy 338detail attribute 143display preferences 177

729

Page 742: Physical Data Model - SAP

Index

duplicated hierarchies 338existence of attribute 338existence of hierarchy 338generate for Oracle 637incomplete mapping 338mapping not defined 338name uniqueness 338Oracle 637properties 140

dimension attributedisplay preferences 177

dimension hierarchy 360check 340existence of attribute 340name uniqueness 340

dimension table 360disconnect data source 445discriminant column 373display preference

association 176cube 177dimension 177dimension attribute 177hierarchy 177package (PDM) 20procedure 178reference 178table 180view 182view column 183view reference 183

distinct values 34domain 62

create 62data type 64modify 67properties 62

domain (PDM)assign default 59attach column 38auto-migrate 87business rule 68check model 314check parameter 68, 122, 124check parameter variable 697coherence 68column 68

data type 63, 64, 68define 62enforce 68length 63, 64mandatory 68non-divergence 68precision 63, 64use 68validation rule 124variable 124, 699

domain mandatory by default (model option) 165drag

reference 99drop

abstract data type 455data type 454database 452default 455foreign key 458, 460index 459join index 463primary key 457, 458sequence 456storage 453synonym 462table 456tablespace 452view 461

DSO metamodel 561DTTM 660duplicate columns 393

Eedit

script 473, 475, 477trigger 199

Enable links to requirements model option 160enabledbprefix 548EnableMultiCheck 402encoding for reverse engineering 533encryption 583end script 452, 456, 463, 473, 475, 477endpoint 592enforce

domain 68non-divergence 68, 165

ERROR 687

730

Page 743: Physical Data Model - SAP

Index

error message 687user-defined 250, 251

ERwinembedded extended model definition 710import 710migrate CDM/PDM pair 713migrating from 713user-defined properties 710

estimatedatabase size 508model database size 511tables database size 512

event 195EventDelimiter 205multiple 205trigger 195

event notification 598EventDelimiter 205events

Sybase Anywhere 671Sybase IQ 669

exceptioncheck 333code uniqueness 333database package 329name uniqueness 333

exception (database package) 633execute permission 262execute query 522export data profile 500expression

business rule 124business rule (PDM) 401client 124, 401server 124, 401

extended attributeDB2 548IBM DB2 553import model from previous version 366import PowerBuilder extended model definition

364Informix 556Interbase 558modify 367MS Access 559MySQL 613NonStop SQL 615

Oracle 639PostgreSQL 642PowerBuilder 364Sybase ASA 653Sybase ASE 654Sybase IQ 669Teradata 674

extended dependenciescircular 115, 247PDM 187stored procedures 247view 114, 115

extended linkcheck 345code uniqueness 345name uniqueness 345

extended model definition 649Imported Attributes 366new PDM 185PowerBuilder 364, 366

extended objectcheck 345code uniqueness 345name uniqueness 345

externalcolumn 362database 362sources 362table 362

external table 32extraction script 353

Select 353

Ffact 136, 145, 360

business rule 400check 337create 145existence of measure 337mapping not defined 337name uniqueness 337properties 145

fact measurecheck 337mapping not defined 337name uniqueness 337

fact table 360

731

Page 744: Physical Data Model - SAP

Index

FASTPROJECTION 660file encoding in reverse engineering 533file object

check 335external 335name uniqueness 335

filegroup 468fill parameter

define value 494indicated column property 494

FKCOLN 687float data type 65, 417force column list 461FOREACH_CHILD 688FOREACH_COLUMN 689FOREACH_PARENT 690foreign key 22

auto-migrate 87change column 94column 33, 46constraint 47, 48data profile 496define 42designate 46drop 458, 460generate 456, 458, 460generate index 54index 50, 53, 459name 50number 180, 182referential integrity 95variable 48, 692

formatcardinality 95character 465, 518script 465, 518variable 478, 708

formula business rule 400full-text catalog 586full-text index 587full-text search 586function

create 222custom 222define 222edit with SQL editor 238function insert 238

insert SQL/XML macro 238macro insert 238operator insert 238permission 262, 265SQL/XML wizard 238variable insert 238

function-based index 50Oracle 8i 50Oracle 8i2 50reverse engineer 50SqlListQuery 50use variables 50

Ggenerate

alternate key 456, 458alternate key index 54annotated schemas via XML Builder Wizard 440automatic archive 7automatic test data source 483, 486, 488CDM 417, 420, 421check parameter 454, 456, 457column 456, 457configure CDM options 421configure OOM options 427constraint 45constraint business rule 406cube data 357cubes in MS SQL Server 562data source 368database 446, 472, 514database package 635DBMS preserve options 414default 455error message 250, 251extraction script 353for MS Access 97 468foreign key 456, 458, 460foreign key index 54index 45, 54, 456, 459inheritance in PDM 546inside table 456join index 463, 664name for empty comment 465new CDM 420new model 412new OOM 427

732

Page 745: Physical Data Model - SAP

Index

new PDM 414OOM 426–428OOM object 425options 15options for test data 501outside table 456PDM 412, 414, 415PDM from database 536PDM to PDM 413physical option 452, 456, 459PowerBuilder extended attribute 368preserve denormalized columns 395preserve horizontal partitioning 377preserve table collapsing 391preserve vertical partitioning 384primary key 456, 457primary key index 54privileges 261procedure 247proxy table script 652public names 368quick launch 449quotation marks 125reference 97referential integrity 95, 456rule 454script 446, 452, 456, 465, 514, 518select object 466sequence 456settings sets 449SQL/XML queries via XML Builder Wizard 440storage 453stored procedures order 247synonym 462synonyms 280table 456tablespace 452test data 480, 490–492, 501trigger 247update model 412validation rule 124, 454, 456, 457view 456, 461views order 115XML model 431, 432XML model via XML Builder Wizard 434

generated code variables 696grant 257, 262

privilege 258with admin option 258with grant option 262

group 255, 273add user 274assign role 271check model 312create 273privilege 257properties 273

HHG index 53hierarchy 136, 149

create 149display preferences 177package (PDM) 19properties 149

HIGHGROUP 660HIGHNONGROUP 660HNG index 53horizontal partitioning 373

cancel 376check model 306delete 376discriminant column 373generate PDM 377MS SQL Server 2005 575object 375, 376partition definition 373partitioned table 373partitions 375revert 378wizard 373

IIBM DB2

database partition group 551extended attributes 553index extension 552web services 286

IDEF1X 100identifier delimiter

script 465identity 180

column 33column in Sybase ASE 648

733

Page 746: Physical Data Model - SAP

Index

column in Sybase ASE 11, 12 654Sybase 33

ignore identifying owner model option 164image data type 67, 419import

CDM 710CSV file 492data profile 499ERwin 710model 710model from previous version 366PowerBuilder extended attributes 366PowerBuilder extended model definition 364web service as service provider 285XPF file 499

INCOLN 691index 22, 50

alternate key 50, 53, 459bitmap 53change DBMS 53check model 320clear 54clustered 50, 53column variable 700create 50, 456display 180drop 459drop join 463estimate database size 508foreign key 50, 53, 459function-based 50generate 45, 54, 456, 459HG 53HNG 53key constraint 50LF 53link to key/reference 50number 180owner 53permission 262primary key 50, 53, 459properties 53property 53query table 57rebuild 54rebuild option 54table 50, 180

type 660types 53unique 45, 50, 53user define 50variable 700

index extension 552Informix extended attributes 556inherit procedure abstract data type 79inheritance 545inheritance in PDM 546

apply transformations 547initialization (database package) 634insert

constraint 217permission 262procedure in template 203trigger template 203, 209

inside table 457, 458, 460install java class 455instead of trigger 105integer data type 65, 417Interbase

extended attribute 558sequences 71

IQ index rebuild 657, 658

JJava class

link 81remove 455reverse engineer 85

JOIN 691join

change child column 94create 91default 91define 91, 92index 463index generate 463migrate column 92primary key 91reference 178reuse column 92, 120table collapsing 388view reference 119

join indexcheck model 340

734

Page 747: Physical Data Model - SAP

Index

create 662define 661generate 664properties 663Sybase AS IQ 661table 661variable 707

join index default owner model option 171join order auto-arranged 92justify variable 478, 708

Kkey 42

add column 47alternate 42check model 323cluster 43code 43create 42define 42foreign 42link column 92name 43primary 42properties 43variable 703

key numberalternate key 180display 180foreign key 180, 182

Llabel

constraint name 178referential integrity 178

length of average data type 510LF index 53link

Java class 76, 85OOM 81reverse Java class 76

listcolumn 41sort 41standard data types 64test data 490

LISTVAL check parameter 123

location of file object 335logical model 4, 413, 545–547

apply transformations 547display inheritance 545generate inheritance links 546

loop macro 696LOWFAST 660

Mmacro

CLIENTEXPRESSION 693SERVEREXPRESSION 693SQLXML 694trigger 685trigger template 685

mandatory parent model option 166manual creation of triggers 191mask character 486materialized query table 113materialized view 113

index 57measure 136, 147, 360

create 147properties 147

member 358message contract 596message error for triggers 250message type 594metadata variables 706metric 360migrate

data warehouse 360ERwin model into CDM/PDM pair 713object conversion from version 6 360version 6 360, 423

migrate from ERwin 713MINMAX check parameter 123mode

reference 99model

copy DBMS 5create 5ERwin 710import 710share DBMS 5

model option 13auto-migrate columns 166

735

Page 748: Physical Data Model - SAP

Index

auto-reuse columns 166change parent allowed 166check on commit 166CODASYL 160column mandatory by default 165conceptual 160database package default owner 175default constraints delete 166default constraints update 166default data type 165default implementation 166default link on creation 166domain mandatory by default 165Enable links to requirements 160enforce non-divergence 165IDEF1X 160ignore identifying owner 164join index default owner 171mandatory parent 166Name/Code case sensitive 160notation 160procedure default owner 172propagate column properties 166rebuild automatically triggers 164relational 160sequence default owner 169table default owner 164, 170table trigger default owner 173unique code 166view default owner 164, 170view trigger default owner 173

modifydatabase 7, 514DBMS procedure template 235DBMS template item 219DBMS trigger template 210extended attribute 367model procedure template 235model trigger template 210, 219trigger 199trigger from table 199

money data type 65, 417move reference to table 99MS Access 559MS Access extended attributes 559MS SQL Server 560

ActiveX 560

analysis server 560analysis services 560cube extended attributes 566customize attributes 569customize cubes 566customize dimensions 567customize hierarchy 571customize multi-dimensional objects 565decision support object 560dimension extended attributes 567DSO metamodel 561enable add-in 560extended attributes 565, 569generate cubes 562hierarchy extended attributes 571MS SQL Server 2005 574repository 560reverse engineer cubes 563

MS SQL Server 2005 574asymmetric key 584certificate 583CLR aggregate function 579CLR assembly 577CLR function 581CLR integration 577CLR procedure 581CLR trigger 582CLR user-defined type 580contract 595database mirroring 591encryption 583endpoint 592event notification 598full-text catalog 586full-text index 587full-text search 586generate cubes 603horizontal partitioning 575message contract 596message type 594partition function 575partition scheme 576queue 596remote service binding 601reverse engineer cubes 608route 600service 600

736

Page 749: Physical Data Model - SAP

Index

service broker 593symmetric key 585synonym 602user schema 612WithOption 612XML data type 589XML index 588XML indexing 588XML schema collection 589XML table column 590

multi DBMS environment 413multidimensional diagram

association 151attribute 142basics 134create 136cube 138dimension 140fact 145hierarchy 149measure 147retrieve objects 348user 255

multiple database 10checks 346IBM DB2 7physical option 10

multiple triggers 204MySQL extended attributes 613

Nname uniqueness

extended link 345extended object 345Web operation 345Web service 345

Name/Code case sensitive model option 160namespace in PDM package 20new PDM 185NMFCOL 692non supported object 156non-divergence 68NonStop SQL extended attributes 615non-unique primary index 673normalization 372notation

CODASYL 100, 160

conceptual 100, 160IDEF1X 100, 160model option (PDM) 160model options 182reference 100, 180relational 100, 160

numberalternate key 48reference 48rows for test data 501

number data type 65, 417

Oobject

attach to user 256owner 256PDM 22

object abstract data type 79inherit procedure 79

object data type in Oracle 616, 657OLE data type 67, 419OOM

add package hierarchy 429data type 426generate object 425generation options 426–428link 81link Java class 76object 425

openCDM 423database 452PDM 423

operation procedure 230option

configure for generated CDM 421configure for generated OOM 427for reverse engineering 538physical 452, 456, 459script 465, 518

Oracleadd reference to bitmap join index 624bitmap join index 616, 619bitmap join index column 623bitmap join index in table 622bitmap join index properties 622create bitmap join index 621

737

Page 750: Physical Data Model - SAP

Index

database package 625dimensions 637extended attribute 639generate dimensions 637object data type 616, 657rebuild bitmap join index 620reverse engineer tablespace physical options 636sequences 71special variables 616SQLJ object data type 616transparent data encryption (TDE) 637

order trigger 204outside table 457, 458, 460owner 53, 256, 262owner filter during reverse engineering 536

Ppackage (PDM)

add hierarchy 429check model 309code 20comment 20composite view 19define 19display preferences 20hierarchy 19name 20namespace 20property 20shortcut code uniqueness 309sub-package 19

parametergenerate CDM 420generate PDM 414generate test data 482generate XML model 431modify database 516test data source 483, 486, 488

parent table 48, 532change 99

partition 375, 383add 376, 384corresponding table 376, 384delete 376, 384horizontal 373manage 376, 384vertical 380

partition function 575partition scheme 576PBCatCol 364PBCatTbl 364PDM

archive 7business rule 408check model 306create 2, 5database 7DBMS overview 12, 155define environment 154enable transformations 415extended dependencies 187generate 412, 414, 415, 417, 431generate from database 536generation options 414, 415logical 4, 545logical model 413modify 6object 22, 425open in current version 423preserve modifications 423property 6role 2save as 7select extended model definition 185validation 306

PDM objectstranslate to CDM 417translate to OOM 425

permissionall 262alter 262column 267database 262define 262define for user 262define from object property sheet 265delete 262execute 262functions 262grant 262grant with grant option 262index 262insert 262object owner 262

738

Page 751: Physical Data Model - SAP

Index

procedure 262references 262reverse engineer 254revoke 262revoke with cascade 262select 262table 262update 262user 262view 262

physical data type 156physical diagram

abstract data type 76column 33create 24default 58define 22domain 62group 273index 50key 42reference 86role 270sequence 71synonym 276table 26user 255view 101view reference 118web operation 290web parameter 295web service 285

physical optionalternate key 458default 127define 127, 130primary key 457query table 114storage 130tablespace 130

PKCOLN 693PostgreSQL extended attributes 642PowerBuilder

extended attribute 364, 366extended model definition 364generate extended attributes 368PBCatCol 364

PBCatTbl 364reverse extended attributes 369

pragmadatabase package exception 633database package procedure 628

precision 63, 64preference

code 180name 180reference 99, 100, 178table 180

prefix tablespace with database 130, 548preserve

CDM 417database object 156, 414modification 417, 423XML model 431

previewbookmark 15change generation options 15keyboard shortcuts 15predefined set of options 15refresh 15SQL tools 15storage command 470table 15tablespace command 470

primary indexnon-unique 673unique 673

primary index in Teradata 673primary key 22

column 33, 43constraint 47define 42designate 43display 180drop 457, 458generate 456, 457generate index 54index 50, 53, 459join 91name 50physical option 457rebuild 44, 532referential integrity 95variable 47, 692

739

Page 752: Physical Data Model - SAP

Index

privilege 257create in DBMS editor 258define 257define for group 258define for role 258define for user 258generate 261grant 258reverse engineer 254revoke 258with admin option 258

procedureattach to table 230check model 334custom 222database package 329define 222dependency 224display preferences 178edit with SQL editor 238example 203function insert 238generate 247inherit in abstract data type 79insert SQL/XML macro 238macro insert 238OOM operation 230operator insert 238permission 262, 265properties 223SQL/XML wizard 238stored 222trigger template 203variable 704, 707variable insert 238

procedure (database package) 627, 628procedure default owner model option 172procedure dependencies

rebuild 228procedure template 233

create 233identify 235model 235modify DBMS 235modify model 235property 236type 235

user-defined 235propagate column properties model option 166proxy table

create 651define remote server 651extended model definition 649generate script 652Sybase ASA 648Sybase ASE 648

Qqualifier filter during reverse engineering 536query

define 357execute 522performance 372SQL 522

query tabledefine 112index 57materialized view 112physical options 114snapshot 112summary table 112view type 113

queue 596quick launch 449quotation mark to generate 125

RR/R Mapping 415rebuild

bitmap join index 620cube 350database package procedure dependencies 228defaults 60index 54IQ index 657, 658primary key 44, 532procedure dependencies 228reference 97, 532trigger dependencies 228

rebuild automatically triggers model option 164rebuild triggers

create trigger automatically 190delete and rebuild 198delete trigger 198

740

Page 753: Physical Data Model - SAP

Index

insert trigger 198select trigger template 198template item 198, 212trigger template 198, 212update trigger 198user-defined trigger 198

reference 22, 86add to bitmap join index 624add to join index 665auto-migration 88bend 99cardinality 95, 178change table 99check model 324child table 95CODASYL 100column variable 702conceptual 100create 86delete 97display 99, 100display preference 178display preferences 178drag 99generate 97join 178mode 99model options 180modify 99move to table 99name 178notation 100, 180number 48number of children 95permission 262preference 99, 100, 178properties 90rebuild 97, 532relational 100reuse column 88straighten 99text 178variable 48, 701view 106

referential integrity 95, 190cardinality 95cluster 95

delete 95display 178generate 95, 456label 178property 95update 95

relational notation 100relational to multidimensional mapping 357relational to relational mapping 353remote server 651remote service binding 601replication (PDM) 393

check model 341repository in MS SQL Server 560requirements (model option) 160result column

data type 294definition 294is element 294

retrievemultidimensional objects 348WarehouseArchitect object 348

reverse engineer 254Access 97 538administrator permissions 524auto-layout 532block terminator 532constraint business rule 407cubes in MS SQL Server 563database package 636DB2 536for MS Access 97 559from a data source 528from database 524from script files 524from scripts 525generate PDM from database 536Java class 85link Java class 76optimization 539options 532, 538owner filter 536parent tables 532permission 254PowerBuilder extended attributes 369privilege 254public names 369

741

Page 754: Physical Data Model - SAP

Index

qualifier filter 536rebuild primary key 532rebuild reference 532retrieve number of rows in tables 532script 254script files order 524shortcuts 535synonym creation 532synonyms 280system login in Oracle 636table with triggers 536tablespace physical options in Oracle 636terminator 532trigger script files 538user-defined and abstract data types 536variable 704

reverse engineeringencoding 533file encoding 533

reverthorizontal partitioning 378table collapsing 391vertical partitioning 386

revoke 257, 262privilege 258with cascade 262

role 255, 270assign role 271assign to a group 271assign to a user 271check model 313create 270privilege 257properties 270

route 600RULES check parameter 123

Ssave as .apm 7script

alter 514begin 452, 456, 463, 473, 475, 477comment 465, 518create database 446, 472create table 472customize 452, 456, 472, 473, 475, 477database create 452, 473

edit 473, 475, 477end 452, 456, 463, 473, 475, 477extraction 353format 465, 518generate 446, 452, 456, 465, 514, 518identifier delimiter 465model 452, 473modify database 514option 465, 518preview 15table 456, 475text color code 15title 465, 518variable 473, 475

security variables 706segment 468select permission 262sequence 71, 190

check model 342create 71, 456drop 456generate 456Interbase 71properties 73variable 707

sequence default owner model option 169serial data type 65, 417

CDM 71server

business rule (PDM) 401expression 124, 401

SERVEREXPRESSION 693service 600service broker 593service provider in web service import 285settings sets 449shortcuts

code uniqueness 309reverse engineering in PDM 535

sizeBLOB 510database 508

snapshot 113index 57

SOAP 285sort

column 41

742

Page 755: Physical Data Model - SAP

Index

list 41source of test data generation 483, 486, 488special variables in Oracle 616SQL

query 522SQL Server

variable 707SQL tools

editor 13preview 15

SQL/XML query (in PDM) 440SQL/XML wizard 240SQLBase column default 33SQLJ object abstract data type 79SQLJ object data type in Oracle 616SqlListQuery 50SQLXML macro 694statistics 541stereotype DBCreateAfter 115, 247storage

check model 343command 470configure 468create 453define 130, 470drop 453generate 453name uniqueness 343not used 343preview 470select 130

storage group 468stored procedure

create 222extended dependencies 247generation order 247

straighten reference 99sub-package hierarchy (PDM) 19subtype in database package 634summary table 113

index 57Sybase AS Anywhere

events 671Sybase AS IQ

add reference to join index 665create join index 662data movement script 666

define join index 661events 669extended attribute 669features 657generate join index 664index type 660join index in table 661join index properties 661rebuild IQ indexes 657, 658

Sybase ASAauto-increment columns 648define remote server of proxy 651extended attribute 653generate script for proxy tables 652proxy tables 648web services 285

Sybase ASEdefine remote server of proxy 651extended attribute 654generate script for proxy tables 652identity columns 648, 654proxy tables 648web services 285

Sybase IQweb services 285

Sybase SQL Anywhere data type 417symmetric key 585synonym 276, 602

alias 276base object 276check 328code 276code length 328code uniqueness 328create 276, 462create view 279define 276drop 462existence of base object 328filter 462generate 280, 462name 276name length 328name uniqueness 328owner 276properties 278reverse engineer 280, 532

743

Page 756: Physical Data Model - SAP

Index

type 276visibility 276

syntaxobject compatibility 157variable 478, 708

System Administrator 270system login in database reverse for Oracle 636system privilege 257system role 270System Security Officer 270

Ttable 22, 26

alternate key 45attach procedure 230based on 29bitmap join index 622check model 315check parameter 456child 48column 180comment 456constraint 31constraint business rule 409create 26, 456, 472create trigger 191data profile 497, 498display preferences 180drop 456estimate database size 508external 32foreign key 46, 87generate 456index 50, 180indicate record 509join index 661message 250modify trigger 199multidimensional type 348notation 182parent 48permission 262, 265physical option 456, 459preference 180preview code 15primary key 43properties 26

reverse engineer table triggers 536script 456, 475statistics 541text 180validation rule 456variable 47, 48, 697view 106, 183XML type 29

table collapsing 388cancel 391check model 307collapsed tables 390delete 391eliminate joins 388generate PDM 391input tables 389object 389, 390references 389revert 391source tables 390target table 389wizard 389

table default owner model option 164, 170table trigger default owner model option 173tablespace

begin script 477check model 344command 470configure 468create 452database prefix in DB2 OS/390 130, 548define 130, 470drop 452enabledbprefix 548end script 477generate 452name uniqueness 344not used 344preview 470reverse physical options in Oracle 636select 130

TDE 637template item 214

add to trigger template 213create from existing template item 214create new 214declare in trigger 201

744

Page 757: Physical Data Model - SAP

Index

define 190, 214identify 217insert in trigger 200insert in trigger template 200modify DBMS 219properties 220rebuild triggers 212

Teradataextended attributes 674primary index 673primary key 673

terminator 532test data 480

assign data profile 496automatic generation 483, 486, 488automatic generation parameter 483column fill parameter 494data source 482distinct values 34export data profile 500generate 480, 501generate from database 491generate from file 492generate from list 490generate option 501generation parameter 482, 501import data profile 499number of rows 501restriction 481triggers 501use 480

test data profileassign 480class 481create 481default 481define 480name 481

textreference 178table 180view 183

TIME 660time

data profile 483data type 419

time data type 66

title script 465, 518transformation

cancel horizontal partitioning 376cancel table collapsing 391cancel vertical partitioning 383column denormalization 393horizontal partitioning 373table collapsing 388vertical partitioning 380

translatedata type 156, 417PDM to OOM 426

transparent data encryption (TDE) 637trigger

check model 324create 190create automatically 190create manually 190, 191declare template item 201define 190dependency 224edit 199edit with SQL editor 194event 195function insert 194, 199generate 247insert SQL/XML macro 194insert template item 200instead of 105macro 685macro insert 194, 199modify 199modify from table 199multiple 204multiple events 205name convention 202operator insert 194, 199order 204overview 190properties 194referential integrity 190reverse engineer script files 538reverse engineer table with triggers 536same type 204sequence 190SQL/XML wizard 194test data 501

745

Page 758: Physical Data Model - SAP

Index

time 195user-defined 191variable 703, 704variable insert 194, 199view 105

trigger dependenciesrebuild 228

trigger template 206add template item 213copy 207create 207create DBMS 207create from duplicate 207create from scratch 207create user-defined 207DBMS 206, 207declare template item 201define 190delete 210duplicate 207example 203identify 209insert 203, 209insert template item 200macro 685model 209modify DBMS 210modify model 210, 219name 202procedure 203property 211rebuild triggers 212type 209update 210user-defined 209

typebusiness rule 399database package 329

type (database package)definition 634public 634subtype 634

typographic conventions x

Uundefined data type 37unique

code (model option) 166constraint 45index 45, 50, 53primary index 673

UniqueConstName 409update

constraint 95, 218permission 262trigger template 210

update statistics 541user 255

add to group 274assign role 271attach object 256check model 311create 255define 256permission 262privilege 257properties 255role 270vs owner 256

user schema 612user-defined

error message 250generate 251index 50

Vvalidation

business rule (PDM) 400PDM 306

validation rule 122apply 124auto-migrate 87business rule 124check parameter 124column 124, 457define 125domain 124generate 124, 454, 457table 456

variableabstract data type 699abstract data type attribute 699Adaptive Server Anywhere 707all named objects 696

746

Page 759: Physical Data Model - SAP

Index

all objects 696business rule (PDM) 700check 332code 696code uniqueness 332column 124, 688, 698column check parameter 697common 696constraint name 47, 48data type 332database 704database options 706database package 329database synchronization 705domain 124domain (PDM) 699domain check parameter 697foreign key 692format 478, 708generated code 696index 700index column 700join index 707justify 478, 708key 703list 696loop macro 696metadata 706name uniqueness 332primary key 692procedure 707reference 48, 701reference column 702reverse engineer 704script 473, 475security 706sequence 707SQL Server 707syntax 478, 708table 47, 48, 697trigger 703, 704view 703

variable (database package) 630constant 630data type 630default value 630in database package 630

length 630precision 630public 630

version 6 migration 423vertical partitioning 380

cancel 383check model 308column selection 380delete 383generate PDM 384object 383, 384partition definition 380partitioned table 380partitions 383revert 386wizard 380

view 22, 101add column 102check model 326column 102, 103, 183comment 461create 101, 456, 461create from synonym 279data type 183define query 106display columns 102display preferences 182drop 461extended dependencies 114, 115force column list 461formula 183generate 456, 461generation order 115materialized query table 113modify column properties 103multidimensional type 348permission 262, 265properties 101reference 106remove column 102rename columns 102select table 105select view 105snapshot 113summary table 113table 106, 183text 183

747

Page 760: Physical Data Model - SAP

Index

trigger 105type 113variable 703XML type 29

view columndisplay preferences 183

view default owner model option 164, 170view index

check model 321view reference 118

check model 325CODASYL 183conceptual 183create 118display join 183display name 183display preferences 183IDEF1X 183join 119notation 183properties 118relational 183

view trigger default owner model option 173

WWarehouseArchitect retrieve object 348Web operation 22

check 345code maximum length 345code uniqueness 345name uniqueness 345

web operation 290create 290properties 290security properties 293

web parameter 295create 295properties 295

Web service 22check 345code maximum length 345code uniqueness 345in PowerDesigner 285local path 285name uniqueness 345

web service 285create 286

DADX extended model definition 298DADX files 286general definition 284generate web services for IBM DB2 298import as service provider 285prefix name 285properties 287reverse engineer web services 302types 285

with default (column properties) 33WithOption 612WSDL 285

XXML Builder Wizard 434

build XML hierarchy 436define XML model 435select tables and views 435

XML data type 589XML index 588XML indexing 588XML model

generate 431, 432generation options 432modify 431objects translated from PDM 431preserve 431update 431

XML schema collection 589XML table 29XML table column 590XML view 29XPF import 499

748