Updated SQL structure for more security