ER/Studio - Embarcadero Technologies Product Documentation

ER/Studio - Embarcadero Technologies Product Documentation ER/Studio - Embarcadero Technologies Product Documentation

docs.embarcadero.com
from docs.embarcadero.com More from this publisher
24.12.2012 Views

USING ER/STUDIO > DEVELOPING THE LOGICAL MODEL • To modify the properties of a foreign key attribute, you must alter the corresponding primary key column in the originating parent table. • To preserve domain consistency, ER/Studio only lets you change the column name of foreign keys. To modify other properties of a foreign key column, you must alter the corresponding primary key column in the originating parent table. Create a Foreign Key/Relationship Foreign keys are created when you establish relationships between entities. The primary key of the parent object becomes the foreign key of the child object. Foreign keys are not displayed in the entity boxes in the Data Model Window when using Filtered IE (No FKs) but are displayed using all other notation types. For more information, see Working with Relationships. Specify FK Attribute Name and Datatype By default, the foreign keys inherit their names from the primary key of the parent object; however, you can choose to provide another name for the foreign key using the Logical Rolename. 1 Double-click the entity you want to change. 2 Click the foreign key in the attributes list and then click Edit. 3 Enter a Logical Rolename and then select Synchronize Column Rolename with Logical Rolename. 4 Click Save. The child now displays the logical rolename of the foreign key. Similarly, you can specify a different datatype for the foreign key. 1 Double-click the entity and from the Entity Editor, select the foreign key from the attributes list and then click Edit. 2 Select Edit Foreign Key Datatype and then make the necessary changes to the datatype. 3 Click Save. Working with Relationships Relationships help enforce business rules and assertions in a data model. Relationships determine how data are related between two entities and/or views. Relationships are implemented as foreign keys in the physical model. The properties of these foreign keys dictate how referential integrity is enforced between tables through constraints and triggers. In addition to standard relationships ER/Studio lets you create recursive relationships, those where an object is related to itself; duplicate relationships, where multiple relationships relate to the same objects; view relationships that relate entities or tables to views, and subtype clusters that associate multiple homogenous entities (subtypes) to a supertype entity. For more information on relationships, see the following topics: • Creating and Editing Relationships • Creating and Editing Recursive Relationships • Creating View Relationships • Creating Subtype Cluster Relationships EMBARCADERO TECHNOLOGIES > ER/STUDIO® 8.0.3 USER GUIDE 130

USING ER/STUDIO > DEVELOPING THE LOGICAL MODEL • Resolving Name Duplication in Parent and Child Entities (Unification) Creating and Editing Relationships 1 On the Data Model Explorer, click the Data Model tab. 2 Click Insert > Relationship and then click the type of relationship you want to insert. 3 On the Data Model Window, click the parent object and then click the child object. • The Duplicate Attribute Editor displays If both the parent and child objects have the same column or attribute names. Here you can resolve these conflicts by assigning rolenames to foreign keys. • The Recursive Relationship editor displays when you create a recursive relationship, which is a non-identifying relationship where the parent and child object are the same. Using this editor you can assign rolenames to any duplicate keys to differentiate the native and foreign key. For more information, see Creating and Editing Recursive Relationships. • The Duplicate Relationship editor displays when you draw a relationship that will result in multiple identifying and/or non-identifying relationships between two entities. Using this editor you can assign rolenames to any overlapping foreign keys; otherwise, ER/Studio unifies any overlapping Foreign Keys. • The Edit Rolenames dialog displays if overlapping foreign keys are detected when you are drawing a relationship. On the Edit RoleNames dialog you can specify rolenames for foreign keys that are inherited more than once. When a primary key is propagated to a child table, the name of the attribute is also propagated to the child table. A rolename lets you rename the attribute of the foreign key to avoid confusion and resolve the relationship conflict. 4 Repeat step 2 and step 3 and until you have created all necessary relationships. 5 To revert to the Selection tool, right-click anywhere on the Data Model Window. 6 On the Data Model Window, double-click the relationship 7 Complete the Relationship Editor and then click OK to exit the editor. The following describe options that require additional explanation. For general information that applies to the Relationship Editor, see Notes. • Parent Key: Lets you select and propagate an Alternate Key (logical model) or a Unique Index (physical model) to a child entity or table. Use this option if you do not want to propagate the primary key. If there are no alternate keys or unique indexes in the parent table the primary key will be used. • Logical Only: Logical model only. If selected, the relationship will not be implemented when generating a physical model, and will be ignored when comparing the logical model with a physical model. • Physical Only: Physical model only. If selected, the relationship will be ignored when comparing the physical model with a logical model. • Do Not Generate: Physical model only. If selected, the foreign key (FK) columns (if any) will be ignored when generating DDL, as in the Compare and Merge Utility. The FK constraint is not generated but the FK column is generated as a native column. To prevent the FK from being generated, edit the FK column in the Table Editor and select the Hide Key Attribute option. Use this option when relational integrity is enforced in the application rather than by an explicit foreign key in the RDBMS. • Not For Replication: If selected, updates to the parent will not be replicated to the child entity. This prevents any foreign key constraints from being applied when updating the child entity. EMBARCADERO TECHNOLOGIES > ER/STUDIO® 8.0.3 USER GUIDE 131

USING <strong>ER</strong>/STUDIO > DEVELOPING THE LOGICAL MODEL<br />

• To modify the properties of a foreign key attribute, you must alter the corresponding primary key column in the<br />

originating parent table.<br />

• To preserve domain consistency, <strong>ER</strong>/<strong>Studio</strong> only lets you change the column name of foreign keys. To modify<br />

other properties of a foreign key column, you must alter the corresponding primary key column in the originating<br />

parent table.<br />

Create a Foreign Key/Relationship<br />

Foreign keys are created when you establish relationships between entities. The primary key of the parent object<br />

becomes the foreign key of the child object. Foreign keys are not displayed in the entity boxes in the Data Model<br />

Window when using Filtered IE (No FKs) but are displayed using all other notation types. For more information, see<br />

Working with Relationships.<br />

Specify FK Attribute Name and Datatype<br />

By default, the foreign keys inherit their names from the primary key of the parent object; however, you can choose to<br />

provide another name for the foreign key using the Logical Rolename.<br />

1 Double-click the entity you want to change.<br />

2 Click the foreign key in the attributes list and then click Edit.<br />

3 Enter a Logical Rolename and then select Synchronize Column Rolename with Logical Rolename.<br />

4 Click Save.<br />

The child now displays the logical rolename of the foreign key.<br />

Similarly, you can specify a different datatype for the foreign key.<br />

1 Double-click the entity and from the Entity Editor, select the foreign key from the attributes list and then click<br />

Edit.<br />

2 Select Edit Foreign Key Datatype and then make the necessary changes to the datatype.<br />

3 Click Save.<br />

Working with Relationships<br />

Relationships help enforce business rules and assertions in a data model. Relationships determine how data are<br />

related between two entities and/or views. Relationships are implemented as foreign keys in the physical model. The<br />

properties of these foreign keys dictate how referential integrity is enforced between tables through constraints and<br />

triggers.<br />

In addition to standard relationships <strong>ER</strong>/<strong>Studio</strong> lets you create recursive relationships, those where an object is related<br />

to itself; duplicate relationships, where multiple relationships relate to the same objects; view relationships that relate<br />

entities or tables to views, and subtype clusters that associate multiple homogenous entities (subtypes) to a supertype<br />

entity.<br />

For more information on relationships, see the following topics:<br />

• Creating and Editing Relationships<br />

• Creating and Editing Recursive Relationships<br />

• Creating View Relationships<br />

• Creating Subtype Cluster Relationships<br />

EMBARCAD<strong>ER</strong>O TECHNOLOGIES > <strong>ER</strong>/STUDIO® 8.0.3 US<strong>ER</strong> GUIDE 130

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!