Refactor: database module and fragments

Signed-off-by: Harry Chen <373685963@qq.com>