I'm developing real-time application on Android platform and I want to add a table with specific name and no information at first in Firebase database. Is it possible and how can I do it?
Firebase doesn't have the notion of 'tables' and there are no 'table names'
From the getting started guide from Firebase
All Firebase database data is stored as JSON objects. There are no tables or records.
So when developing your app it's important to understand the difference between NoSQL (JSON) databases and SQL.
Additionally, you can't really have a node in Firebase with no data.
So, you may want to re-think why you need a node with no information; as soon as you write information, the parent node will be created.
For example
define a user
public User(String name, String favFood) {
this.name = name;
this.favFood = favFood;
}
write some data
Firebase userToAddRef = ref.child("users").child("user_0");
User aUser = new User("Harry Nilsson", "Lime Coconut");
userToAddRef(aUser);
This will create the parent 'users' node and add a child node 'user_0' that contains a single child 'Harry Nilsson' and his favorite food.
{
"users": {
"user_0": {
"name": "Harry Nilsson",
"favFood": "Lime Coconut"
}
}
}
If you really NEED to have a node with no data, maybe as a placeholder (?) is to write the node so the end JSON structure would be
{
someNodeName: true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With