0802-0804

Previous Table of Contents Next

Page 802

Adding Foreign Keys

When you add a new table to the diagram, it can relate to an existing table. You also might want to add a relationship between two existing tables. To create a foreign key, you need to click one of the foreign key icons ”the Mandatory Foreign Key icon or the Optional Foreign Key icon. After selecting the icon, select the From table and then the To table on the diagram. You are then prompted for the constraint name . The Database Design Wizard uses the following naming convention:

 Alias of From table_Alias of To table_FK 
TIP
To create multiple keys, hold down the Ctrl button while you click the icon. When you are finished creating the keys, select another icon.

As in the entity relationship, there is a multitude of information that can be added to further clarify the foreign key including the error message to be displayed, whether the key is to be implemented in server or client logic or both, and what the restrictions are.

Sometimes, you might want to show an arc across multiple foreign keys. First, select each foreign key in the arc by selecting one and then holding down the Ctrl key while selecting the others. Then, select the table that they arc to. The Create Arc icon becomes active. Click the Create Arc icon, and the arc appears. To remove a foreign key from an arc, click the arc and hold down the Ctrl key while selecting the foreign keys to remove. The Remove from Arc icon becomes active. Click the Remove from Arc icon, and the foreign keys are removed from the arc. If you want to add a foreign key to the arc, click the foreign key to add. The Add to Arc icon becomes active. Click the Add to Arc icon, and the foreign key is added to the arc. You select whether at least one of the relationships in the arc must exist by the Arc Mandatory checkbox.

Creating Primary Keys

You can create a primary key on the diagram rather than through the Constraints tab on a table or view. Select the first item in the primary key. Hold down the Ctrl key and select any other items in the key. Click the primary key.

NOTE
You can create unique and check constraints from the Constraints tab as well.

Page 803

Saving the Diagram

To save the diagram, click the Save icon. You can name your diagram anything you like; it probably makes sense to name it something related to the top menu level.

Multiple Diagrams

Using multiple diagrams works the same way here. Use Edit Consolidate from the menu bar. At this point, you can choose whether to consolidate a specific table, foreign key, or the entire diagram.

If foreign keys have been added to tables that are on your diagram, you can add them to your diagram by choosing Edit Include Relationship. All the relationships missing from your diagram appear on a list, and you can select the ones you want to add to your diagram.

As a last enhancement, use the same methods to add colors, change fonts, or vary line widths so that your diagrams are more easily readable or follow any color patterning you've established.

You can also change the preferences for specific types of items. By choosing Edit Preferences, you can set all tables to be one color, all views to be another color, and all snapshots to be yet another color.

Generate the Tables Again

If you are not satisfied with the generation of any tables or there are new entities you want to generate as tables, you can do so from the diagrammer. Click the Database Design Wizard icon to regenerate or generate any tables from entities. For more information on the Database Design Wizard, see the "Database Design Wizard" section earlier in this chapter.

Retrofit

If you have made changes to a table that you want to see reflected in the entity the table was generated from, click the Table Entity Retrofit icon. You can choose what tables to retrofit, what entity they return to, and what columns and constraints should be passed back.

Generating DDL

Once you are satisfied with what you have created in the Data Diagrammer, you can generate the DDL for creating the tables, views, snapshots, and constraints on your database. Make sure you save the diagram before generating. Click the Generate DDL. Select what tables, views, snapshots, and constraints you want to generate. The scripts to create the items are created at this point. The scripts receive the following names :

  • XXX.TAB creates table code.
  • XXX.VW creates view code.
  • XXX.SS creates snapshot code.

Page 804

  • XXX.CON creates constraints code.
  • XXX.IND creates index code.

The XXX is defined from the Options tab of the Generate DDL screen. Here you can specify the database, version, and file prefix. The default path for the storage of these scripts is the Orawin/Bin directory. The XXX.sql script calls the other scripts in the correct order. You can examine the scripts and run them right from the generator. The DDL Generator also generates DBA information such as triggers, tablespaces, clusters, and so on.

The Application Design Wizard

You use the Application Design Wizard to generate modules and menus from functions. Before running the tool, you should make sure that your functions are properly defined. To check them, run the Matrix Diagrammer to ensure the functions are covering all the CRUD for the entities to be generated. For more information on running these reports , see Chapter 31. Finally, the Database Design Wizard should have already generated the table definitions so that the table usage is recognized by the Application Design Wizard.

Starting the Application Design Wizard

You can invoke the Application Design Wizard from either the Repository Object Navigator, the Function Hierarchy Diagrammer, or the Dataflow Diagrammer. Select Utilities Database Design Wizard.

The Application Design Wizard selection screen appears. (See Figure 32.13.) You can select the start function level, the module prefix, the language options, the merge granularity, and whether to generate modules or menus.

Figure 32.13.
TheApplication Design
Wizard.


Previous Table of Contents Next


Oracle Unleashed
Oracle Development Unleashed (3rd Edition)
ISBN: 0672315750
EAN: 2147483647
Year: 1997
Pages: 391

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net