Started wok on reducing special case code in database

for each kind of object.

WIP