Updates in conversion from mongo to sql