Mapping Overview
Quality Criteria
Read aloud is unavailable in this browser.
Measuring Mapping Quality
You've applied the mapping algorithm and made thoughtful design decisions. The relational schema is defined, constraints are specified, and documentation is written. But how do you know the mapping is actually correct?
Mapping quality isn't subjective—it can be systematically evaluated against well-defined criteria. A high-quality mapping:
- Preserves all semantics from the original ER diagram
- Enforces all constraints that the business requires
- Avoids anomalies that cause data inconsistency
- Supports efficient operations for expected access patterns
- Maintains clarity for developers who will query and maintain the schema
This page establishes a comprehensive quality framework for evaluating relational schema mappings. By the end, you'll have a validation checklist that ensures mappings meet professional standards.
By the end of this page, you will understand the pillars of mapping quality, be able to validate mappings against formal criteria, identify common mapping defects, and apply a systematic quality checklist to any ER-to-relational transformation.
The Four Pillars of Mapping Quality
Mapping quality can be decomposed into four fundamental dimensions, each addressing different aspects of schema correctness and utility:
The Quality Pillars:
| Pillar | Focus | Key Question |
|---|---|---|
| Semantic Correctness | Does the schema accurately represent the ER model? | Can all ER constraints be enforced? |
| Structural Integrity | Does the schema avoid data anomalies? | Is the schema properly normalized? |
| Operational Efficiency | Does the schema support efficient queries? | Can expected operations execute performantly? |
| Maintainability | Is the schema understandable and evolvable? | Can future changes be made safely? |
Inter-Pillar Trade-offs:
These pillars sometimes conflict:
- Normalization (Structural Integrity) may hurt Operational Efficiency due to joins
- Denormalization for performance may reduce Semantic Correctness (redundancy risks)
- Highly constrained schemas ensure correctness but may reduce Maintainability (rigid change process)
The goal is not to maximize every pillar but to achieve an appropriate balance for your system's requirements. A data warehouse may sacrifice normalization for query speed; an OLTP system may prioritize integrity above all.
Quality Assessment Approach:
For each pillar, we'll define:
- Specific criteria to evaluate
- Validation procedures to verify
- Common defects and their symptoms
- Remediation strategies
There's no universal ranking of these pillars. OLTP systems prioritize semantic correctness and structural integrity. Analytical systems may accept denormalization for query performance. IoT data ingestion may prioritize operational efficiency. Know your system's priorities before evaluating quality.
Pillar 1: Semantic Correctness
Semantic correctness ensures the relational schema accurately represents all information and constraints from the ER model. This is the most fundamental quality criterion—without it, the database cannot serve its purpose.
Semantic Correctness Criteria:
- •Entity Completeness — Every entity type has a corresponding table (or merged into another per design decision)
- •Attribute Completeness — Every attribute appears as a column (or in a separate table for multivalued)
- •Relationship Completeness — Every relationship is represented via FK, junction table, or merged approach
- •Key Preservation — Every entity's identifying attribute(s) serve as primary or unique key
- •Cardinality Enforcement — 1:1 has UNIQUE on FK; 1:N has FK; M:N has junction table
- •Participation Enforcement — Total participation → NOT NULL FK; Partial → nullable FK
- •Referential Integrity — All FK constraints properly declared with appropriate actions
- •Domain Constraints — CHECK constraints enforce attribute domains where needed
Validation Procedure:
To verify semantic correctness, perform a mapping audit:
- Create Entity Mapping Matrix:
| ER Entity | Mapped Table | Key Preserved? | All Attrs? |
|---|---|---|---|
| EMPLOYEE | EMPLOYEE | ✓ (SSN → PK) | ✓ |
| DEPENDENT | DEPENDENT | ✓ (Composite) | ✓ |
- Create Relationship Mapping Matrix:
| ER Relationship | Type | Mapping Approach | Cardinality Enforced? | Participation Enforced? |
|---|---|---|---|---|
| WORKS_IN | 1:N | FK in EMPLOYEE | ✓ (no UNIQUE) | ✓ (nullable) |
| MANAGES | 1:1 | FK in DEPARTMENT | ✓ (UNIQUE) | ✓ (NOT NULL) |
- Trace Each Constraint: For every constraint in the ER diagram, identify the corresponding relational enforcement mechanism.
• Missing FK for relationship • 1:1 without UNIQUE on FK • Total participation with nullable FK • Junction table with wrong key • Multivalued attr stored as delimiter • Missing CHECK for domain
• Every ER element traceable to schema • Constraints provably enforce rules • No valid ER state rejected by schema • No invalid ER state accepted by schema • Mapping documentation complete
Pillar 2: Structural Integrity
Structural integrity ensures the schema avoids redundancy and the associated update anomalies. This pillar is closely aligned with normalization theory—a well-mapped schema should achieve at least Third Normal Form (3NF) without explicit denormalization decisions.
Anomaly Types:
| Anomaly | Description | Example | Detected Via |
|---|---|---|---|
| Insertion Anomaly | Cannot insert one type of data without unrelated data | Cannot add department without having employee | Attempt operations on empty relationships |
| Deletion Anomaly | Deleting data causes unintended loss of other data | Deleting last employee removes department info | Trace cascade effects of deletions |
| Update Anomaly | Updating one fact requires multiple row changes | Department name change requires updating all employee rows | Identify redundantly stored data |
Normalization Verification:
A correct ER-to-relational mapping should produce a schema that is at least 3NF:
1NF Criteria:
- All tables have atomic values (no repeating groups, no multivalued cells)
- Primary key defined for every table
2NF Criteria (if applicable):
- 1NF plus no partial dependencies (non-key attributes depend on full key, not part of key)
- Relevant only for composite keys
3NF Criteria:
- 2NF plus no transitive dependencies (non-key attributes don't depend on other non-key attributes)
- Every non-key attribute depends on "the key, the whole key, and nothing but the key"
BCNF Criteria:
- Every determinant is a candidate key
- Stricter than 3NF; may conflict with dependency preservation
A properly constructed ER model, when mapped correctly, naturally produces a 3NF schema. If your mapping produces normalization violations, either the ER model has issues (hidden dependencies) or the mapping introduced redundancy. Trace back to identify where the problem originated.
Structural Integrity Checklist:
- •No repeating groups — Multivalued attributes properly factored out
- •No partial dependencies — All attributes depend on full composite keys
- •No transitive dependencies — Non-key attributes don't determine other non-keys
- •No redundant data storage — Each fact stored in exactly one place
- •Anomaly-free operations — Insert, update, delete without unintended side effects
Pillar 3: Operational Efficiency
While mapping focuses on correctness, the resulting schema must also support efficient database operations. Efficiency criteria evaluate whether the structure enables good query performance.
Efficiency Factors:
| Factor | Description | Mapping Impact |
|---|---|---|
| Join Complexity | Number of tables that must be joined for common queries | Table merging reduces joins; separation increases them |
| Row Width | Total bytes per row affecting I/O | Wide tables (merged or STI) may hurt scan performance |
| Index Suitability | Can efficient indexes be created for expected queries? | Key choices affect indexability |
| NULL Density | Proportion of NULL values in tables | High NULL density wastes space and complicates indexing |
| Key Size | Byte size of primary and foreign keys | Composite or string keys larger than integer surrogates |
| Cardinality Ratios | Number of rows in joined tables | Affects join algorithm selection and memory usage |
Efficiency Evaluation Process:
-
Enumerate Expected Queries: List the most common and most critical queries the system will execute.
-
Trace Query Paths: For each query, identify which tables are accessed, which joins required, which indexes useful.
-
Estimate Access Patterns:
- Point lookups (single row by key)
- Range scans (rows within range)
- Full table scans (all rows)
- Join cardinalities
-
Identify Hotspots: Tables or joins that appear in many queries are optimization targets.
-
Consider Index Strategies: Can indexes on the mapped tables support common access patterns?
Example Efficiency Analysis:
Query: Find all employees in a department with their skills
Tables needed: EMPLOYEE, DEPARTMENT, EMPLOYEE_SKILLS
Joins: EMPLOYEE ⟕ DEPARTMENT (on DeptID)
EMPLOYEE ⟕ EMPLOYEE_SKILLS (on SSN)
Indexes needed:
- DEPARTMENT(DeptID) — for join
- EMPLOYEE(DeptID) — for lookup
- EMPLOYEE_SKILLS(EmployeeSSN) — for join
Assessment: 2 joins required, all indexable ✓
Efficiency analysis should inform decisions but not override correctness. Denormalizing for performance is acceptable ONLY after confirming the normalized design is too slow. Always start with a correct mapping and optimize based on measured performance, not speculation.
Pillar 4: Maintainability
Schemas live for years or decades. Maintainability measures how understandable, modifiable, and evolvable the schema is over its lifetime.
Maintainability Criteria:
- •Naming Clarity — Table and column names clearly indicate their purpose without abbreviations or cryptic codes
- •Consistent Conventions — Naming patterns, case conventions, and constraint naming are consistent throughout
- •Documentation Quality — Schema includes comments, data dictionary, and mapping rationale
- •Reasonable Table Count — Neither excessive fragmentation nor inappropriate merging
- •Clear Entity Boundaries — Each table represents one clear concept (entity or relationship)
- •Explicit Constraints — Constraints declared in DDL, not hidden in application code
- •Minimal Coupling — Changes to one part of schema don't cascade unexpectedly
- •Versioning Readiness — Schema design allows additive changes (new columns, tables) without restructuring
Maintainability Anti-Patterns:
| Anti-Pattern | Example | Impact |
|---|---|---|
| Cryptic names | EMPL_DPTT_FK1 | Developers can't understand purpose |
| Overloaded tables | Single table for 10 entity types | Every change affects unrelated data |
| Hidden constraints | Cardinality enforced only in app | Data corruption if app logic bypassed |
| Magic values | Status = 99 means deleted | Requires tribal knowledge |
| Excessive normalization | 30 tables for 5 entities | Simple queries become complex |
| Undocumented decisions | No rationale for design choices | Changes made without understanding context |
Write schemas as if the next person to work on it is a competent professional who knows SQL but not your business domain. Clear naming, explicit constraints, and good documentation enable them to understand and safely modify the schema.
Evolution Readiness:
A maintainable schema anticipates change:
-
Additive Changes Should Be Easy:
- New optional columns → Simple ALTER TABLE ADD
- New entity types → New tables with FKs
- New relationships → FK additions or junction tables
-
Structural Changes Should Be Plannable:
- Splitting tables → View for backward compatibility
- Merging tables → Data migration with integrity checks
- Key changes → Careful FK cascade planning
-
Data Type Expansions Should Be Possible:
- VARCHAR(50) → VARCHAR(100) trivial
- INT → BIGINT possible but requires FK updates
- String → Enum requires data validation
Common Mapping Defects
Experienced reviewers recognize recurring patterns of mapping defects. This catalog helps identify and remediate common errors:
Defect Catalog:
| Defect | Symptom | Root Cause | Remediation |
|---|---|---|---|
| Missing 1:1 UNIQUE | Multiple rows on 'one' side | FK without UNIQUE constraint | Add UNIQUE to FK column |
| Wrong FK placement | Excessive NULLs in FK column | FK on wrong side of 1:N | Move FK to N-side table |
| M:N without junction | Comma-separated values in cell | Attempted embedded M:N | Create proper junction table |
| Missing NOT NULL | Orphan rows (FK is NULL) | Partial participation where total | Add NOT NULL to FK |
| Wrong CASCADE action | Data deleted unexpectedly | CASCADE where RESTRICT appropriate | Change to RESTRICT or SET NULL |
| Composite key omission | Duplicate weak entity rows | Owner PK not in weak PK | Include owner PK in composite key |
| Mixed inheritance | Inconsistent subtype handling | Different strategies per subtype | Unify to single strategy |
| Redundant columns | Update anomalies | Denormalization without tracking | Normalize or document with sync strategy |
Defect Detection Techniques:
-
Constraint Testing: Attempt to insert data that should violate ER constraints. If the database accepts it, there's a mapping defect.
-- Test: 1:1 should prevent second manager for same dept -- If this succeeds, UNIQUE is missing INSERT INTO DEPARTMENT (DeptID, DeptName, ManagerSSN) VALUES (1, 'Sales', '111-11-1111'); INSERT INTO DEPARTMENT (DeptID, DeptName, ManagerSSN) VALUES (2, 'Marketing', '111-11-1111'); -- Same manager! -
Anomaly Probing: Execute sequences of DML that would reveal anomalies:
- Insert entity without required relationship
- Delete referenced row and check cascades
- Update data that should appear in multiple places
-
Coverage Analysis: Check that every ER element maps to something:
- Every entity → table or merged
- Every attribute → column
- Every relationship → FK or junction
- Every constraint → DDL clause
Comprehensive Quality Checklist
The following checklist consolidates all quality criteria into a practical validation tool. Use this checklist to verify any ER-to-relational mapping before considering it complete.
- •☐ Every entity type has a corresponding table (or documented merger)
- •☐ Every attribute appears as a column (or in multivalued table)
- •☐ Every relationship is represented (FK, junction, or merge)
- •☐ Primary keys preserve entity identity from ER model
- •☐ 1:1 relationships have UNIQUE constraint on FK
- •☐ 1:N relationships have FK on N-side
- •☐ M:N relationships have junction table with composite PK
- •☐ Total participation enforced via NOT NULL on FK
- •☐ Partial participation allows NULL FK where appropriate
- •☐ Weak entities include owner PK in their composite PK
- •☐ Multivalued attributes decomposed to separate tables
- •☐ Referential actions appropriate for each relationship
- •☐ Schema achieves 3NF (or denormalization is documented)
- •☐ No insertion anomalies for expected operations
- •☐ No deletion anomalies for expected operations
- •☐ No update anomalies from redundant data
- •☐ Common queries can execute efficiently
- •☐ Indexes can support identified access patterns
- •☐ Names are clear and follow consistent conventions
- •☐ Documentation captures mapping decisions and rationale
Treat this checklist as a quality gate. A mapping should not proceed to implementation until all applicable items are verified. Any unchecked items require either remediation (if defect) or documented exception (if intentional deviation).
KEEP LEARNING
Keep learning for free.
Read the complete lesson, save your notes and pick up where you left off with a free account. No card needed.