template and db