Cleanup database.js

* Add section headings.
* Start to rearrange code into sections.
* Start to add a table of contents.
* Add a few alternatives to database.query to match other patterns
  of querying.  (E.g., a query in which we only look at true/false.)
* Add some introductory comments to functions.
* Reformat some of the Alex-style six-Ps.
* And more.
Fix link to image after create.
Merge branch 'master' of github.com:GlimmerLabs/MathOverImages
Rewrote deleteImage.
Add deleteimg to api.