Implement database factory