Saturday, March 30, 2019
SQL to Firebase A Metamorphosis
SQL to Firebase A MetamorphosisAbstract Firebase is world extensively utilise in cross-plat urinate apps for dis a kindred functionalities, iodine of them being Realtime Databases. This paper luxuriouslylights how an RDBMS found informationbase such(prenominal) as MySQL stool be converted to a JSON based Firebase Realtime Database for easier readability, multi-device entropy access and manipulation, and stain shop for a centralized selective informationbase. Although MySQL follows a schema for the information and stores education in the form of tables and relations, Firebase stores information in a JSON tree. Conversion of data from the former to the latter depends on how the diligence queries the database. The paper covers the three grassroots queries Insertion, Retrieval and cutting out of data.Keywords-Firebase JSON Objects MySQL Realtime Database With the app market booming and proving to be lucrative, many products and platforms ar being launched to make the p rocess of developing and maintaining these apps simple. Firebase, which is adept such example, is a demoralize based platform for mobile and web application development. It provides backend as a service 1 that includes analytics, real time database, remote configuration for apps, driving force notifications, multiple authentication types, hosting platform and Admob-which allows developers to monetize their apps by displaying advertisements to name a few. Notably, Firebase is expanding to become a unified app platform for android and iOS. Firebase allows developers to build high quality apps and mix and match the features available to meet their requirements. It is owned by Google and a host of new features were introduced recently in May 2016. 2The real time database (a NoSQL database) provided by Firebase is what forms the basis of this paper. Data is stored as JSON (Java Script Object Notation) bearings and synchronized in real time to every connected client and stay availabl e stock-still when the app goes offline. 3 It is designed in such a direction that only operations that potbelly be executed quickly ar allowed which alters a great real time experience. The firebase storage is built for app developers who extremity to store and serve user generated content, and is backed up by google cloud storage, a powerful, simple and cost effective bearing storage service.We forthwith turn to comparative databases, arguably the closely popular kind of database, even today. Data is stored in tables (combination of rows and columns). The concept of schemas is implemented in relational databases. 4 outline is the blueprint that defines how data is organized. SQL databases atomic number 18 strict to ensure integrity unless lack flexibility. It notify be difficult when initially developing because one might be unaw be of the schema. Once the schema is decided, the developer necessitate to formula accordingly. This can be tedious as designers argon st rictly hold by the schema. A NoSQL database, like the firebase database is schema-less which in turn provides a spate of flexibility. In summary, relational databases be inflexible but they provide data integrity whereas NoSQL databases are flexible but the data integrity is left(a) to the developer.The Firebase database stores data in the form of a tree. The root node can be compared to the database in case of RDBMS. The root node can giftl multiple squirt nodes as shown in figure 1.Figure 1 Structure of a Firebase DatabaseThe small fry nodes in turn can amaze multiple child nodes and so on. Data, as mentioned before is stored as a key value pair. To access a value, this tree needs to be traversed. 5Neelima Kuderu in her paper proposed Schema-Migration and Mapping Framework to deliver developers for automatically migrating relational databases to NoSQL while preserving the semantics of the original database 6A B M Moniruzzaman in his paper provides furcateification, char acteristics and evaluation of NoSQL databases in Big Data Analytics. The study also provides an independent consciousness of the strengths and weaknesses of various NoSQL database approaches to supporting applications that process huge volumes of data as fountainhead as to provide a global overview of this non-relational NoSQL databases. 7Siim Plangi describes what Backend as a helping is, its advantages, disadvantages. Analysis of one such platform was performed with respect to an Android application and it is concluded that using such platforms is a great way to get down development time and resources. 8Ryan Thompson in his paper approachs to determine the sustainability of cloud storage We also get an overview of evolution of cloud storage moving into the hereafter, and attempt to determine whether integrations into cloud storage can be relied upon to transport lively information. 9Navdeep Singh in his paper introduces everyone with Google firebase API and its features. 10 Mital Potey in his paper discusses the study revealing that database oversight becomes considerably scalable, flexible and efficient when traditional relational databases are complimented by a specifically designed set of alternative databases such as NoSQL, NewSQL based systems. 11Keith W. HareKeith W. Hare in his paper reviews the features common to the NoSQL databases and compares those features to the features and capabilities of SQL databases. 12This section highlights the characteristics of Firebase that are not existent in MySQL.Real-time Multi-user AccessThe application is designed such that multiple people are able to access a centralized database simultaneously. The challenges that arise with maintaining a consistent state are interpreted care of. There are protocols in place in the font of a conflict. Rollback functions are implicitly called in the event of association loss or drop to the database. 13B. Cloud AccessData in all of its forms such as text and images are c apable of being stored on the cloud. Since the cloud is the point of access, the database is readily available everywhere, provided the user has the compensate permissions. In the event that the application is offline, the last synchronized copy of the database is used by the application, hence aiding responsiveness. Once access is regained, the database synchronizes again with the main online database.Cross-Platform APIFirebase can be integrated into various platforms that the application is built upon. Hence if one user records in the database, the updates are conveyed to all other uses, be those users are on an iOS, Website or Android platform. The APIs are bundled onto a case-by-case SDK hence the enabling the developer to focus less on the infra social system and much on the customers needs. 14Online StorageFirebase takes care of storage hence the data is hosted by them. This saves the developer from high investments on hardware for storage and the physical space busy by it . In some scenarios, this is a vulnerability since the user does not have real custody over the data stored online. In most data-insensitive cases, this fact is overlooked by the user.Firebase, like any other form of service has its fair share of shortcomings. Various application developers have communicate out elucidating the specific issues they have faced while incorporating it. Here are a few common complicationsA. High pricing with scalabilityFirebase charges a fee for the services it provides based on the number of simultaneous connections, size of the data stored, bandwidth per month and automatic backups 15. Free of charge services are modified up to fifty connections and a hundred megabytes of storage.B. You dont own your dataThe data that is stored on the database is not owned by you. The bane being that actions such as exporting of the complete database cannot be performed by the user alone. Although this is likely by contacting the Firebase team to do it for you. 16 T he boon is highlighted in section leash (D).C. Relations are proven to be tediousDue to the structure of Firebase Realtime-Database, formation of relations has proven to be a nightmare to most developers. This is evident and problematic only when the amount of data is scaled multi-folds. disrespect all these limitations, Firebase continues to be used extensively to build Minimum executable Products (MVPs) and first working prototypes at Hackathons and large scale integration by major application enterprises.The section provides an insight as to the conversion of SQL queries to Firebase code. Since Firebase is a multi-platform supported tool, the code is expressed in terms of the logic and algorithmic program for easy transitioning into the respective programming languages.A. Data InsertionIn MySQL, an doorway into the database1 takes place with a interrogative such as- INSERT into EMPLOYEES- (UID, Name, Department, Salary)- determine- (25412, Ajay Patel, Marketing, 45000)Figur e 2 A single inlet into a SQL DatabaseThis aim tuple can be represented in Firebase by administering the following algorithmAn voice of the database is retrieved by first initializing an object of the Database point of fictitious character. The instance stores a repair (usually in the form of a URL pointing to the online reference of the Database) returned by methods of a Firebase object.Now an instance is take to reference the immediate child of the database. another(prenominal) object of the Database Reference is initialized to the stead of the child.The child is extraordinaryly place by the name (key)given to it.In this case, the first immediate child is the table we are querying, i.e.- Employees.The location is returned by the method of the instance created to reference the database earlier.Once an instance of the table is created and initialized, multiple instances are required to query the attributes of this table.One reference each is initialized using the name to i dentify each attribute of the child.The location of each of them is returned by the method of the instance created in step 2 for the table we are querying.Finally, each of these references are used to set the in demand(p) value required by the user.A methodunder each of these references are called and the in demand(p) value is passed as a parameter to the method.A visual histrionics of the Firebase structure in figure 3 is a tree with Employees as the parent that represent the table and the tuple as a child with the unique reference (in this case, the value 25412). UID is a primary key constraint in the MySQL database. Along the same lines, Firebase uses a key value (in this case UID = 25412) to unequivocally identify a child of the parent Employees. As envisioned, MySQL stores the data in the form of rows and columns, whereas Firebase employs a JSON tree format.Figure 3 Firebase representation of a single entry.In the case of multiple entries, MySQL uses the query aforementione d, multiple clock to enter the data. The resulting table is shown in figure 4.Each call counts to a single tuple containing the information required to query it.Figure 4 triplex tuples in a MySQL DatabaseSimilarly, multiple children are entered into the Firebase database one tuple at a time. Each tuple is encapsulated in the form of a single JSON (JavaScript Object Notation) object. This is similar to the insertion query in MySQL except the tuple is a single object passed to the database reference.Conversion of tuple data to a JSON object is done using a concept in OOPs (Object Oriented Programming System) called POJO (Plain Old Java Object) class 17. The data is passed to the getter methods of the object created for that class, each of which is defined for the attributes.Once the values of the object are set, the object is passed to the reference defined earlier and the database is updated.Note that each object holds only the attributes of a single tuple.Figure 5 multiple childre n in Firebase Structure.B. Data RetrievalIn MySQL, data can be retrieved using the select literary argument. Constraints can be defined in the statement to show only a certain tuple(s). The following query displays an take as shown in Figure 6.-SELECT * from EMPLOYEES WHERE UID=32121Figure 6 Retrieval of a tuple based on condition in MySQL.Firebase provides the functionality of triggering a certain argument of methods that notifies the application when data is modified. The method used for this feature takes the location of the child to be monitored and is termed as a listener. The sequence of data retrieval is as followsThe listener is defined from the Firebase reference created previously. The listener has various methods available that enable the developer to employ them for other functionalities.Under the method that is implicitly called whenever a child is added, one of the parameters is the data snapshot that is downloaded from the cloud. utilize this data snapshot, the chi ldren are identified using their unique IDs and subsequently stored onto variables such as Strings and integer values.Figure 7 Retrieval of child node with UID = 32121.C. Data DeletionMySQL makes use of DELETE FROM along with a where clause to determine the entry to be deleted. The following query results in a database as depicted in Figure 8.-DELETE FROM EMPLOYEES WHERE UID=63212Figure 8 Resultant database later on the query is performed.The equivalent of the function in Firebase is as follows.The Firebase reference of the child that needs to be deleted is determined beforehand by identity of the unique ID.Using this reference, a method used to delete the complete child and its reference is called.All the attributes and children under this reference are re flowd.Figure 9 Firebase database after the entry is deleted.Firebase continues to be the leading BaaS for cross-platform applications that require a real-time database hosted on the cloud. Features and updates are continuously being introduced by Google to overcome the few flaws exhibited by it. Applications built on relational databases that are looking to move to the cloud now have the ability to do so.Firebase has a maturation support on various mobile platforms such as iOS and JavaScript based web applications. According to the official Google Blog 18, a few of the future goals of the platform include- lower and simpler pricing, Android and iOS SDKs (Software Development Kits) receive constant offline support and a much-improved UI (User Interface). Overall, Firebase will hopefully continue to provide developers with the tools and support required to radically change how app development is done.Acknowledgment (Heading 5)We would firstly like to convey Prof. H D Phaneendra, Head of the Department of Computer Science and Engineering, NIE, Mysore for openhanded us support and opportunity to work on this paper. We would also like to thank Prof. M.J. Yogesh, Department of Computer Science and Engineeri ng, NIE for his vital insights and guidance. We also deform our warm regards to all the faculty members of the department for their constant encouragement and invaluable advice.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment