Refactored database architecture