MAFA-19: wrote database functions to get required metadata

Signed-off-by: unknown <cnwnh1@cnwcb5a.cnw.co.nz>