Nick89
Nick89

Reputation: 2998

How do I structure my Parse data in the new Firebase?

I am probably like many others, who has recently been learning to code in Swift, and was learning to also use Parse as a backend database.

I have recently decided that before launching my app, I want to explore Firebase, and I feel that this may be the better option for my app. Also, as Parse is shutting down it's services, I think this makes most sense.

From what I understand, Parse is a Relational Database, and Firebase is non-relational. And right now, I'm struggling to see how I can build what I already have in Parse, into Firebase.

To breifly explain my Parse set up:

  1. I have several classes, 2 of which are called Reviews, and Votes_Up

enter image description here

  1. The reviews class simply holds info about films that I have manually added. It also keeps a count against how many people have voted up or down for that particular film.

  2. Votes_Up class is more relational. It records which logged in user is voting up for which film.

As Firebase doesn't seem to have this Table structure but instead uses JSON trees, I'm struggling to work out how I will create my database in Firebase, and still create the same features I currently have. (In where I can show individual users which films they have voted for etc)

Can anyone help and give an example using my current Parse database classes, and how I would structure this in the new Firebase?

Upvotes: 0

Views: 390

Answers (3)

ThierryC
ThierryC

Reputation: 1794

To complete the others answers I suggest this structure:

• Film
    o  CRxIO5xmJ8
            DateReleased: "2015-12-29T09:15:50.165Z"
            filmName: "Money Monster"  
            usersVoteFor
                    cXcofgX0x6gNFOLMLnuq5BnkxV73: true
                    xxxxxotherUIDfromAuthentication: true

    o  w5PvtvNT1X
            DateReleased: "2015-12-29T09:15:50.165Z"
            filmName: "Captain America"


•   User
       o cXcofgX0x6gNFOLMLnuq5BnkxV73
             filmsVotedFor
                   CRxIO5xmJ8: true
                   w5PvtvNT1X: true
             username: zozo

       o xxxxxotherUIDfromAuthentication
             username: zaza

Upvotes: 1

Edison
Edison

Reputation: 11987

As you know the two PaaS platforms are totally different.

  • With Parse you create the tables/Classes on the web dashboard and then use the SDK in your mobile app to read/write.

Firebase uses a data structure implementation (JSON blobs).

  • Parse does not have a Web Socket framework which means you need to build it. With Parse you use the client/app to check the Parse tables to see if there's new data. This means with Parse there is a delay.

With Firebase they use Web Socket framework to tell you when data has changed. This means Firebase will notify all mobile apps/clients using the private specific key in their JSON that there is new data. Firebase is known to be more "real-time".

  • In addition they use completely different user authentication.

What you need is Firebase's Structuring Data Guide

Have you considered using Parse Server?

Upvotes: 0

ErstwhileIII
ErstwhileIII

Reputation: 4843

You probably should consider something like:

users
films
  user voted for 
reviewers
  film voted for

Upvotes: 0

Related Questions