Open In App

Difference Between Stored and Derived Attribute

Last Updated : 13 Sep, 2024
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

While using databases, there is always a clear difference between stored and derived attributes, and this makes the work of managing the data easier. Stored attributes are attributes whose values are stored within the database while derived attributes use values that are stored in the database to arrive at their values. This article will, therefore, examine various attributes of the two categories to enable you to grasp the right method to use at the right time.

Stored Attribute

The stored attribute is an attribute that is physically stored in the database. Assume a table called a student. There are attributes such as student_id, name, roll_no, and course_Id. We cannot derive the value of these attributes using other attributes. So, these attributes are called stored attributes.

Advantages of Stored Attributes

  • Fast Retrieval: This is because stored attributes are stored in the database and they do not need any process to be made for retrieving them.
  • Persistence: However, on its own accord, the value stays the same, but can be altered as needed.
  • Simple Queries: In the case of the stored attributes, it is rather easy to query since no computation is required.

Disadvantages of Stored Attributes

  • Redundancy: Storing information this way makes sense if the information cannot be deduced from other data, themselves.
  • Increased Storage: Storing more attributes consumes more space, especially where the scale of the database is large it becomes rather inefficient.

Derived Attribute

A derived attribute is an attribute whose values are calculated from other attributes. In a student table if we have an attribute called date_of_birth and age. We can derive the value of age with the help of the date_of_birth attribute.

Advantages of Derived Attributes

  • No Redundancy: The major advantage of derived attributes is that since they are computed and not stored there is no redundancy of data.
  • Space Efficient: Based on this, derived attributes are advantageous since they do not require storage space within the database.

Disadvantages of Derived Attributes

  • Slower Retrieval: Since derived attributes consist of computation, they pose a potentiality to slow down the query time.
  • Complex Queries: Some queries can involve derived attributes making it somewhat harder as compared to the first group.

Difference Between Stored and Derived Attributes

Stored Attribute Derived Attribute
For a stored attribute it is mandatory to be stored in the database.For a derived attribute it is not mandatory to be stored in the database.
It is not possible to determine the value of a stored attribute.It is possible to determine the value of a derived attribute with the help of another attribute.
It is an attribute that cannot be derived from any other attribute.It is an attribute that can be derived from any other attribute.
Stored attribute will be fixed.Derived attribute will be variable in nature.
Stored attribute is represented by an oval. Derived attribute are represented by a dotted oval.
Stored attribute saves the CPU's processing cycle.Derived attribute if not stored in Relational table, then save storage space.
Stored attribute save data access time.Derived attribute if it is not stored in the Relational table, then the data access time is longer.
Stored attribute requires constant maintenance to ensure that the derived value is current.Derived attribute if it is not stored in the Relational table, does not require maintenance, since it is derived from the stored attribute.
Stored attribute does not add coding complexity to queries.Derived attribute if not stored in the Relational table, adds coding complexity to queries.
Stored attribute data value is readily available.Derived attribute if not stored in the Relational table, data value is not readily available.

Conclusion

With the help of the article, one can learn about the distinction between stored and derived characteristics and the necessity to apply it while designing the databases. However, stored attributes are easily accessible and also easy to retrieve while derived attributes are space efficient and eliminates the need to repeat data storage. Which of them has to be used, primarily depends on the particular requirements of the given application in terms of storage and performance.


Next Article

Similar Reads