Design for historical salary (slowly changing)
SQL
Hard
2 views
Problem Description
You need employee salary history. Design normalized tables to store salary changes with effective_from date.
Output Format
DDL statement(s)
Sample Test Case
Input:
Employees salary history
Constraints
Store time-variant data separately
Official Solution
CREATE TABLE Employees (emp_id INT PRIMARY KEY, name VARCHAR(100)); CREATE TABLE EmployeeSalary (emp_id INT NOT NULL, effective_from DATE NOT NULL, salary DECIMAL(10,2) NOT NULL, PRIMARY KEY(emp_id, effective_from));
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!