On many other platforms, the situation you describe would result in an exception: your child record is committed to the database but the parent it refers to does not exist. Do not rely on this to work in Mendix. It is generally speaking a modelling error. The runtime attempts to fix it for you but this is really error prone.
A common example is creating a parent object, without commit and taking pictures that are linked to it. A recipe for disaster. Always commit the parent first.
In this situation I often split the process: A MyObj_New page with some basics, the save button calls a microflow that commits the object, closes the page and then opens the edit page. Or just commit your object when a child object is committed. Be prepared for objects in your database that do not meet your validation requirements. - @Marcel Groeneweg