Reusing Attribute Definitions Using Domains
Go Up to Working with the Data Dictionary
Domains are very useful for creating entity attributes or table columns commonly used in your models. Creating a domain allows you to define the object once and then use it repeatedly by applying the domain to the entity attributes and table columns.
Domains are reusable attribute templates that promote consistent domain definitions. You construct domains as you would attributes, specifying a name, datatype properties, null status, default values and validation rules. After creating domains, you can re-use them in your data model by applying them to attributes and table columns. By defining a domain, you also gain the power of propagating changes to the underlying domain definition to all attributes and table columns that reference it.
One important method for enforcing business rules is to define and to apply domain restrictions. Domain integrity refers to the rules governing what values an attribute can take. By restricting and validating an attribute's values, you can implement important business rules such as ensuring that a checking account maintains a positive balance, or preventing the entry of invalid phone numbers.
ER/Studio Data Architect lets you organize your domains using domain folders. Domain folders let you create and manage your Data Dictionary Domains. You can classify domains in unique groups by creating different domain folders. You can create nodes within nodes. You can move existing domains into a domain folder, or create new domains within the folder.
Domains can be dragged and dropped into a table or entity to create a column or attribute. Domains can also be dragged onto another domain to create a subdomain, by moving the selected domain beneath the target domain. Domains can also be copied and pasted onto another domain to create a copy of the selected domain as a subdomain or the target domain. Note, changes to the copied domain will not be inherited by the pasted subdomain.
Domains can have nested subdomains or child domains that initially duplicate most of the attributes of the parent domain, but can have divergent behaviors once created. A Domain Override option in the Add Domain or Edit Domain functions creates inheritance and overrides the domain system without losing the valuable relationship with the attributes/columns (binding information).
- When you delete a domain folder, all domains and folders within that folder are also deleted. All bindings to any columns and attributes are unbound.
Create a Domain Folder
- On the Data Dictionary tab, right-click the Domains node and then click New Domain Folder.
- Enter a name for the domain and then click OK.
Create and Edit a Domain or Subdomain
To create a domain at the root of the Domains node, on the Data Dictionary tab, right-click the Domains node and then click New Domain.
To create a domain within a domain folde r, on the Data Dictionary tab, expand the Domains node, right-click the node of a domain folder, and then click New Domain.
To create a subdomain (a domain within a domain folder), on the Data Dictionary tab, navigate to the domain folder where you want to create the subdomain, right-click the domain folder, and then click New Domain.
- Define the domain as required and then click OK to complete the editor.
- Once created, you can edit the domain by double-clicking its object on the Data Dictionary tab to launch the editor.
The following helps you complete the Domain Editor options:
- Receive Parent Modifications: For subdomains, lets you synchronize changes made to the attributes of a parent domain with a those of the child domain. Selecting this option automatically synchronizes parent and child attributes, except those specified on the Reference Values, Naming Standards, Attachment Binding, and Binding Information tabs. Not selecting this option creates a child domain that is initially identical to the parent domain, except that the child domain is created without any attachment bindings. Subsequent changes to the parent domain will not be inherited by the subdomain. Any changes you make to the subdomain will override the values inherited from the parent domain. Henceforth, the child can only inherit attributes from the parent if these attributes were not previously specified for the child.
- Synchronize Domain and Attribute/Column Names: Select this option to synchronize the Domain, Attribute, and Column Names. If you entered names in the Attribute and/or Column Name fields that are different than the Domain name, selecting this option overrides your entries.
- Apply nullability to all bound columns? This option becomes available when you select a datatype that can have nulls but you choose to disallow nulls by clicking No in the Allow Nulls area. Selecting this check box does not impact if there are no bound columns.
- Identity Property area: This area becomes available if the Identity Property is supported by the database platform of a model in the diagram, and the datatype selected, such as TINYINIT, supports this property.
- Default Binding: If a default value has not already been bound to the domain (Data Dictionary > Defaults > Edit Default Definition > Binding Information), you can enter a Declarative Default value or choose another Default from the Default Binding list. The declarative default will appear in the SQL produced when you select Generate Database from the physical model.
- Declarative Default: Specifies the default domain value when a value is not explicitly specified during an insert. DEFAULT definitions can be applied to any columns except those defined as timestamp, or those with the IDENTITY property. Only a constant value, such as a character string; a system function, such as SYSTEM_USER(); a NULL; or a constraint name can be assigned to a DEFAULT.
Add, modify, or delete a constraint. Check constraints are used to ensure the validity of data in a database and to provide data integrity. For more information, see Enforcing Data Integrity Using Check Constraints.
Reference Values tab
Reference Values are attributes that define allowed data. They represent look-up table columns or code-value ranges or a rule or constraint applied to columns. For more information, see Defining Valid Attribute Data Using Reference Values.
Naming Standards tab
Controls user and object permissions to modify the affected item. When a Naming Standards Template is bound to an object, then that template is used instead of the Naming Standards Template selected in the Naming Standards Utility or the Generate Physical Model utility. This allows you to apply different naming standards to different objects when portions of a model require different versions of a standard. For example, some objects already exist in the database and you do not want to apply a newer naming standard to them. For more information, see Enforcing Naming Standards Using Naming Standards Templates.
Enter or edit a definition for the domain. If the target database supports it, ER/Studio Data Architect adds this definition as a domain comment when generating SQL code.
The notes added here are included as part of the HTML report when you generate a report for the model. You can format the notes using standard HTML tags.
Override Controls tab
Controls what can or cannot be overridden on columns bound to this domain.
- General Overrides area: The allow/disallow options disable the "override" indicator on the bound attributes/columns if set to Disallow. When you modify the domain override controls and set one or more of the general override options to Disallow, ER/Studio Data Architect (and the RepoServer for Enterprise Data Dictionaries) removes all existing overrides for that particular property.
- Name Synchronization:
- Never Sync: Completely detaches the domain name from the bound attributes/columns. This avoids inadvertent changes when the attribute or column names are bound to the same domain, and attribute/column name in the domain editor is changed. Changes to the names in the domain do not affect the names of attributes/columns that are bound to the domain.
- Partial Sync: Changes to the attribute/column name in the domain editor will update the name of any bound attributes or columns that have the old name, i.e. where the name has not been overridden. For example, if you create two entities with an attribute from the domain, one with the default name and one with an overridden attribute name, then modify the attribute name in the Domain editor and have selected Partial Sync, then the domain change will modify the attribute name in the entity where the name has not been overridden, but will not change the attribute name in the entity where the name has been overridden. If the names do not match then the changes are not propagated.
- Attachment Synchronization: Keeps attachments in the domain in sync with the bound column. Any attachments added to a domain will propagate to the attributes/columns. Always Migrate always migrates new attachments on the domain to the columns. You can still add other attachments directly to the columns.
Attachment Bindings tab
Bind an external piece of information, or attachment to the domain. You can also remove an attachment from an object, override an attachment binding's default value, or change the position of a bound attachment. To override the value of the attachment you have moved to the Selected Attachments grid, double-click the Value field of the target attachment. ER/Studio Data Architect opens the Value Override Editor or a list depending on the attachment datatype. Attachments are created in the Attachments folder of the Data Dictionary and must be applied to the domain before they will display on this tab. For more information, see Attaching External Documents to the Data Model.
Binding Information tab
Select the object classes and/or specific objects to which you want to bind this attachment. You can override this setting using the Attribute or Column tab of the entity or table editor, respectively.