Firebase与MySQL数据库(分层/关系)

时间:2021-10-13 16:54:42

I am fairly new to Firebase, I have some knowledge of databases because I have worked with MySQL before but reading the benefits of Firebase and what it has on offer - real-time database, login (auth), analytics etc.

我是Firebase的新手,我对数据库有一定的了解,因为我之前使用过MySQL,但是阅读了Firebase的优点及其提供的功能 - 实时数据库,登录(auth),分析等。

I am looking to implement Firebase into the project I am working on. Whilst MySQL is a relational database, through my search I found (I believe) Firebase is a hierarchical database because of the how it structured database like a JSON-tree.

我希望将Firebase应用到我正在进行的项目中。虽然MySQL是一个关系型数据库,但通过我的搜索,我发现(我相信)Firebase是一个分层数据库,因为它的结构数据库就像JSON树一样。

Following the correct way of development, I would like to draw ERDS and database tables to get an idea of how my project will communicate with the backend. However, I am not quite sure how I can represent the data structure using these mediums because in SQL you would have primary keys and foreign keys linking tables. Is this the case for Firebase as well?

按照正确的开发方式,我想绘制ERDS和数据库表,以了解我的项目如何与后端进行通信。但是,我不太确定如何使用这些介质表示数据结构,因为在SQL中,您将拥有主键和连接表的外键。这也是Firebase的情况吗?

For example, in MySQL the table would look like: Firebase与MySQL数据库(分层/关系)
The ERD would like like:

例如,在MySQL中,表格看起来像:ERD喜欢:

Firebase与MySQL数据库(分层/关系)

My questions are:

我的问题是:

  • Am I correct in saying Firebase is a hierarchical data structure?
  • 我说Firebase是一个分层数据结构吗?
  • How can data be represented in ERD and Database tables to show the data structure of firebase?
  • 如何在ERD和数据库表中表示数据以显示firebase的数据结构?
  • Does Firebase uses primary and foreign keys like in MySQL
    If so, are these represented in the same way like in when designing ERDs and tables for MySQL database?
  • Firebase是否像MySQL一样使用主键和外键如果是这样,它们是否以与为MySQL数据库设计ERD和表格时相同的方式表示?
  • How / what is the best way to structure data in Firebase and show these in ERD and tables?
  • 如何/什么是在Firebase中构建数据并在ERD和表格中显示这些数据的最佳方法?

I am new to Firebase, so any help would be nice. Thanks.

我是Firebase的新手,所以任何帮助都会很好。谢谢。

1 个解决方案

#1


6  

This is an incredibly broad topic, as can be seen by the fact that you have four questions in a single post. I recommend watching our Firebase for SQL developers series and reading NoSQL data modeling.

这是一个令人难以置信的广泛主题,可以从一个帖子中有四个问题的事实看出。我建议观看我们的Firebase for SQL开发人员系列并阅读NoSQL数据建模。

A few quick answers:

一些快速回答:

  • Firebase is indeed a hierarchical data structure: it's really just a JSON tree in the cloud.
  • Firebase确实是一个分层数据结构:它实际上只是云中的JSON树。
  • there is no defined way to display hierarchical data in an ERD. It's more common to show a JSON tree.
  • 没有定义的方法在ERD中显示分层数据。显示JSON树更常见。
  • Firebase has the concept of keys, which are the names of the nodes that you store data under. You could somewhat compare those to the primary keys of a relational database. But there is no concept of a managed foreign key.
  • Firebase具有密钥的概念,密钥是您存储数据的节点的名称。您可以将它们与关系数据库的主键进行比较。但是没有托管外键的概念。
  • as your second question: it is a common practice to model your Firebase database as JSON, which is quite convenient as that's also the format that the database stores.
  • 作为您的第二个问题:将Firebase数据库建模为JSON是一种常见做法,这非常方便,因为它也是数据库存储的格式。

#1


6  

This is an incredibly broad topic, as can be seen by the fact that you have four questions in a single post. I recommend watching our Firebase for SQL developers series and reading NoSQL data modeling.

这是一个令人难以置信的广泛主题,可以从一个帖子中有四个问题的事实看出。我建议观看我们的Firebase for SQL开发人员系列并阅读NoSQL数据建模。

A few quick answers:

一些快速回答:

  • Firebase is indeed a hierarchical data structure: it's really just a JSON tree in the cloud.
  • Firebase确实是一个分层数据结构:它实际上只是云中的JSON树。
  • there is no defined way to display hierarchical data in an ERD. It's more common to show a JSON tree.
  • 没有定义的方法在ERD中显示分层数据。显示JSON树更常见。
  • Firebase has the concept of keys, which are the names of the nodes that you store data under. You could somewhat compare those to the primary keys of a relational database. But there is no concept of a managed foreign key.
  • Firebase具有密钥的概念,密钥是您存储数据的节点的名称。您可以将它们与关系数据库的主键进行比较。但是没有托管外键的概念。
  • as your second question: it is a common practice to model your Firebase database as JSON, which is quite convenient as that's also the format that the database stores.
  • 作为您的第二个问题:将Firebase数据库建模为JSON是一种常见做法,这非常方便,因为它也是数据库存储的格式。