I have table discipline and teacher table. The teacher contains discipline. How do I change the name of the course and automatically change the tb teachers?
I'm kind of confused about using On update cascade and delete Casdade .. It deletes and modifies all the children, but how do I use the cascade update in the discipline table if it has only the primary key?
public void createTableDisciplina(){
try {
conn.createStatement().execute("CREATE TABLE Disciplina(Nome varchar(50) NOT NULL primary key)");
} catch (SQLException ex) {
Logger.getLogger(DBConnection.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void createTableProfessor(){
try {
conn.createStatement().execute("CREATE TABLE Professor(Nome varchar(50) NOT NULL primary key, Nome_Disciplina varchar(50) NOT NULL references Disciplina(Nome) ON DELETE Cascade, NumAulas int NOT NULL, NumFaltas int)");
} catch (SQLException ex) {
Logger.getLogger(DBConnection.class.getName()).log(Level.SEVERE, null, ex);
}
}