This module discussed how business objects and their characteristics are converted into entities and attributes.
This is in preparation for creating an ER diagram. You also learned that multi-valued attributes violate the single-value rule for relational databases, and then learned two approaches to resolving multi-valued attributes.
Finally, you learned about constraints that can be placed on attributes and entity relationships to help ensure data integrity.
- Learning Objectives
Having completed this module, you should be able to:
- Define entities and entity attributes
- Explain the purpose of entity identifiers
- List rules for creating entity identifiers
- Describe instances of entities
- Describe attribute domains and domain types
- Explain the problem with multi-valued attributes
- Describe how to resolve multi-valued attributes by adding more attributes
- Describe how to resolve multi-valued attributes by creating a new entity
- List entity and attribute constraints
The single-value rule in relational databases states that each attribute (column) in a table must contain atomic (indivisible) values—meaning a field should not store multiple values or lists. This rule is a fundamental part of First Normal Form (1NF) in database normalization.
Key Aspects of the Single-Value Rule
-
Atomicity of Data
- Each column must contain a single value per row, rather than multiple or composite values.
- Example: A "PhoneNumbers" column should not store multiple phone numbers in a single field (e.g., "555-1234, 555-5678").
-
No Repeating Groups
- Columns should not hold multiple values for the same attribute.
- Example: Instead of having columns
Product1
, Product2
, and Product3
in an Orders
table, products should be stored in a separate OrderDetails
table.
-
Compliance with First Normal Form (1NF)
- The single-value rule ensures that a table adheres to 1NF, which prevents data redundancy and inconsistencies.
Example of Violating vs. Following the Single-Value Rule
Incorrect Design (Violating the Single-Value Rule)
CustomerID | CustomerName| PhoneNumbers
-----------|-------------|-----------------------
1001 | John Doe | 555-1234, 555-5678
1002 | Jane Smith | 555-9999
- Here, the `PhoneNumbers` column stores multiple values in a single field, breaking the single-value rule.
Correct Design (Following the Single-Value Rule)
A separate table is used to store multiple phone numbers properly.
Customers Table
CustomerID | CustomerName
-----------|-------------
1001 | John Doe
1002 | Jane Smith
CustomerPhones Table
PhoneID | CustomerID | PhoneNumber
--------|-----------|------------
1 | 1001 | 555-1234
2 | 1001 | 555-5678
3 | 1002 | 555-9999
- This design follows the single-value rule by ensuring that each column holds only one value per row.
Why the Single-Value Rule Matters
- Prevents data anomalies (e.g., difficulty in updating or deleting specific values).
- Improves query performance (avoids parsing and searching within text-based multi-value fields).
- Ensures data integrity (each value is properly indexed and related).