I'm working on a client's Point-of-Sales (POS) software. I was going to use django with MySQL but the client can't pay for a host, so I decided to write it in Java with Firebase. I'm having some trouble thinking in terms of Firebase coming from MySQL.
According to the Firebase documentation, to do relations like I would in SQL, it would have to look like:
inventory : {
CD001 : {
genre : {
"CLASSICAL" : TRUE
}
}
genre : {
CLASSICAL : {
Name : "CLASSICAL"
inventory : {
CD001 : TRUE
}
}
}
Whereas in SQL I would just put the genre primary key
as a foreign key
in inventory. Is there a better way to do this in Firebase? It seems for every product that has the genre CLASSICAL
I would have to make two updateChildAsync()
. Also, any changes (like removing a genre from inventory) I would also have to loop through two DatabaseReference
.
If I were to use push
to get the generated primary key
it would be even worse because I would have to loop through each child just to get the genre
name.
I know this may not be the optimal way to make a POS, but given the constraints of the project and that I like learning new stuff, I'm going to stick with it.