Reviewed by Aditya Kumar · Last reviewed 2026-08-08
A Foreign Key (FK) is a column or set of columns in a database table that refers to the Primary Key (PK) of another table. Its primary purpose is to establish and enforce a link between two tables,…
This easy-level General/Other question appears frequently in data engineering interviews at companies like Altimetrik. While less common, it tests deeper understanding that distinguishes strong candidates. Mastering the underlying concepts (bigquery, etl) will help you answer variations of this question confidently.
Start by clearly defining the core concept being asked about. Interviewers want to see that you understand the fundamentals before diving into implementation details. Structure your answer with a definition, then explain the practical application with a concise example. The expert answer includes a code example that demonstrates the implementation pattern.
A Foreign Key (FK) is a column or set of columns in a database table that refers to the Primary Key (PK) of another table. Its primary purpose is to establish and enforce a link between two tables, ensuring referential integrity.
This link prevents "orphan" records by ensuring that a value in the FK column must exist as a PK in the referenced "parent" table. For instance, an order record cannot exist for a customer_id that doesn't correspond to an actual customer. Databases can enforce actions when a referenced PK is deleted or updated, such as ON DELETE CASCADE (deletes dependent rows), ON DELETE SET NULL (sets FK to NULL), or ON DELETE RESTRICT (prevents deletion of the parent PK).
Consider an orders table with a customer_id column referencing the id (PK) in a customers table.
CREATE TABLE customers (
id INT PRIMARY KEY,
name VARCHAR(255)
);
CREATE TABLE orders (
order_id INT PRIMARY KEY,
customer_id INT,
order_date DATE,
FOREIGN KEY (customer_id) REFERENCES customers(id) ON DELETE RESTRICT
);
While crucial for transactional OLTP systems, enforcing FK constraints in analytical data warehouses (OLAP) like BigQuery or Snowflake is often relaxed or handled differently. The overhead of checking every insert/update can significantly impact ETL/ELT performance, especially with large-scale batch loads. In these environments, referential integrity is frequently managed upstream in the data pipeline (e.g., during data ingestion, transformation using tools like dbt, or validated with data quality checks) rather than at the database level, treating FKs as metadata hints rather than strict enforcement.
In the interview, also mention that while traditional RDBMS enforce FKs, modern distributed data systems often treat them as metadata for query optimization or rely on ETL processes for data integrity.
Red Flag: Assuming all DBs enforce. Pro-Move: 'Postgres: FK enforced; BigQuery: FK as metadata only—we validate in dbt tests.'
Some links below are affiliate links. If you buy through them we may earn a small commission at no extra cost to you — it helps keep DataEngPrep free.
According to DataEngPrep.tech, this is one of the most frequently asked General/Other interview questions, reported at 1 company. DataEngPrep.tech maintains an editor-reviewed database of 1,863 data engineering interview questions across 7 categories.