What is a derived attribute? Give an example. What are the advantages or disadvantages of storing or not storing a derived attribute?
How is a relationship between entities indicated in an ERD? Give an example using
the Crow’s Foot notation.
The Correct Answer and Explanation is :
What is a Derived Attribute?
A derived attribute is an attribute that is not stored in the database but is calculated or derived from other stored attributes. For instance, in a database storing employee information, the age of an employee could be derived from their date of birth and the current date.
Example:
- Date of Birth: Stored attribute (e.g., 1990-01-01).
- Age: Derived attribute, calculated as the difference between the current date and the date of birth.
Advantages and Disadvantages of Storing Derived Attributes:
Advantages of Not Storing Derived Attributes:
- Reduced Storage Requirements: Derived attributes do not consume additional database space.
- Accuracy: Derived attributes are always up-to-date since they are recalculated on demand.
- Consistency: There’s no risk of mismatched data because the derived value reflects the base data.
Disadvantages of Not Storing Derived Attributes:
- Increased Computation: Calculating derived attributes each time they are accessed can affect performance.
- Complex Queries: Queries may become more complex, as calculations need to be included in every query requiring the derived attribute.
Advantages of Storing Derived Attributes:
- Faster Access: Storing derived attributes allows quicker retrieval since no calculations are needed.
- Simpler Queries: Derived values are precomputed, making queries easier to write.
Disadvantages of Storing Derived Attributes:
- Inconsistencies: If the base data changes, the derived attribute may not automatically update.
- Increased Storage: Storing derived attributes requires additional space.
Indicating Relationships in an ERD Using Crow’s Foot Notation
In an Entity-Relationship Diagram (ERD), relationships between entities are represented using lines and specific symbols. In Crow’s Foot Notation, relationships are depicted with symbols like:
- Lines to connect entities.
- Crow’s Foot (three prongs) for “many.”
- Straight line for “one.”
- Circle for optional participation.
Example:
- Entities:
CustomerandOrder. - Relationship: A customer can place multiple orders, and each order belongs to one customer.
Using Crow’s Foot:
- The line between
CustomerandOrderwould show: - A single line at the
Customerside (indicating “one”). - A crow’s foot at the
Orderside (indicating “many”).
This relationship can be read as:
- “A customer can place zero or many orders.”
- “An order belongs to exactly one customer.”
Crow’s Foot Notation is widely used for its simplicity in representing cardinality and participation clearly.