build database