Types of Attributes in ER Diagram: Explained with Examples
In an ER diagram,
attributes describe properties of entities and can be of various types: simple (indivisible), composite (made of multiple parts), derived (calculated from other attributes), single-valued (one value per entity), and multi-valued (multiple values per entity). These types help model real-world data clearly and precisely.Syntax
Attributes in an ER diagram are represented as ovals connected to their entity or relationship. Different types of attributes have distinct representations:
- Simple Attribute: A single oval with the attribute name.
- Composite Attribute: An oval connected to smaller ovals representing its parts.
- Derived Attribute: An oval with a dashed outline.
- Multi-valued Attribute: A double oval.
- Key Attribute: An oval with the attribute name underlined to show it uniquely identifies an entity.
plaintext
Entity: Student
Simple Attribute: Name
Composite Attribute: FullName (FirstName, LastName)
Derived Attribute: Age (from DateOfBirth)
Multi-valued Attribute: PhoneNumbers
Key Attribute: StudentIDExample
This example shows how different attribute types describe a Student entity:
plaintext
Entity: Student
Attributes:
- StudentID (Key, Single-valued)
- FullName (Composite: FirstName, LastName)
- DateOfBirth (Simple)
- Age (Derived from DateOfBirth)
- PhoneNumbers (Multi-valued)
Representation:
Student --(oval)--> StudentID (underlined)
Student --(oval)--> FullName --(ovals)--> FirstName, LastName
Student --(oval)--> DateOfBirth
Student --(dashed oval)--> Age
Student --(double oval)--> PhoneNumbersOutput
Student entity with attributes:
- StudentID (unique ID)
- FullName split into FirstName and LastName
- DateOfBirth as a simple attribute
- Age calculated from DateOfBirth
- Multiple PhoneNumbers stored
Common Pitfalls
Common mistakes when using attributes in ER diagrams include:
- Confusing composite and simple attributes by not breaking down composite attributes into parts.
- Forgetting to mark key attributes as underlined, which can cause ambiguity in entity identification.
- Not using derived attributes properly, leading to redundant data storage.
- Ignoring multi-valued attributes and trying to store multiple values in a single attribute, which breaks normalization.
plaintext
Wrong: Entity: Employee Attribute: FullName (treated as simple) Right: Entity: Employee Attribute: FullName (Composite: FirstName, LastName)
Quick Reference
| Attribute Type | Description | ER Diagram Symbol |
|---|---|---|
| Simple | Indivisible attribute with a single value | Single oval |
| Composite | Attribute made of multiple sub-parts | Oval connected to smaller ovals |
| Derived | Attribute calculated from other attributes | Dashed oval |
| Multi-valued | Attribute with multiple values per entity | Double oval |
| Key | Attribute that uniquely identifies an entity | Underlined oval |
Key Takeaways
Attributes describe properties of entities and relationships in ER diagrams.
Simple, composite, derived, multi-valued, and key are the main attribute types.
Composite attributes break down into smaller parts for clarity.
Derived attributes are calculated, not stored directly.
Multi-valued attributes represent multiple values and use double ovals.