solution to database script
finally, database script works!