You can use ref.child()
in a non-existent child and give ref.push()
to create.
So just do it:
DatabaseReference empresaRef = ref.child("Empresa");
To access the venues:
DatabaseReference sedeRef = empresaRef.child("Sede");
And to create a new one is just:
Empresa empresa = new Empresa();
Sede sede = new Sede();
DatabaseReference empresaRef =
ref.child("Empresa").push().setValue(empresa);
DatabaseReference sedeRef = empresaRef.child("Sede").push().setValue(sede);
However it is recommended to save using a unique ID instead of the name.
To generate the ID use:
Empresa empresa = new Empresa();
Sede sede = new Sede();
String empresaID = ref.push().getKey();
DatabaseReference empresaRef = ref.child(empresaID);
empresaRef.setValue(empresa);
String sedeID = empresaRef.push().getKey();
DatabaseReference sedeRef = empresaRef.child(sedeID);
sedeRef.setValue(sede);
;)