There are two types of foreign keys in Toad Data Modeler:
- Primary Foreign keys (PFK, graphically marked by blue key).
- Foreign keys (FK, graphically marked by green key).
PFK
As soon as you create an identifying relationship, Toad Data Modeler automatically adds a copy of the primary key of the Parent table to the Child table - Primary Foreign Key (PFK). (The foreign key in Child table is a part of the primary key.)
FK
As soon as you create a non-identifying relationship, Toad Data Modeler automatically adds a copy of the primary key of the Parent table to the Child table - Foreign key (FK). (This foreign key in Child table is not a part of the primary key.)
In other words, foreign keys (PFKs and FKs) are imported from parent entities to child entities automatically when you create relationship. Foreign keys cannot exist without relationships. Therefore, you are not allowed to delete FK or PFK from Child tables either. To delete them, you have to delete appropriate relationship.
In Toad Data Modeler, information on foreign keys can be found in:
- The Attribute Properties dialog | Foreign Keys tab where you can see details on particular FK.
- The Relationship Properties dialog where you set linking method between parent and child entities.
Foreign Keys Mapping
In Toad Data Modeler, you can control your foreign keys. Foreign keys mapping feature allows you to create Compound Keys, use existing keys etc.
Example:
You have reverse engineered a model without relationships. In Toad Data Modeler, a new model has been created. However, information about foreign keys has been lost as in Toad Data Modeler stands that foreign keys cannot exist without relationships. Now you need to create relationships in Toad Data Modeler.
As soon as you create a new relationship, a new foreign key is added to the child entity automatically or existing attribute is mapped to primary key automatically.
In case you need to choose different column for the relationship, edit the relationship and choose the new column on tab General.
Automatic FK Mapping
You can also set Automatic FK Mapping in Settings | Options | Physical Model.
- Disable—FK mapping is OFF
- Enable—Toad Data Modeler searches for matching attributes. If a single option is found, it gets mapped. If multiple options are found, a dialog appears.
- Always Show Dialog—The dialog opens even if only a single option is found.
You can change the attribute name e. g. in the following cases:
- When you create a self-relationship.
- Whenever you want to change a Foreign Key attribute name.
Scenario:
You have just added a self-relationship to the Film entity. |
- A copy of your identifying key attribute has been created in the entity - Film ID. Now you have two Film ID attributes in the Film entity.
- Edit the newly created Film ID attribute, define a new Name . The link to parent attribute is displayed on top right-hand corner of the form.
- Confirm OK and see the change on the Workspace.
Toad Data Modeler allows you to design Entity Relationship Diagrams of specific database platforms, convert physical model from one database platform to another, create an ER Diagram directly from your database (Reverse Engineering feature), update physical models, generate DDL/SQL scripts and Change Scripts, create Dictionary Types, Views, Triggers, Functions, generate detailed documentation to your model (in HTML, RTF, PDF, XSLT formats) and much more.
This chapter describes features and functions related to Physical Data Modeling. Look around each section to get the information you need.
|
Note: See the sample physical model Videorental (Oracle 10g db) that is included in the installation package of Toad Data Modeler. Default location is: C:\Program Files (x86)\Quest Software\Toad Data Modeler7.3\Samples. |
Benefits of Physical Data Model
- Detailed definition of database structure, including database specific items, for example:
- Stored procedures
- Functions
- Triggers
- Views
- Materialized views
- Sequences (auto increments) etc.
- Possibility to synchronize local model with existing database.
- Possibility to specify logical names for objects (captions for tables, attributes and other objects).
- Detailed database specific information can be exported to HTML/RTF/PDF or XML/XHTML/CSV reports.
- Automatic generation of SQL code for selected objects (SQL code generation is not available in Logical and Universal Model)
- Automatic migration of PK attributes to child entities (Attributes don't migrate to child entities in Logical Model)
Toad Data Modeler supports several database systems. As there are differences among databases, there are only applicable to specific databases.
For example:
- Microsoft SQL Server 2000 and higher only support Dictionary Types, which are called User-Defined Data Types in database itself
- PostgreSQL databases do not support Users, only User Groups. Instead of Users, Roles are used for managing permissions.
- and others...
Database platform and version specific information are listed in the respective topics in the Databases chapter.