3.使用MySQL 语句在 salary_management_system数据库中创建4个数据表 tbl_departments、tbl_rank_ salary、tbl_employees、tb_salary。
时间: 2024-10-27 15:14:23 浏览: 15
在MySQL中创建这些表格的SQL语句会分别如下所示:
1. 创建 tbl_departments (部门) 表格:
```sql
CREATE TABLE tbl_departments (
id INT AUTO_INCREMENT PRIMARY KEY,
department_name VARCHAR(50) NOT NULL
);
```
2. 创建 tbl_ranks_salary (职位工资等级) 表格:
```sql
CREATE TABLE tbl_ranks_salary (
rank_id INT AUTO_INCREMENT PRIMARY KEY,
rank_name VARCHAR(50),
min_salary DECIMAL(10, 2),
max_salary DECIMAL(10, 2)
);
```
3. 创建 tbl_employees (员工) 表格:
```sql
CREATE TABLE tbl_employees (
employee_id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
department_id INT,
rank_id INT,
FOREIGN KEY (department_id) REFERENCES tbl_departments(id),
FOREIGN KEY (rank_id) REFERENCES tbl_ranks_salary(rank_id)
);
```
4. 创建 tb_salary (员工薪资) 表格(假设薪资记录包含时间信息,如月度薪资):
```sql
CREATE TABLE tb_salary (
salary_id INT AUTO_INCREMENT PRIMARY KEY,
employee_id INT,
salary_amount DECIMAL(10, 2),
month DATE,
FOREIGN KEY (employee_id) REFERENCES tbl_employees(employee_id)
);
```
阅读全文