Updated database script and SQL query.