Firebase database for SQL developers - Part 2

Converting your SQL database structure to a non-schema / JSON database like Firebase

I, :) welcome to the second part for my posts on Firebase database for SQL developers

Firebase database for SQL developers - Part 1

In this post am going to take a relational model that we can see in a SQL database and then convert that to a No-SQL database like the Firebase database

SQL

the image above shows an events table, speakers table and event_speakers table. event_speakers is the table that relates events table to speakers tables together with something called FOREIGN KEY

To retrieve data from the SQL database image above the query will go as follow

SQL

So to what we have been waiting for translating the relationship in a Firebase database type

With the Event structure in mind we will want to create a JSON like database for the relationship like this

{
  "Events": {
    "event_one": {
      "event_name": "Global event",
      "event_location": "Lagos Ikeja",
      "event_created": 16082017,
      "event_active": "active",
      "Speakers": {
        "0": "speaker_one",
        "1": "speaker_two",
        "2": "speaker_three"
      }
    },
    "event_two": {
      "event_name": "Developerlearn  friday session",
      "event_location": "Iwaya Sabo . Yaba",
      "event_created": 16082017,
      "event_active": "active",
      "Speakers": {
        "0": "speaker_one",
        "1": "speaker_two"
      }
    }
  },
  "Speakers": {
    "speaker_one": {
      "speaker_name": "Olatunde Owokoniran",
      "speaker_email": "hurlatunde@gmail.com",
      "event_created": 16082017
    },
    "speaker_two": {
      "speaker_name": "Femi Taiwo",
      "speaker_email": "dftaiwo@gmail.com",
      "event_created": 20082017
    },
    "speaker_three": {
      "speaker_name": "Mclord Adeola",
      "speaker_email": "mclord@gmail.com",
      "event_created": 22082017
    }
  }
}

Olatunde Owokoniran

Creating the world of ME with each code

Lagos, Nigeria hurlatunde.github.io