Reverse-engineering an existing database: When assessing the structure of an acquired set of tables with data, determining foreign keys is (part of) the ________.
-
Afirst step.
-
Bsecond step.
-
Cthird step.
-
Dfourth step.
Answer
Correct Answer: second step.
Explanation
Introduction / Context:Foreign keys connect child tables to parent tables and are essential to understanding the database's business relationships. They should be identified immediately after establishing each table's primary key.
Given Data / Assumptions:
- Step sequence: 1) primary keys, 2) foreign keys, 3) validate RI, 4) functional dependencies.
- Metadata or naming may be inconsistent; data must guide discovery.
- We want an early mapping of relationships to guide later checks.
Concept / Approach:
Once primary keys are known, scan for columns in other tables that match the key's data type and semantics. These candidate foreign keys establish parent-child relationships and inform join paths and cardinalities for subsequent analysis and cleanup.
Step-by-Step Solution:
Confirm primary keys for each table.Search other tables for columns with matching types/names (e.g., CustomerID).Propose foreign keys and document their intended references.Verification / Alternative check:
Use counts and distinct checks to see whether each child column's values are subsets of the referenced primary key values before enforcing constraints.
Why Other Options Are Wrong:
First step: requires known parents; third/fourth: delays understanding of relationships needed for validation and normalization.
Common Pitfalls:
Assuming all ID-suffixed columns are foreign keys; overlooking composite keys or mismatched collations/data types.
Final Answer:
second step.