Data EngineerQuestion 49 of 55
Generating Surrogate Keys
Problem
The business key for employees is a social security number, which you cannot legally use as the primary key in your data warehouse. You decide to generate a meaningless unique string for every row. Select first_name and generate a UUID for each row using the uuid() function (supported by DuckDB).
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...