What is an attribute?

Suppose we have a classroom. In this classroom, we have many students then how do we differentiate one student from another? It is the property of each student that helps us in doing so. A student can have many properties like his name, age, height, class, roll no, etc. which will help in identifying each student distinctly. What is this property called? Any guesses? Yes, we are talking about attributes. As we have read about the other two components of the E-R model i.e Entity and Relationship, now we will study about the third component i.e. attribute in detail. So, let's get started.

Attribute

A real-world property of an entity type is called an attribute. This is the characteristics of an entity. It is represented by an oval or ellipse in E-R diagram. Each attribute can take only a set of permitted values. This is called the domain of that attribute. For example, we define the roll_no of the ‘Student’ by a numeric value. So, the permitted values are only integers and hence, ‘integer’ is the domain of attribute ‘roll_no’. Each attribute is represented by a separate column in a relational table.

For example, The entity ‘Student’ has properties like Name, Address, Roll_no, Mobile_no, Age, DOB, Class, Section, etc. So, when we make an E-R diagram then Name, Address, Roll_no, Mobile_no, Age, DOB, Section and Class are represented as the attributes of the entity type ‘Student’.

In the above example, we see that we have used various modified oval symbols to represent the E-R diagram. Various symbols represent various types of the attribute. The text of one attribute(Roll_no) is underlined, the other attribute(Email) is written in double oval, etc. We will understand all this as we go through this blog and learn about various types of attributes and how they are represented in the E-R diagram.

There are are many types of attributes which are as follows:

  • Simple Attribute & Composite Attribute
  • Single Valued Attribute & Multi-valued Attribute
  • Stored Attribute & Derived Attribute
  • Key Attribute & Non-key Attribute

Simple Attribute & Composite Attribute

This division is made on the basis that if the attribute can be further divided or not into more attributes. If it cannot be further divided it is a simple attribute and if can be further divided it is a composite attribute.

Simple Attribute

A simple attribute contains an atomic value which cannot be further divided. It is simply represented by an oval. A simple attribute is directly connected to the entity type. While making the E-R diagram, we directly connect the oval with the rectangle.

For example, Roll_no of Student, Age of Student. It is represented in the E-R diagram as:

Composite Attribute

A Composite attribute can be further divided into other attributes. We represent this in E-R diagram by connecting an oval with oval i.e the composite attribute is also represented by oval and the further divided attribute all also represented by ovals. When we convert this E-R diagram to the relational table then we don't have any column of the composite attribute. We have column only for the attribute which came after we further divided the composite attribute.

For example, Name of a student can be further divided into first name, middle name and last name. The composite attribute name is also represented by oval as well as the other attributes are also represented by oval and we connect the all the further divided attributes with the composite attribute. In the table, we will have three columns i.e. First_name, Middle_name, and Last_name. There is no such column called "Name".

Single Valued Attribute & Multi-valued Attribute

This division is made on the basis of how many values can be taken by the attribute. If the attribute can take more than one value, it is a multi-valued attribute. If the attribute takes only one value it is a single-valued attribute.

Single-valued Attribute

This attribute has only one value. It is represented by a simple oval. Some simple attribute can also be a single-valued attribute. For example, the Section of ‘Student’ is a simple attribute as it can’t be further divided. Also, it is a single-valued attribute because a student can't study in more than one section.

For example, Section of a Student.

Multivalued Attribute

This attribute has more than one value. It is represented by a double oval. Some Composite keys can also be a multivalued attribute. For example, the address attribute of a student can further be divided into ‘Locality’, ‘Town’ and ‘PIN’. So, we call it a composite attribute. Also, the address of a student can have more than one value. A Student can have more than one Address i.e Permanent Address and Temporary Address. So, it can also be called a multivalued attribute.

For example, A student can have more than one e-mail address.

Stored Attribute & Derived Attribute

This classification is made on the basis that if the attribute is just stored in the database or can be derived from some other attribute.

Stored Attribute

The value of this attribute should be provided by the user. This attribute is stored and can be used for finding the value of other attributes. It cannot be derived from any other attribute. It is also represented by an oval. For Example, The Date of Birth of ‘Student’ has to be provided by the student.

Example: Date of Birth(DOB) of Student.

Derived Attribute

The value of this attribute is derived from some other attributes. We know the value of some other attribute(stored attribute)and from stored attribute, we are deriving the value of this attribute(derived attribute). This is done mainly because the value for such attribute keeps on changing. It is represented by a dashed oval.

For example, The value of age attribute is derived from the DOB(date of birth) attribute.

Key Attribute & Non-key Attribute

This classification is made on the basis that if the attribute can uniquely identify the entities or not. As the name suggests key attribute will uniquely identify the entities whereas the non-key attributes would not be able to uniquely identify the entities.

Key Attribute

A key attribute is used to uniquely identify the entities of an entity type. In a relational table, it represents the primary key of the table. It is represented by oval and the text in it is underlined. Even if all the other attributes of an entity are the same but the key attribute will always be different.

Example: We have Roll_no as the key attribute of the ‘Student’ because two students can never has same roll number.

Non-Key Attribute

All the other attributes other than the key attribute are the non-key attributes. Two or more entities can have the same value for this attribute. For example, the Class attribute would have the same value for all those students who are studying in the same class.

Example: Class, Section, Age, Name etc, are the non-key attributes.

Note: The same attribute can be of more than one kind. For Example, The Address attribute is a composite attribute, multivalued attribute, stored attribute and a non-key attribute.

This is all about attributes. Hope you learned something new today.

Do share this blog with your friends to spread the knowledge. Visit our YouTube channel for more content. You can read more blogs from here.

Keep Learning :)

Team AfterAcademy!