We are creating an app where the teacher can create his class register, and it should look like that:
Teacher creates his profile, after that there is an activity with RecyclerView
that displays students names. Below RecyclerView
there is TextView
that says "Student! create your own profile" (ofcourse after clicking it, there is an activity for creating students profile). Student can create his profile only by using the same device as teacher while he was creating Teachers Profile. Ok, that looks nice and so far we have it all done, but here comes our question. What is the best behaviour to store users data in this case? Should we structure our data this way?
{
"Teachers" : {
"USYSacnOjDR5EAPwljZMHtggN9I2" : {
"teachername" : {
"teachername" : "Janis"
},
"students" : {
"0xgMzfOLLwQ2KWF7aKhH5ZIbQnx2":{
"studentname": "Pavel"
}
}
}
},
So, this looks like veeery badly structured data, we know it, but like we said before, We need to display in RecyclerView
the names of this specific teacher students that are other FirebaseAuth
users and had their own datas like grades
Every opinion or critique is appreciated.
@Edit here is how i retrieve data :) reference=FirebaseDatabase.getInstance().getReference("teachers").child(teacherkey).child("users");
reference.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
User user = dataSnapshot.child("name").getValue(User.class);
result.add(user);
adapter.notifyDataSetChanged();
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
User user = dataSnapshot.child("name").getValue(User.class);
result.remove(user);
adapter.notifyDataSetChanged();
}