FreshersQuestion 35 of 50
Identify the Foreign Key
Problem
A new developer is struggling to understand how the employee database is structured. They ask you to show them a small sample of the employee data and explain how it links to the departments table. Retrieve all columns from the employees table but only for the first 5 records. Identify which column acts as a foreign key pointing to the departments table in the comments.
Database Schema
Table: employees
employee_id(INT): Unique identifier for the employee.first_name(VARCHAR): First name of the employee.last_name(VARCHAR): Last name of the employee.salary(INT): Employee's salary.department_id(INT): Foreign key referencing the department.manager_id(INT): Foreign key referencing the manager (another employee).hire_date(DATE): Date the employee was hired.
Table: departments
department_id(INT): Unique identifier for the department.department_name(VARCHAR): Name of the department.
Try It
Loading playground environment...