Updated database functionality to be much better and more diverse. Also added checks for if files alredy existed in the table pre-insert