CREATE TABLE departments (
tenant_id UUID,
department_id UUID DEFAULT gen_random_uuid(),
department_name VARCHAR(100) NOT NULL,
description TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (tenant_id, department_id),
FOREIGN KEY (tenant_id) REFERENCES tenants(id)
);
CREATE TABLE employees (
tenant_id UUID,
employee_id UUID DEFAULT gen_random_uuid(),
department_id UUID,
title VARCHAR(100),
compensation DECIMAL(10, 2),
status VARCHAR(50),
hire_date DATE,
termination_date DATE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (tenant_id, employee_id),
FOREIGN KEY (tenant_id, employee_id) REFERENCES users.tenant_users(tenant_id, user_id),
FOREIGN KEY (tenant_id, department_id) REFERENCES departments(tenant_id, department_id)
);
CREATE TABLE performance (
tenant_id UUID,
performance_id UUID DEFAULT gen_random_uuid(),
employee_id UUID,
manager_id UUID,
feedback TEXT,
rating INT,
vector_embedding VECTOR(768), -- Adjust the dimensions as needed
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (tenant_id, employee_id),
FOREIGN KEY (tenant_id, employee_id) REFERENCES employees(tenant_id, employee_id),
FOREIGN KEY (tenant_id, manager_id) REFERENCES employees(tenant_id, employee_id)
);
CREATE TABLE compensation_history (
tenant_id UUID,
compensation_id UUID DEFAULT gen_random_uuid(),
employee_id UUID,
old_compensation DECIMAL(10, 2),
new_compensation DECIMAL(10, 2),
change_date DATE,
reason TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (tenant_id, employee_id),
FOREIGN KEY (tenant_id, employee_id) REFERENCES employees(tenant_id, employee_id)
);
CREATE TABLE employee_feedback (
tenant_id UUID,
feedback_id UUID DEFAULT gen_random_uuid(),
employee_id UUID,
feedback TEXT,
vector_embedding VECTOR(768), -- Adjust the dimensions as needed
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (tenant_id, employee_id),
FOREIGN KEY (tenant_id, employee_id) REFERENCES employees(tenant_id, employee_id)
);
CREATE TABLE benefits (
tenant_id UUID,
benefit_id UUID DEFAULT gen_random_uuid(),
employee_id UUID,
benefit_name VARCHAR(100),
benefit_description TEXT,
vector_embedding VECTOR(768), -- Adjust the dimensions as needed
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (tenant_id, employee_id),
FOREIGN KEY (tenant_id, employee_id) REFERENCES employees(tenant_id, employee_id)
);