database code done.

i hope this shitty laptop doens't crash any more!