Database functionality, first logic