Added database, main file and some small fixes to other files

data are all stored in sqlite3 database