Entities and Attributes
Entities and Attributes
The Entity–Relationship (ER) model represents real-world data using three fundamental concepts:
-
Entities
-
Attributes
-
Relationships
This section focuses on entities and attributes, which form the building blocks of conceptual database design. Relationships are introduced later.
1. Entities and Attributes
What Is an Entity?
An entity is a real-world object or concept that has an independent existence. Entities can be:
-
Physical objects: person, employee, car, house
-
Conceptual objects: company, job, university course
Each entity is distinguishable from others and is described by a set of attributes.
Attributes of an Entity
An attribute is a property or characteristic that describes an entity.
Example: EMPLOYEE entity
-
Name
-
Age
-
Address
-
Salary
-
Job
Each entity has one value per attribute (unless the attribute is multivalued). These attribute values form the actual data stored in the database.
2. Types of Attributes in the ER Model
The ER model classifies attributes into several categories based on their structure and usage.
2.1 Simple vs. Composite Attributes
Simple (Atomic) Attributes
-
Cannot be subdivided into smaller components
-
Example: Age, Salary, Sex
Composite Attributes
-
Can be divided into smaller, meaningful sub-attributes
-
Example:
-
Address → Street, City, State, Zip
-
Street → Number, Street_name, Apartment_number
-
📌 Key Point
Composite attributes are useful when users sometimes refer to the entire attribute and sometimes to its individual components.
2.2 Single-Valued vs. Multivalued Attributes
Single-Valued Attributes
-
Have exactly one value for each entity
-
Example: Age of a person
Multivalued Attributes
-
Can have multiple values for the same entity
-
Example:
-
Phone_numbers of a person
-
College_degrees of a student
-
Colors of a car
-
📌 Constraints on Multivalued Attributes
-
Lower and upper bounds may restrict how many values are allowed
-
Example: A car may have at most two colors
2.3 Stored vs. Derived Attributes
Stored Attributes
-
Values are explicitly stored in the database
-
Example: Birth_date, Salary
Derived Attributes
-
Values are calculated from other attributes
-
Example:
-
Age derived from Birth_date
-
Number_of_employees derived by counting employees in a department
-
📌 Design Note
Derived attributes are often not stored to avoid redundancy and inconsistency.
2.4 NULL Values
A NULL value represents the absence of a valid value for an attribute. There are two main meanings of NULL:
1. Not Applicable
-
Attribute does not apply to the entity
-
Example:
-
Apartment_number for a single-family house
-
College_degrees for a person with no degree
-
2. Unknown
-
Attribute applies, but the value is not known
-
Example:
-
Home_phone number not provided
-
🔍 Further Classification of Unknown NULL
-
Missing value: Value exists but is not recorded
-
Unknown existence: It is not known whether the value exists at all
2.5 Complex Attributes
Attributes can be both composite and multivalued, and these can be nested arbitrarily.
Complex Attribute
-
Combination of composite and multivalued attributes
-
Represented using:
-
Parentheses
( )for composite attributes -
Braces
{ }for multivalued attributes
-
Example: Address_phone
-
A person may have multiple residences
-
Each residence may have:
-
One address (composite)
-
Multiple phone numbers (multivalued)
-
📌 Such nested structures are called complex attributes.
{Address_phone( {Phone(Area_code,Phone_number)},Address(Street_address
(Number,Street,Apartment_number),City,State,Zip) )}
3. Importance of Attributes in Conceptual Design
-
Attributes define what information is stored
-
Proper classification helps:
-
Reduce redundancy
-
Improve clarity
-
Support correct constraints
-
-
Understanding attribute types is essential for:
-
Designing ER diagrams
-
Mapping ER schemas to relational schemas
-
4. Key Takeaways
-
Entities represent real-world objects with independent existence.
-
Attributes describe the properties of entities.
-
Attributes can be:
-
Simple or composite
-
Single-valued or multivalued
-
Stored or derived
-
-
NULL values represent missing, unknown, or inapplicable data.
-
Complex attributes allow flexible modeling of real-world data.


Comments
Post a Comment