Data Modeling easy
In a relational database, what is the function of a Foreign Key?
- A It serves as the unique identifier for a specific row within the current table and ensures that no duplicate records exist in that set.
- B It establishes a persistent link between two tables, ensuring that a record in one table cannot exist without a valid parent in another.
- C It indicates that the column contains sensitive information that must be automatically masked or hashed by the database engine.
- D It defines a virtual computed column that is derived from the results of several other mathematical operations within the same row.
Answer: B. It establishes a persistent link between two tables, ensuring that a record in one table cannot exist without a valid parent in another.
A Foreign Key (FK) is a foundational tool for enforcing referential integrity in relational databases. It ensures that 'orphaned' records cannot be created—for example, you cannot create an Order for a Customer ID that does not exist in the Customers table. While FKs guarantee structural correctness, they introduce a small performance overhead during write operations as the database must verify constraints.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- When modeling a Distributed Transaction using the Saga Pattern (Choreography or Orchestration), what type of consistency do you achieve?
- Which practice prevents SQL Injection attacks?
- What is 'Bi-Temporal' data modeling (e.g., in SQL:2011 standard)?
- Adding an Index to a database column generally improves Read performance. What is the negative trade-off?
- Log Systems Merge (LSM) Trees (used in RocksDB, Cassandra) optimize for fast writes. What is their primary downside regarding Disk I/O?
- What is the primary objective of normalizing a relational database schema (e.g., to 3NF)?