Open In App

Attributes in DBMS

Last Updated : 04 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Attributes are properties or characteristics of an entity. Attributes are used to describe the entity. The attribute is nothing but a piece of data that gives more information about the entity. Attributes are used to distinguish one entity from the other entity. Attributes help to categorize the entity and the entity can be easily retrieved and manipulate the entity. Attributes can help the database to be more structural and hierarchical. An entity with no attribute is of no use in the database.

Example

  • Let’s take the student as an entity. Students will have multiple attributes such as roll number, name, and class.
  • These attributes are used to describe the student in more detail.

Screenshot-2024-03-23-232743

  • As shown in the figure, roll_no, name, and class are the attributes of the entity Student.
  • All three attributes give meaning to the entity. The information about the student entity lies in all 3 attributes.

Types Of Attribute

There are 8 types of attributes in DBMS.

  • Simple Attribute.
  • Composite Attribute.
  • Single Valued Attribute.
  • Multivalued Attribute.
  • Key Attribute.
  • Derived Attribute.
  • Stored Attribute.
  • Complex Attribute.

Let’s look at all attributes one by one.

Simple Attribute

  • Simple attributes are those attributes that cannot be divided into more attributes. Simple attributes state the simple information about the entity such as name, roll_no, class, age, etc.
  • Simple attributes are widely used for storing information about the entity.

Example

  • Here in the below example, Student has roll_no, class, and name as attributes that cannot be divided into more sub-attributes.
  • These types of attributes are called simple attributes.
  • Simple attributes are mainly used to create all other types of attributes.
Simple Attribute

Simple Attribute

Composite Attribute

  • When 2 or more than 2 simple attributes are combined to make an attribute then that attribute is called a Composite attribute.
  • The composite attribute is made up of multiple attributes. After combining these attributes, the composed attributes are formed.
  • Complex attributes are used where data is complex and needs to be stored in a complex structure.

Example

  • Here if we look at the below example, address is the attribute derived from the 3 simple attributes i.e. City, State, and Street.
  • To get the value of the address attribute, we have first to know those city, state, and street attributes.
  • This type of attribute is known as a composite attribute.
Composite Attribute

Composite Attribute

Single Valued Attribute

  • The attribute with only a single value is known as a single-valued attribute. These attributes have a single value for each instance of a given entity.
  • Mostly these attributes are used to provide the unique identity to the multiple instances of attributes.

Example

  • In the given example, we know that the DOB attribute will have only one value. So we can say that the DOB attribute is nothing but a single Valed attribute and it cannot have multiple attributes.
  • Here roll_no and name will also have mostly one value only.
  • We can say that all 3 attributes of the student are single-valued.
Single Value Attribute

Single valued attribute

Multivalued Attribute

  • An attribute which can have multiple values is known as a multivalued attribute. Multivalued attributes have multiple values for the single instance of an entity.
  • Keu of entity is associated with multiple values. It does not have only one value. It is the opposite of the single-valued attribute.

Example

  • Here the student has an attribute named phone_no. One student can have multiple phone_no, so we can say that phone_no can have multiple values.
  • These types of attributes are known as multi-valued attributes.
  • Multi-valued attributes are used when more than 1 entries for one attribute need to be stored in the Database.
Multi value Attribute

Multi-valued attribute

Key Attribute

  • The attribute which has unique values for every row in the table is known as a Key Attribute. The key attribute has a very crucial role in the database.
  • The key attribute is a distinct and unique characteristic of the entity that can be used to identify the entity uniquely.

Example

  • For students, we can identify every student with roll_no because each student will have a unique roll_no.
  • This indicates that roll_no will be a Key attribute for the Student entity.
  • All operations on the database can be performed only using Key Attributes.
Key Attributes

Key attribute

Derived Attribute

  • The attribute that can be derived from the other attributes and does not require to be already present in the database is called a Derived Attribute.
  • Derived attributes are not stored in the Database directly. It is calculated by using the stored attributes in the database.

Example

  • Here the student has multiple attributes including DOB and age. It is observed that age can be calculated with the help of the DOB attribute.
  • So age is a derived attribute that is derived from an attribute named DOB.
Derived Attributes

Derived attribute

Stored Attribute

  • If the data of the attribute remains constant for every instance of entity then it is called a Stored Attribute.
  • The value of the attribute present in the database does not get updated and it remains constant once it is stored.
  • These attributes are used to store permanent information about an entity which will remain constant throughout the lifetime of the entity.

Example

  • The student has 3 attributes as shown above. Her name and DOB will remain the same throughout his/her education. So the student has a fixed value attribute that will never change in the future.
  • These attributes are known as stored attributes.
Stored Attributes

Stored attributes

Complex Attribute

  • When multi-valued and composite attributes together form an attribute then it is called a Complex attribute.
  • Complex attributes can have an unlimited number of sub-attributes.

Example

  • Here for the student, we created an attribute named contact_info which further decomposed into phone_no + Address.
  • The address is a composite attribute which is further divided into simple attributes and phone_no is a multivalued attribute.
  • This indicates that the contact_info attribute is made from the multi-valued and composite attribute.
  • This type of attribute is known as the Complex Attribute.
Complex Attributes

Complex attributes

Frequently Asked Questons on Attributes in DBMS – FAQs

Why attributes are used?

Attributes are used to get more information about the entity which will help to store the data in a specific format. Attributes are essential parts of the entity as all entity-related data is stored in the form of attributes only.

Are columns called as attributes?

Yes, columns are nothing but the attributes and rows will be named as tuples. So for the student entity, the columns will have the attributes and each student entry will be called a tuple.

How many key attributes can an entity have?

An entity can have multiple key attributes but only one key item will be defined as a primary key attribute and the other key attribute will remain as a secondary key attribute.

Can an entity have zero attributes?

Yes, the entity can have zero attributes but that entity will not carry any information with us resulting in no use of the entity.

What are non-key attributes?

Attributes which does not identify as key attributes are known as non-key attributes. If any attributes do not have unique values across all tuples then it is identified as the non-key attributes.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads