Add database query functions