Offline database in Expo - react-native

My users will be storing 10-500 records locally. I'm looking for a database with an offline-first approach that works with Expo.
Eventually the user will have the option to sync the data to an (undecided) online service. Looking for suggestions for this as well.
Users should be able to register an account to use online functionality such as syncing their data, uploading photos and viewing other users content. Offline functionality should work even without an account.
What are your suggestions for a database layer and the stack in general? Hoping to hear your suggestions.

As mentioned by Bruno Eduardo on the comments Expo comes with sqlite.
An example:
You import SQLite from expo:
import { SQLite } from 'expo';
You then can initiate a database like so:
const db = SQLite.openDatabase('db.db');
This would create the database in the local users phone.
From there you can query the tables you'd like to create and load with data like so.
db.transaction(tx => {
tx.executeSql('create table if not exists users (id integer);')
});
There are two approaches you can take (probably more but just two I'm thinking of).
You can query the data from an api so that it'll load it locally. Or the other option would be to copy a database with your data already setup to the device.
I need to mention there's a few problems with your approach. Best practice for many reasons, which I won't mention, is to use an api for data. If you're dealing with simple records the time to query an api is minimal. If the user is "Eventually the user will have the option to sync the data" then it might be best to consider working that out before you begin to build a local db.

Related

Firebase Big Query: How can I see realtime data in BigQuery?

I have a Firebase application which is uploading events with parameters. I need to be able to view those events in order to debug some issues we're having in production. I can only see the tables which are generated nightly in BigQuery. I can find references online saying that BigQuery allows viewing real time data. What I can't find is any straightforward instructions on how to create those views.
Is it possible? If so, can someone give me instructions that even a complete newb could follow?
We have decided to use the BigQuery APIs for information we want to see immediately in the database.

Join my app database with database from software

I have been hurting a wall for quite a while now, I am making an application linked to a software that we are using, which will allow the user to either access data from the software with my application and update data with my application on the software.
So here is the whole idea:
So my app will be linked to the software's database (Software Patient) with the help of foreign key (patientId on "App Patient").
And I need to be able to search for email, password, firstName, lastName, secretStuff directly from my app and be able to update data as well on both databases.
The biggest issue here is that I can't make a third table that merge all the data into one because the data from the software's database (Software Patient) will be updated quite a lot directly from the software by others people.
The current stack is composed of :
My application: Node.js with Sequelize, GraphQL & PostgreSQL
Software that we use: SQL Server Express
Thank you in advance!
The app you are developing must get data from your commercial Software Patient (we'll call it SP) system. That presents several questions. You really really need clear answers to these questions to finish designing the data flow in your app. Some of the questions:
How will your app get data from SP? Will you issue SQL queries to SP's database? Does SP publish an Application Programmer Interface (API) for this purpose? Or a data export function you'll use in you app's workflow?
Must your app's view of SP data be up-to-the-minute? Will an hourly update be enough? Daily?
Will your app change SP data, insert new data, or delete data in the SP system? If so see the first question.
Must you reverse-engineer SP, that is, guess how its data is structured, to make your app work? Or can you get specs / documentation from SP's developers?
If you update a reverse-engineered database, dude, be careful!
If your app will use SQL to get data from SP, it will send that SQL to SP's SQL Server Express database. nodejs has tooling for that, but both the tooling and the SQL dialect used in postgreSQL are different. Maybe it would be wise to use SQL Server throughout: doing so reduces the cognitive load on people who will maintain and enhance your app in the future. Neither they nor you will have to keep straight the differences between the two DBMSs.
If you'll use an API, great! That's a clean interface between two systems. (It will probably have some irritating and confusing bugs, so allow some time for that. I've had to send pull requests to several API maintainers.)
If you figure out the answers to these sorts of questions, you'll make a good decision about your question of the third table. It's impossible to address your specific third-table question without some of these questions.
And. Please. Don't forget infosec. You have a duty to keep personal data of the patients you serve away from cybercreeps.

Nativescript Offline Data

I'm quite new to NativeScript so I'm after some advice.
I've been looking at different back-end database solutions for the data. I've looked at firebase and while it does what it says on the tin I've come from am SQL relationship database background historically.
I've had a look and see that kinvey can connect to azure database (haven't tested this as yet)
I've looked at the azure database plugin but at present that doesn't support offline data.
Just wondering what other people have tried and recommend/stay away from.
Your use plugin nativescript-sqlite.

how to have database offline for iOS app

I would like to develop dictionary app for iOS application. and I am not sure which database Managment system should I use to store data. I want to my app to be offline so even user that don't have internet, they still can use my app. so my question which database should I use to store my database ? I research on google, it said sqlite. so if i store my data in sqlite so will my data in database sqllite will go with my app? thank
Yes, sqlite is your DB of choice unless you're just working with a couple of dozen records.
If you plan to use CoreData, you can also address sqlite with it.
If you don't plan to use CoreData, you can still use sqlite and work directly with the DB. There are good wrappers which help you, like FMDB: https://github.com/ccgus/fmdb

Xcode iOS phone directory app. core data, sql lite, or

as part of an application I am trying to create, I am looking to data storage solutions. However, I have found many solutions that I can not quite directly apply to the position I am in.
Basically, I want to display in my app, a directory of the staff of my organization. About 100 or so individuals. I want to have generic attributes such as name, email, office#, etc.
However, my goal is to not end up with a static representation of the staff here! (people come and go, switch offices,etc.)
I am looking for the best way (if possible) to maintain a small database that I can administer, and if perhaps, something were to change to someone here, I can make the change and the change will be reflected accordingly.
Please help! I tried submitting my first app but got rejected because I relied on a webview to accomplish this task. This is an internship opportunity and my first real chance at development. Any help will be GREATLY appreciated.
Thanks!!!!!
The iPhone directory app can be used to store data in any format you want (xml, json or a proprietary format), because all you do is save a file. But if you choose to use the iPhone app directory to store data you have to write code to read the file (very simple to do) and parse the information (not so simple because the dificulty scales based on the information complexity).
SQLite is a tool to store structured data, providing you a set of tools to access and use the information. You don't need to parse the information, because SQLite does it for you by using transact sql queries.
By now, because you have a list of individuals, and these people are relationed to offices, I think you should use SQLite.
The Code Data is a object graph management, it's a tool to give you more options over data manipulation, and can make your life very easy if you have a lot of data and very complex data models. I don't think you need that for your particular problem, but I think you should learn it at some point.
UPDATE 1
You application will have something like:
A core database (sql server, oracle, my sql, etc) will hold your individuals information (your cloud database).
A web page (php, asp.net, etc) will display the core database information in json or xml format (your api).
A iphone app will download the information from the web page and store it in the local SQLite. (you have to decide when you will update the local sql lite, like when is opened, once a week, once a moth, twice a day, etc) (your local storage method).
Display the local SQLite individuals information in the app.