Open In App

Derived Attribute in DBMS

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

An entity is nothing but a piece of data that can be uniquely identified in the database. For example, in a university database, a student is an entity. The teacher is also an entity as it can be uniquely identified.

Attributes

  • Attributes are the properties of the entity. Attributes are used to give more details about the entity.
  • Characteristics of an entity are stored in the attributes only. Most of the time, attributes are used to identify the instances of the attributes.
  • An entity with zero attributes is of no use in the database.

Example

Let’s take a student entity. Students will have attributes such as roll number, name, class, etc.

So this can be represented as below.

Attribute

  • The entity is denoted in the rectangular box whereas attributes are shown with the help of an ellipse.
  • In the above example, all attributes are placed in ellipse whereas the student entity is shown with a rectangular shape.
  • There are many types of attributes present in DBMS. We will study here about Derived attributes only.

What is Derived Attribute?

Derived attributes are the attributes that can be derived from the other attribute. These attributes are not present in the database physically but they can be derived from the other attributes easily. Derived attributes are calculated on runtime, so it can be also said that their values vary in nature.

Example

  • Let’s take an example of a student entity only. Let’s assume it has attributes such as roll number, name, and DOB as shown in the figure.
  • If we take another attribute which is age, we can derive it from the DOB attribute. age need not be present in the database. Derived attributes are represented with the dotted ellipse as shown in the figure.
Derived Attribute

Derived attribute

Let us understand it with values.

  • We will take a student Table where we will have 3 attributes that are roll_no, name, and DOB.
  • roll_no is used to identify every instance of the given student entity.
  • Here we need another attribute which is age. But age is a derived attribute that can be derived from the DOB attribute in the given student table.

Table Student

roll_no

name

DOB

1

kartik

01.01.2003

2

yash

01.01.2004

3

aditya

12.12.2003

  • So using the DOB attributes we can derive the age attribute easily. For example,
  1. For roll_no 1, age = 21 years (age on the day 01.01.2024)
  2. For roll_no 2, age = 20 years (age on the day 01.01.2024)
  3. For roll_no 3, age = 20 years and 20 days (age on the day 01.01.2024)
  • Here we did not require the physical presence of the age attribute in the database but we easily derived it from the DOB attribute.
  • So whenever we require the age of the student, we will calculate the age from the DOB while running the query.
  • This will not require any extra memory to store the age attributes in the system.
  • These is called Derived Attributes.

More examples of derived attributes

  • The percentage can be derived from the obtained marks.
  • The city can be derived from the pin code.
  • The due date can be derived from the borrowed date.
  • Profit can be derived from the total cost and total revenue.

and many more.

Features of Derived Attribute

  • They are not physically stored, they are calculated using the other attribute resulting in no cost for storage.
  • They depend on the other attributes in the database.
  • They vary according to changes in the attributes they depend on. So no need to make explicit changes in derived attributes.

Disadvantages of Derived Attribute

  • Calculation gets increased every time we have to perform a set of calculations to get the values of the derived attribute
  • Increase in the time for performing the simple actions as calculations are needed.
  • The complexity of query language gets increased for the simple implementation with the derived attribute as we have to calculate the derived attribute every time.

Frequently Asked Questions on Derived Attribute – FAQs

Which Symbol is used to denote the derived attributes?

The dashed ellipse shape is used to denote the derived attribute.

Where are the derived attributes stored?

Derived attributes are not stored physically. They are calculated on the go i.e. whenever required.

What is the difference between a stored attribute and a derived attribute?

Stored attributes are stored physically in databases but derived attributes are not stored in the attribute.

Which are different types of attributes?

There are various attributes such as simple attributes, Composite attributes, Single-valued attributes, Multi-valued attributes, key attributes, Stored attributes, and Complex attributes.

Are values of the derived attribute fixed?

No values of the derived are not fixed. Derived attributes depend on the other attributes. If the attribute’s value changes, then the attributes depending upon them also change. So derived attributes are not fixed, they depend on the other attributes and their values.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads