Skip to content
C

Derived Attribute


Derived Attribute

Definition

A derived attribute is an attribute whose value can be computed or inferred from other attributes (or from related entities), rather than being independently input and stored. Because its value is always reproducible from other data, a derived attribute is typically NOT stored directly — storing it risks creating redundant, potentially inconsistent data.

Worked Example

Age for a Student is the textbook derived attribute: it can always be computed as CURRENT_DATE - Date_of_Birth. Storing Age directly would mean it silently becomes wrong every single day (and definitely wrong after a birthday) unless constantly recalculated — so relational designs normally store Date_of_Birth (the stored attribute) and compute Age on demand in a query or view. Another example: Number_of_Students_Enrolled for a Course can be derived by counting rows in the Enrollment relationship for that course, rather than being maintained as a separate stored counter.

Edge Cases

  • In ER diagrams, a derived attribute is shown as a dashed oval, distinguishing it from the solid oval of an ordinary stored attribute.
  • The relationship to its "source" attributes must be a genuine, reliable function — Age is reliably derivable from DateofBirth (given "today's date"), which is why it is safe to compute rather than store.
  • In real systems, a derived value is SOMETIMES intentionally cached/stored for performance (e.g., a materialized "Total_Marks" column updated by a trigger) — this is a deliberate denormalization trade-off, not a contradiction of the concept; the attribute is still conceptually "derived" because its authoritative value comes from other data, even if a redundant stored copy exists for speed.
  • Do not confuse a derived attribute with a multi-valued or composite attribute — derivation is about where the value comes from (computed vs. directly supplied), a completely separate axis from occurrence-count or internal structure.

Key Takeaways / Interview Q&A

Q: Why is it generally bad practice to store a derived attribute like Age directly? A: Because it becomes stale/incorrect the moment time passes or the source data (DateofBirth) changes, creating redundancy and an update-anomaly risk — the same problem normalization tries to prevent.

Q: How is a derived attribute shown in an ER diagram? A: As a dashed-outline oval, connected to the entity, to visually flag that it is computed rather than base data.

Q: Give an example of a derived attribute at the relationship level, not just the entity level. A: Years_Since_Enrollment for an Enrollment could be derived from Enrollment_Date and the current date, without needing its own stored column.

Mock Test

  • Derived Attribute - Quick Test

    8 questions on Derived Attribute.

    8 questions · 8 min · Medium
    Start Mock Test