Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using OneDrive or Dropbox as a database

First off, this is not a duplicate of any of these questions, which discuss using a single Dropbox account as the backend of a multi-user app

I have built a handful of apps, mostly on Windows Phone and Windows Store, and have lots more in the works.

I often find myself wanting to add data synching to these apps, between devices but for the same user. My apps are often free or very cheap, and I can't afford to fork out money for a database hosting server. I do have a paid hosting account with some limited DB space I could use, but in the (unlikely) event that one of my apps becomes a runaway success I'm suddenly stuck with a large hosting bill. In that case I'd have to suddenly start charging users a recurring amount for apps that were previously free, or worse, already paid for.

I keep coming back to this idea of using OneDrive, or Dropbox, or some other free cloud hosting as a database. Here's how I see it working.

Lets say we have a todo app called Jobbie

  • User installs Jobbie on both devices
  • User logs into OneDrive on both devices, creating a "jobbie" sync folder in their OneDrive folder
  • On Device A, User creates a new todo item "pick up dry cleaning"
  • Device A uploads a text file to OneDrive with the name "20153001-pick_up_dry_cleaning.item".
  • Device B scans the folder, finds a new file, and adds it to local database
  • On Device B, User marks "pick up dry cleaning" as "done", and the file is renamed to "x20153001-pick_up_dry_cleaning.item" (or deleted)
  • Device A scans the folder, sees the item has been renamed (or deleted) and removes it from local database

The obvious problems I see with this approach are

  1. items are limited to 255 - 9 characters (9 reserved for xYYYYMMDD), unless you want to download each file which would be quite slow
  2. there's no locking

Other than these two issues, are there any other problems I might face implementing such a system?

PS: I have also considered overwriting a stored SQLite file with a local copy but I figure this would be too much data overhead for a mobile device

UPDATE

I've accepted Peter Nied's answer below, which pointed out the issues I might encounter with such a system, which answered my question. However, Smarx pointed out in the comments that Dropbox has a free datastore API which I can use for my apps. This seems like a far better solution than trying to implement my own datastore on top of the file system, so I'm going with that.

UPDATE 2

The Datastore API was deprecated just 3 months after I updated the post, so its no longer available. Luckily I hadn't started developing against it at that point. You can use Dropbox as a standard flat-file storage very easily, but if you want to do any kind of sync you'll have to roll your own

UPDATE 3

June 2021

I did build something akin to "Jobbie" for personal use, but I ended up storing data in a text file using the Dropbox API, similar to how Todo.TXT works.

My Mobile app on Android (VueJs / Cordova) syncs my content changes to Dropbox, and then on any laptop I can open up the txt file in any text editor and make changes if I need to. It works very well for my use case.

Once or twice I've had the text file open in an editor with autosaving enabled (some markdown editor on Mac) and I have lost data when the latest version was overwritten with an older copy, but using Dropbox revision history it was easy enough to recover data.

If you're building a lightweight app and need to sync simple data between devices on the cheap, this works.

like image 495
roryok Avatar asked Jan 30 '15 10:01

roryok


People also ask

Is Dropbox a database?

Dropbox is the most popular cloud storage system on the market and it continues to improve its features. Dropbox allows users to move files, such as images and video, off their computers and onto a database in the cloud. Furthermore, it lets users save space and share files quickly.

Can you create a database in OneDrive?

Create a Virtual MySQL Database for Microsoft OneDrive Data Login to Connect Server and click Databases. Select "Microsoft OneDrive" from Available Data Sources. Enter the necessary authentication properties to connect to Microsoft OneDrive. OneDrive uses the OAuth authentication standard.

Can I run an Access database from OneDrive?

Unlike other MS Office programs like Word and Excel, OneDrive does not even offer an ability to open an Access file that is in OneDrive cloud, only to download.

Is OneDrive a database?

OneDrive for Business Limitations and Restrictions For those of you who may know SharePoint well, its content repository is actually an MS SQL Server database. So, OneDrive is actually SQL Server exposed via SharePoint which in turn is exposed via a Document library which makes it look like a file/folder structure.


1 Answers

While OneDrive and DropBox have ways to store file information and ensure some level of consistency with Etags/Ctags, building on top of of these file based systems would be hard to offer data-partitioning, transactions, and conflict management. It would be cool, but I doubt it would be cheap (time-wise) or bug free.

Using services that are already built to offer you the functional for data storage would be your best bet. There are multitudes upon multitudes of services that would give you database access to your information store. such as offerings from Microsoft's Azure product line, Amazon's AWS and many others that specialize in keeping data in sync across multiple platforms.

like image 55
Peter Nied Avatar answered Oct 15 '22 13:10

Peter Nied