1
I would like to calculate the salary of a teacher based on the hourly load of discipline that he teaches, I created a Java algorithm for this, but however I can’t pass it to SQL
Algorithm in Java
public double calcSalario() { //Calcula o salário do professor
switch (this.getEscolaridade()) {
case 1:
this.salario = 20 * this.calcCargaHoraria();
break;
case 2:
this.salario = 23 * this.calcCargaHoraria();
break;
default:
this.salario = 25 * this.calcCargaHoraria();
break;
}
return salario;
}
But I can’t do anything close to that in SQL, as I could do the same thing directly in the database?
This is the structure of my bank
create table pessoa(
Id_pessoa tinyint not null,
Nome_pessoa varchar(45) not null,
Cpf_pessoa varchar(20) not null,
Sexo_pessoa enum('m', 'f', 'nd') not null,
primary key(Id_pessoa)
) default charset = utf8;
create table aluno(
Id_aluno tinyint not null,
Id_pessoa tinyint not null,
Score_aluno double,
Bolsista_aluno tinyint not null,
primary key(Id_aluno),
foreign key(Id_pessoa) references pessoa(Id_pessoa)
) default charset = utf8;
create table professor(
Id_professor tinyint not null,
Id_pessoa tinyint not null,
Efetivo_professor tinyint not null,
Escolaridade_professor tinyint not null,
Salario_professor double,
primary key(Id_professor),
foreign key(Id_pessoa) references pessoa(Id_pessoa)
) default charset = utf8;
create table disciplina(
Id_disciplina tinyint not null,
Nome_disciplina varchar(45) not null,
CargaHoraria_disciplina int not null,
primary key(Id_disciplina)
) default charset = utf8;
create table curso(
Id_curso tinyint not null,
Nome_curso varchar(45) not null unique,
primary key(Id_curso)
) default charset = utf8;
create table aluno_disciplina(
Id_aluno tinyint not null,
Id_disciplina tinyint not null,
primary key(Id_aluno, Id_disciplina),
foreign key(Id_aluno) references aluno(Id_aluno),
foreign key(Id_disciplina) references disciplina(Id_disciplina)
) default charset = utf8; -- Relaciona o aluno com a disciplina que ele está cursando
create table professor_disciplina(
Id_professor tinyint not null,
Id_disciplina tinyint not null,
primary key(Id_professor, Id_disciplina),
foreign key(Id_professor) references professor(Id_professor),
foreign key(Id_disciplina) references disciplina(Id_disciplina)
) default charset = utf8; -- Relaciona o professor com a matéria que ele relaciona
create table disciplina_curso(
Id_disciplina tinyint not null,
Id_curso tinyint not null,
primary key(Id_disciplina, Id_curso),
foreign key(Id_disciplina) references disciplina(Id_disciplina),
foreign key(Id_curso) references curso(Id_curso)
) default charset = utf8; -- Relaciona a disciplina com o curso
Post what you do calcCargaHoraria
– Motta
@Abelsouza: Which is the database manager: Mariadb? Oracle Database? SQL Server? other?
– José Diz