DB doc and sql bugfix