+ All Categories
Transcript
Page 1: Introduction to Firebase

INTRODUCTION TO FIREBASE

Mustafa Ş[email protected] Developer @ SONY GSI

Page 2: Introduction to Firebase

2

AGENDA What is Firebase ? Use Case Realtime Database Data Modeling Security Rules Pricing Conclusion

Page 3: Introduction to Firebase

3

WHAT IS FIREBASE?

«Firebase is a mobile and web application platform with tools and infrastructure designed to help developers build high-quality

apps»*

*https://en.wikipedia.org/wiki/Firebase

Page 4: Introduction to Firebase

4

WHAT IS FIREBASE?

A set of tools which provides a full suite for app development Ability to create applications with no server-side programming Backend as a Service

Page 5: Introduction to Firebase

5

HISTORY

Founded in 2011 by Andrew Lee and James Tamplin Initial product was a realtime database Over time it becomes a full suite for app development Acquired by Google in 2014

Page 6: Introduction to Firebase

6

WHAT IS FIREBASE?

*https://firebase.google.com/

Page 7: Introduction to Firebase

7

USE CASE – MOBILE APPUsually our architecture

DatabaseServer / REST APIDevices

*Icons made by Madebyoliver from www.flaticon.com

Page 8: Introduction to Firebase

8

USE CASE – MOBILE APP

*Icons made by Madebyoliver from www.flaticon.com

Access via REST or SDK

Page 9: Introduction to Firebase

9

FIREBASE REALTIME DATABASE

Initial product and the heart of the Firebase platform After a database update, new data is synchronized across all clients within milliseconds NoSQL Json Database

Page 10: Introduction to Firebase

10

FIREBASE REST

Firebase can be used as REST endpoint (append .json to the URL) Usage of HTTP methods (GET, POST, PUT, PATCH, DELETE) as usual Provides a set of Query parameters

Page 11: Introduction to Firebase

11

FIREBASE SDK

Page 12: Introduction to Firebase

12

SDK - READ DATA (ON – METHOD)

Event based query system Provides different event types Listens for data changes at a particular location Callback triggered for the initial data and whenever the data changes

Page 13: Introduction to Firebase

13

SDK - READ EXAMPLES

Page 14: Introduction to Firebase

14

SDK - READ DATA (OTHER METHODS)

’’once’’ Method Access like ’’on’’ method – but just one callback and not keep giving updates

’’off’’ Method Detaches a callback previously attached with ’’on’’ method

Page 15: Introduction to Firebase

15

SDK – WRITE DATA (PUSH METHOD)

Most common pattern for adding data Generates a new child location and returns its Reference Uses a unique key based on current time Because of the unique key, data is chronologically inserted

Page 16: Introduction to Firebase

16

SDK - WRITE DATA (OTHER METHODS)

’’set’’ Method Overwrites any data at given location and all child locations

’’update’’ Method Used to selectively update only the referenced properties at the given location

Page 17: Introduction to Firebase

17

SDK - WRITE EXAMPLES

Page 18: Introduction to Firebase

18

SDK - WORKING OFFLINE

Offline read and write data possible There are two offline modes Short term

Local in-memory cache Long term

Disk persistence Works on Android and IOS

Page 19: Introduction to Firebase

19

USE CASE

We are going to build a mobile application We have entities like User, Channel, Follower, ...

One user can have many channels Each channel only belongs to one user

One channel can have many followers Each follower can follow many channels

Page 20: Introduction to Firebase

20

DATA MODELING - NESTED NODES

Might be exactly what we need When we need channels always with full follower information

But Firebase is always loading all json There is no way to exclude properties

Page 21: Introduction to Firebase

21

DATA MODELING - THE ELEGANT WAY

Add indexes to resolve two-way relationships Association properties of the relationship could be saved as the value of this node

Page 22: Introduction to Firebase

22

DATA MODELING

Keep in mind – It’s a JSON tree Avoid nesting data Flatten data structures Create data that scales

* https://firebase.google.com/docs/database/web/structure-data

Page 23: Introduction to Firebase

23

SECURITY RULES

Default rules are too open Access to everything even if signing in anonymously

Mindfully data modeling is essential for real life rules Important rule types .read .write .validate .indexOn

Page 24: Introduction to Firebase

24

SECURITY RULES - EXAMPLE

Page 25: Introduction to Firebase

25

PRICING

*https://firebase.google.com/pricing/ December, 2016

Page 26: Introduction to Firebase

26

SOME FIREBASE CUSTOMERS

* https://firebase.google.com/customers

Page 27: Introduction to Firebase

27

ALTERNATIVES

Page 28: Introduction to Firebase

28

IN CONCLUSION

Get fast in action Easy to use But sometimes we just need server-side code It is hosted Data needs to be well structured

Page 30: Introduction to Firebase

THANK YOU!


Top Related