Simple MySQL database questions - Database per user of application? - android

Currently I have developed an android application that uses a local sqlite database per installation. The database comes pre-populated with static tables, and the entire point of the application is to allow the user to assign dates/comments with the pre-populated information in each table.
I am looking to bring this online, and move the database to a mysql format, allowing access via desktops and other mobile devices. Is the best way to handle this to assign each new user a new database?

I would strongly avoid creating multiple databases, and instead add relationships to the existing database structure you have with a users table. Each user has an association to each existing object. Keep in mind sharing with other users in the event that you may want to allow one user to see another user's info.
My suggestion is provide an update to the app where after the first launch after updating it pushes their information to your MySQL database and inform the users that they can access their data via other methods now.

how many user to you expect? I would use only one database with a user table instead of hundreds/thousands of databases.

One table for all users (only with user info like id, email, password, etc).
Another table with comments (with user id and his comment), so that you can add as many comments per user as needed. If dates are related to comments put them on this table, else another table for dates as well.

Related

SQLite DB problem when we use different accounts in single app with same device

It's not a code problem but it's just by my curiosity.
I am making an application that can be logged in by social login, and also email login.
In my application, I plan to use some SQLiteDatabase to save simple datas.
However, when I just save it with A account and login with different account, won't there be conflict because its the same device and server is not intervened with it? How do you know it's different account when its the same device, one application?
Think its sort of a silly question maybe, but if there's a way that everyone uses to solve it, I would like to know.
There can be two cases -
You want to use same database for different users -
In this case, there is no problem as your SQLite database gets saved in your app's /data/data folder which will be always accessible from inside your app.
You want to use different database for different users -
In this case, you have to add user_id column in all the tables of your SQLite database, and based on your user_ids, you can do your database actions like query, deletion, etc

Copy data from website to realm database

My app needs to use data from different websites. On these websites, there is a search with different chemical ingredients.
How can I programmatically copy this data from website to my realm database?
This database on Realm needs to be saved as a table which has 2 columns: ingredient name, description.
First of all, create an ID for each ingredient, receiving ID, Ingredient, Description. It's the best way to avoid conflict.
Second, you need to assemble a crawler, and this goes beyond your android application, maybe a network service that can be done even in java, identifying the information on each site and inserting into your database. So doing turn your android application get this information from the site.

Sqlite database with android - local?

I have an android app that I have been working on and I created a sqlite database using the android.database.sqlite package. I know that you can access that data by using Android Studio manually, but I am trying to save data into the database so that if one user of the app does something to add to the database, another user of the app will have the same access to the database. Will the android.database.sqlite package allow this or will the database for each user be unique to that user? If this is the case in which all users cannot access the same database after updating, what is the best way to go about creating a database that would let every user access it even when updates occur?
It is possible to add multiple users to a local application. Here is the simplest way to accomplish this:
1) Create a table for users in your database, with a user ID
2) Every user specific value in other tables should be marked to corresponding users with this ID
3) When you fetch the data from database, use the Select statement specifying user
Tip: Android has an Object-Relational-Mapping Library called Room for making database creation simpler. Reading about Room would help too! Take database classes for gaining knowledge about such common tasks.

One mysql database per user with thousands of users

I have an Android app and i want to allow my users to sync their local sqlite db with server.Since i have thousands of user's how should i set up my MySql database on server?As i see it there are two approaches,
1) One database per user plus one database to store user's credentials.Is this even possible since there will be thousands of different databases on server?
2) One database that holds all user's data.I was thinking i could add a field (user_id) on each table that identifies a user.I don't like though the idea that all user's data will be on the same table!!!
What's the best approach for my case?Is there something different i could try?
One database that holds all user's data.I was thinking i could add a field (user_id) on each table that identifies a user.I don't like though the idea that all user's data will be on the same table!!!

Database Structure Differences between Web & Mobile Development

I would like to know the difference between the structure of database on mobile (Eg; SQLite) and the structure of database on web.
For example, on mobile app development, the database table related to
user will only have one row. But, in web (back-end), there would be
many row for user table. So, even though we only have one row, we
still keep creating the user table in SQLite ?
In my App, all the data are coming from Web Services. And I would like to support full offline support. So, it is like i need to create SQLite structure and tables for everything I received from web services.
The other data are making sense. But, for user, there gotta be some
logic in here to for that specifically. I need to store every data I
am storing in my web-services. But, still, it feels wrong to create a
user table which will only have one row in any given situation.
Let's say in Facebook App. News Feeds are storing in database table. But, how they store the logged in user info for offline ? By creating a user table with only one row ?
NO, If I was to do something like that, then the db on the app would be quite different from what is on the server.Things to consider:
On server your user db stores many different users details like name, age, location, phone number etc. While on app you really don't need all the users, but just the current user's details.
If it was something like facebook then On server I would have users tables, photos, friends, posts, etc. On server all the users posts, comments, photos would be saved BUT on the apps end I would only have the currently logged in user details. The tables doesn't need to be the same, you could have less tables on the app.

Categories

Resources