0
0
DbmsConceptBeginner · 3 min read

Derived Attribute in DBMS: Definition and Examples

A derived attribute in a database is an attribute whose value is calculated from other stored attributes. It is not stored directly but computed when needed, like calculating age from a birthdate.
⚙️

How It Works

A derived attribute is like a shortcut or a result you get by using other information you already have. Imagine you have a person's birthdate stored in a database. Instead of storing their age, which changes every year, you calculate it when you need it by subtracting the birth year from the current year.

This saves space and keeps data consistent because you don't have to update the age every day. The system derives the value on the fly using a formula or rule based on other attributes.

💻

Example

This example shows how to define a derived attribute Age from the stored attribute BirthDate in SQL.

sql
CREATE TABLE Person (
  PersonID INT PRIMARY KEY,
  Name VARCHAR(100),
  BirthDate DATE
);

-- Query to get Age as a derived attribute
SELECT Name, BirthDate, 
       FLOOR(DATEDIFF(CURDATE(), BirthDate) / 365.25) AS Age
FROM Person;
Output
Name | BirthDate | Age --------|------------|---- Alice | 1990-05-15 | 33 Bob | 1985-10-30 | 37
🎯

When to Use

Use derived attributes when you want to avoid storing data that can be calculated from other data. This helps keep your database clean and reduces errors from outdated values.

Common real-life uses include calculating age from birthdate, total price from quantity and unit price, or full name from first and last names. Derived attributes are useful in reports and queries where you need up-to-date calculated values without extra storage.

Key Points

  • A derived attribute is not stored but calculated from other attributes.
  • It helps keep data consistent and reduces storage needs.
  • Common examples include age, total cost, and full name.
  • Derived attributes are useful in queries and reports for real-time calculations.

Key Takeaways

Derived attributes are calculated from other stored attributes, not saved directly.
They keep data consistent by avoiding redundant storage of changeable values.
Use derived attributes for values like age, totals, or concatenated fields.
Derived attributes improve database efficiency and reduce update errors.