create tm from database