I want to get all employees that have a Java certification, but I have been struggling to create a query that works:
This is my schema:
{
  Employees: {
    randomId {
      name: john smith,
      certifications: 
        0: Swift,
        1: Android
    },
    randomId {
      name: richard williams,
      certifications: 
        0: java,
        1: Android
    }
  }
}
I did the following but I doubt that it is the most efficient way to solve this problem, (my thinking is that I do not want to query the entire database for all employees each time I'm checking for a certification)
DatabaseReference reference = database.getReference("Employees");
reference.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                
                for (DataSnapshot snapshot : dataSnapshot.getChildren()){
                    Employee e = snapshot.getValue(Employee.class);
                    for (String cert : e.getCertifications()) {
                        if (cert.equals("java"))
                            return true;
                    }
                }
            }
        
            @Override
            public void onCancelled(DatabaseError error) {
                // Failed to read value
                Log.w("W", "Error", error.toException());
            }
        });
 
     
    