Thursday, October 21, 2010

Understanding Attributes in E-R Diagrams

An attribute is a property or descriptor of an entity, for example, Customer Name is an attribute of the entity Customer. Each attribute will eventually be represented by one or more entity attributes in the physical database structure.



Attributes Define Entities



Collectively, attributes define an entity. An attribute is meaningless by itself. For example, date of birth comes from the context of the entity to which it is assigned, for example, date of birth of an employee.



Attributes are not shown on the Entity-Relationship Model but are recorded in the underlying data dictionary which contains the definitions of attributes for all entities and relationships identified in the model. An attribute should not have facts recorded about it. In practice, however, there are exceptions. For example, you might wish to show address as an attribute of Customer. Address is not significant enough to be modelled as an entity in its own right and would typically be shown as an attribute of Customer. However, at the detailed level, it may itself have attributes such as an indicator for mailing address or home address.



Attributes do not have to be recognized and defined during the early stages of entity definition. Entity definition is an iterative process, and it is unlikely that a completely satisfactory Entity-Relationship Model will be obtained on the first iteration.



Identifying Attributes



To identify entity attributes, examine:



· all external entities from the Context Diagram,



· the data flows passed by the external entities,



· existing automated data,



· each entity (i.e., generate a list of entity attributes that describe the entity).



Attributes Versus Data Elements



Attributes have a looser description than data elements. For instance, whereas an attribute may have only a descriptive name, a data element needs:



· a size and range,

· a format and length,

· an accurate and detailed description,

· valid values,

· defined edit rules.



Some attributes may be converted into many data elements. For instance, the attribute "address" may become four data elements representing:



· Street Address,

· City/Town,

· State/Province,

· Postal or Zip Code.



Additional data elements may also be defined as a result of customer requirements. For example, the customer may require a list of all companies by county.



For the purposes of Data Modelling, attributes and data elements are often considered identical because attributes in the data model typically become data elements in the database.



CANDIDATE KEYS



Description



A candidate key is a set of one or more attributes which uniquely distinguishes each instance of an entity. For example, a candidate key for Employee may be Employee ID, candidate keys for Budget may be Budget Year, Budget ID, or Effective Date.



Primary Key Identifier



The primary key of an entity unambiguously distinguishes between occurrences of the entity. It is a unique identifier comprised of one or more attributes of the entity. Each occurrence of an entity has one value for its primary key. Select the primary key from the list of candidate keys.



Each entity must be assigned a primary key. An entity can have only one primary key.



Foreign Key Identifier



Foreign keys (also known as referential attributes) are attributes that define relationships between entities. The attributes of a foreign key in one entity are the attributes of a primary key in another entity. For example, Department ID is the primary key of Department and Department ID is a foreign key of Employee defining the relationship "Employee works for Department."



CATEGORIES OF ATTRIBUTES



Attributes fall into three categories depending on the information that the attribute captures:



· Descriptive attributes provide facts intrinsic to each instance of the entity. For example, the Salary of Employee or the Address of Customer.



· Naming attributes provide facts about arbitrary labels and names carried by each instance of an entity. For example, the Employee Name of Employee or the Employee ID of Employee.



· Referential attributes (i.e., foreign keys) provide facts which tie an instance of one entity to an instance of another entity. For example, the Department Number of the Department to which an Employee is assigned ties the Employee to the Department.

ATTRIBUTE DOMAINS



A domain is a set of values for an attribute (i.e., the properties or characteristics of entities). The value set conforms to a common definition for the domain (e.g., type, format, syntax, meaning).



Specify domains in one of the following ways:



· List all possible values (e.g., for an attribute named color, possible values are red, green, blue).



· Identify a source (e.g., procedures manual) that contains the valid values.



· List an acceptable range of values for the domain (e.g., for an attribute named weight, possible values range from one to five pounds).



· Define a business rule that permits determination of the validity of a value assigned to an attribute (e.g., discounts greater than five percent only apply to commercial customers).





DERIVED ATTRIBUTES



Derived attributes are attributes whose values are generated from other attributes using calculations, algorithms or procedures. For example, Account Balance is derived by subtracting Total Debit from Total Credit.



Generally, the specifications for calculating derived attributes are a concern of the processing aspects of the information system (e.g., process model). Derived attributes may be included in the data model if the rules for calculating the attribute values would otherwise be lost.



Clearly indicate in the data model when an attribute is derived. Ensure that the rules needed to derive or calculate the attribute value are captured in the model. Verify that all attributes needed to calculate the derived attribute are present in the data model.



Once the physical data model is constructed, some derived attributes are added to the model to improve performance of the system.

No comments:

Post a Comment