Residents of Boston’s North Shore suburbs were struggling to absorb the news Wednesday that Danvers High School math teacher Colleen Ritzer was murdered, and that a 14-year-old male student has been charged.

The tragedy occurred one day after the Sparks Middle School shooting in Nevada, in which police say math teacher Michael Landsberry was killed by a 12-year-old male student who then killed himself.

Two communities on opposite sides of the country are now grappling with the loss of beloved teachers, and renewing the national soul-searching about school safety and how to identify and help distressed young people before they turn to violence.

“It’s rare for a student to kill a teacher … but in trusting relationships there is some vulnerability,” and educators are likely to be reflecting on that in the wake of these incidents, says David Schonfeld, a pediatrician and director of the National Center for School Crisis and Bereavement at St. Christopher’s Hospital for Children in Philadelphia.

“School campuses are still among the safest places in the country, but that doesn’t take away the hurt and sadness when someone is lost at school … and we have to do more to ensure the safety of the students and those who work there,” says Dennis Van Roekel, president of the National Education Association, an educators’ union in Washington.

Workplace deaths among elementary and secondary school staff are rare, and homicides even more rare. In 2012, the Department of Labor reports 40 deaths and 7 homicides in public and private K-12 schools – which likely includes the six staff members killed in the shootings at Sandy Hook Elementary in Connecticut.

Between 2003 and 2010 the number of workplace homicides in schools fluctuated up and down between 3 and 7, according to the Labor Department’s Census of Fatal Occupational Injuries.

The homicides are not always by students. Across all industries, 12 percent of homicides of both men and women are by students, patients, or clients.

Yet just within the category of shootings, at least 17 teachers, principals, and other staff members have been killed by students since 1995, according to a map summarizing school shooting incidents published by USA Today.

In Danvers, investigators found blood in the school after Ms. Ritzer was reported missing late Tuesday night. Her body was recovered from woods nearby the school.

Student Philip Chism was also reported missing Tuesday when he did not return home from school, and was picked up by police on a road in a nearby town after midnight. He was arraigned on a murder charge in adult court Wednesday and held without bail. The judge denied his defense attorney’s request to keep his name hidden because he is 14.

Each case brings up slightly different issues for teachers, school crisis experts says.

No more details were available at press time about how well Ritzer and Philip knew each other or whether the student, who reportedly had recently moved to the town from Tennessee, had any mental health issues that might have been evident to teachers. According to the Boston Globe, a police report filed in court Wednesday said simply: "Ritzer and the juvenile are known to each other from the school."

But for dedicated teachers who often stay after school or bond with students, the Danvers news would be “frightening and unsettling,” Dr. Schonfeld says. “Some teachers might rethink the safety of ‘Can I meet with you after school?’ ”

When a teacher like Mr. Landsberry in Nevada is hailed as a hero for sacrificing his life while confronting the shooter, the question may arise in other teachers’ minds of whether they would be expected to do the same. “We expect a lot from teachers, but that goes above and beyond what we should expect from anyone,” Schonfeld says.

Kenneth Trump, president of National School Safety and Security Services in Cleveland, Ohio, agrees. In light of school shootings, some schools are training teachers that they should attack a gunman if they can’t get away or hide, he says, but a few hours in a workshop “can create a false sense of security … and set them up for getting themselves even more hurt.”

Instead, Mr. Trump says, schools should be focusing on the fundamentals and turning to best practices, such as bolstering good relationships with students and ensuring they’ve got good quality basic security and emergency preparedness. Schools also need more resources to deal with the mental health and behavioral challenges among students, he says, since mental health issues are often at the root of student violence.

Chris Weimert, a student in Ritzer's geometry class last year, said Ritzer had taught at the school for two years and was a welcoming person who “always had a warm smile on her face,” the Associated Press reported. Chris said Philip “seemed like a good kid…. It really threw the whole town of Danvers a curve ball.”

“At this time, we are mourning the tragic death or our amazing, beautiful daughter and sister,” a family statement said. "Everyone that knew and loved Colleen knew of her passion for teaching and how she mentored each and every one of her students.”

All public schools in Danvers were closed Wednesday. High school students were planning a candlelight vigil for Wednesday evening.

The Massachusetts Teachers Association says it is “closely monitoring this terrible situation. As we grieve for Colleen, we are doing everything we can to support students, fellow educators and parents.”

Resources that may be of assistance to schools and communities in this time of crisis are available at: www.massteacher.org/crisisresources

Material from Associated Press was used in this report.