Loading learning content...
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:
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.
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:
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:
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.
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:
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
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:
2NF Criteria (if applicable):
3NF Criteria:
BCNF Criteria:
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:
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:
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.
Schemas live for years or decades. Maintainability measures how understandable, modifiable, and evolvable the schema is over its lifetime.
Maintainability Criteria:
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:
Structural Changes Should Be Plannable:
Data Type Expansions Should Be Possible:
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:
Coverage Analysis: Check that every ER element maps to something:
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.
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).
Quality assessment transforms mapping from a completed task to a verified deliverable. Let's consolidate the key insights:
What's Next:
The final page of this module explores Common Patterns—recurring mapping scenarios that appear across different domains. These patterns provide templates that accelerate mapping for familiar structures and guide handling of complex cases.
You now have a comprehensive framework for evaluating mapping quality. Apply the four pillars and the validation checklist to every mapping you create or review. Quality assessment is what separates professional database design from ad-hoc schema creation.