0
39kviews
What is an attribute? Discuss various types of attributes with examples.
1 Answer
5
1.3kviews

Attributes are properties which describes each member of an entity set.

For example, an EMPLOYEE entity may be described by the employee’s name, age, address, salary, and job.

A particular entity will have a value for each of its attributes and hence forms major part of data stored in database.

enter image description here

Various types of attributes occur in the ER model:

  1. Simple and Composite
  2. Single-valued and Multivalued
  3. Derived attributes
  4. Null attributes
  5. Complex attributes

Simple and Composite attributes

  • Attributes that are not further divisible into sub-attributes (atomic) are known as Simple attributes. Composite attributes, on the other hand, can be divided into sub-attributes which represent more basic attributes with independent meanings.
  • For example, the Address attribute of the EMPLOYEE entity shown can be subdivided into Street_address, City, State, and Pincode.
  • Composite attributes are useful to model situations in which a user sometimes refers to the composite attribute as a unit but at other times refers to its components.
  • If the composite attribute is referenced only as a whole, there is no need to subdivide it into component attributes. For example, if there is no need to refer to the individual components of an address (Zip Code, street, and so on), then the whole address can be designated as a simple attribute.
  • Composite attributes can form hierarchy as shown in the figure below.

enter image description here

Single-valued and Multivalued

  • Attributes having single value for a particular entity is known as single-valued attribute. For example, age of person is single valued.
  • There are many instances where attribute has set of values for a specific entity, known as Multivalued attributes. For example, Phone number. A person may have zero, one or more phone numbers, and different employees may have different numbers of phones.
  • Multivalued attribute is modeled in ER using double circle as shown below –

enter image description here

Derived attributes

  • The value for this type of attribute can be derived from the values of other related attributes or entities. For example, suppose that the customer entity set has an attribute age, which indicates the customer’s age. If the customer entity set also has an attribute date-of-birth, we can calculate age from date-of-birth and the current date. Thus, age is a derived attribute.
  • However derived attribute needs to be computed every time when it’s required, which is not the case if it’s a stored attribute. So there is a tradeoff between space needed to store and computing power needed to compute attribute.

Null attributes

  • In some cases, a particular entity may not have an applicable value for an attribute. For example, Apartment_number attribute of address field applies to address in apartment buildings only and not to other address like row houses. Hence, an address of a row house would have NULL for its Apartment_number attribute.

Complex attributes

  • Complex attributes are formed by nesting composite and multivalued attributes arbitrarily.
  • This nesting can be represented by grouping composite attribute between parentheses () and separating the components with commas, and by displaying multivalued attributes between braces { }.
  • For example, a person can have more than one residence and each residence can have a single address and multiple phones, an attribute Address_phone for a person can be specified as shown below - {Address_phone( {Phone(Area_code,Phone_number)},Address(Street_address (Number,Street,Apartment_number),City,State,Zip) )}
Please log in to add an answer.