db interface [stolen]