Logic for types in DB