How to perform a crud with firebase?

Asked

Viewed 389 times

-1

I read an article about Firebase, I thought it was wonderful what in theory you can accomplish. I would like your help because I want to create a CRUD, only I have always used Mysql. For the little I understood uses JSON ( NO-sql).

How can I create this manually in NO-sql in the JSON file? I wanted to mount such a table in CRUD, example:

ID Nome_Produto   Unidades
0  carro             1   
1  carro2            3  
2  carro3            5    

If you can guide me some reading material to understand more about Firebase (database) would be great, I thank you already!!!

  • There is a sequence of videos with excellent explanations about this: Click [here](https://www.youtube.com/watch?v=noB98K6A0TY "Getting Started with the Firebase Realtime Database on the Web, Part 1")! And the documentation also [here](https://firebase.google.com/docs/database/web/start "Firebase Database ")!

  • https://firebase.google.com/docs/? hl=en The firebase documentation itself teaches everything very easily and intuitively

1 answer

1


Hello, first of all, you should forget the logic of working in SQL databases and go on to interpret the instances of the classes in which it works directly, this is the logic of nonrelational databases of document type (eg: Firebase, Mongodb, Mariadb, etc...).

When working with this type of database, objects are instantiated directly, according to their elements. In the case of firebase (which is your choice) it does not allow working directly with arrays within objects, instead it allows you to define the Keys for a parent object in an orderly fashion. The result would be something like this:

{
  "carros": {
    1: { "nome": "carro", "unidades": 1 },
    2: { "nome": "carro2", "unidades": 3 },
    3: { "nome": "carro3", "unidades": 5 },
  }
}

With this structure, you no longer need to keep the "id" of the table within the object because it is only a relational index and is no longer a logical reference. If it is necessary to use, firebase allows, in the query you tell it to also send the key $keyfor your object, which will be identified directly as if it were your "id".

I advise you to start studying No-SQL because from now on it is the future regarding the storage of data in question at cost/benefit. Even well-used and robust databases like Oracle and MS Sqlserver are not comparable to No-SQL databases when you have massive data processing and a large mass of simultaneous connections.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.