Using Common Data for a Website and Mobile App

Pin It

Web Mobile Database
Data is the main driver behind any application be it a desktop, mobile or web app. The developer of an application builds it around how users interact with data. Data keeps track of entities and actions within an app.

Having recently moved into the mobile app development space, I had to answer several questions on how I would structure the apps that I develop. This meant having to actually develop apps to get the answers.

In software development, there is no other way; you learn by doing. It is not enough to just take courses or go through tutorials. You have to get your hands dirty and build apps for yourself as if you were building them for an actual client.

One of the challenges I faced was using a common database for a website and mobile app. This is an important challenge to solve because, if a client has a website, it is likely that they would require a mobile app as well. And I had to be prepared.

Different Databases And Frameworks

Even if a website and a mobile app are for the same business concept, the implementation is completely different. Despite their similarities in functionality, completely different technologies have to be used for each.

For instance, I would build a website using the Laravel Framework. Laravel is a fluent framework based on PHP and it uses a MySQL Database. On the other hand the mobile app would be built using Flutter with Dart language and uses an SQLite database.

You can see the problem, right? There are actually two issues. The frameworks are different, which means that the website cannot directly interact with the app and vice versa. Even if the communication between frameworks was possible, the databases used by either are incompatible.

What is needed is an approach that allows for the website and mobile app to use a common database. The ideal is to have the website as the main database and then build an interface to allow the mobile application to access the same data.

The Dilemma of Two Databases

A database is a very important element of a website or a mobile app. It enables persistent storage of data. When you leave a website or an app and then later come back, your data is still there, thanks to a database.

Having a separate database for a website and another for the mobile app would mean that if you interact with one and then move to the other, you would lose your data and have to start all over again. This is far from ideal.

A database is also essential for storing user data. If there is no common database it means that users who register on the website will find themselves not registered on the mobile app and also vice versa.


The best solution to using common data for a website and mobile app is the implementation of a RESTful API. REST stands for REpresentational State Transfer. It is a way of creating Web services. API Stands for Application Programming Interface.

When creating a REST API, guidelines on how data should be accessed and manipulated from the server are established. These guidelines specify the structure of the commands to request and manipulate specific data.

The key element in the REST API setup is that all data is returned in JSON. JavaScript Object Notation (JSON) is an open-standard file format or data interchange format that uses human-readable text to transmit data objects consisting of attribute-value pairs and array data types.

What this means is that data obtained from a MySQL database server, for example, which exists as tables of data can be transferred as a JSON formatted text string to the mobile app. The mobile app achieves this by processing the JSON received from the REST response.

This elegantly overcomes the challenge of having two different databases each on the website and the mobile app. Hence the website can maintain its database and transfer its contents to the mobile app which can then optionally store the data in its own database for cases where the mobile device is not online.

Of course, the RESTful API Also provides a mechanism for the mobile app to write data to the website database. With that, common data is shared and maintained between the website and mobile app.

Pin It