Modified DB integration

Modified:
1.Instead of writing to the DB after every step, a random user id is
generated at the start of every session, when the game ends, all the
data is written to the DB to ensure only fully played games are
documented.