created SQL for databases and add more validation