Where to put user database

Windows Platform: The application I am working on creates a database. On the first time the application is started I ask the user if where they want the database created. The user can select a “local install” where the database will be created on the local disk, or, the user can choose “network install” and they can point to a network drive.

Because of Window’s user accounts for the “local install” I was thinking of asking the user whether they want all users of this PC, or only current user to be able to access the database. If they choose “all” I will create the database in the Shared Application Data, if they choose current user then I will create the database in the Documents folder. Regardless of the option they choose, I write a simple text file in the Shared Application Data folder that contains the path to the location where the file is located.

One problem; The Shared Application Data (c:\Program Data) is a hidden folder. IF the user ever wants to move this file, or include it in a back up they may not be able to locate the file. This could get confusing for the user.

I understand it is not recommended to create files in the directory where the application is running, which of course would be the easiest.

What are the best practices here? Suggestions?

I ran into that problem long time ago in the VB6 version of my product. Program Data is the recommended location, but when users had to do anything manually with the file (because of an issue or something they wanted to do themselves), it was painful to help some of them find the file(s).

So the next year I ended up putting an entry in My Documents\\Database and sticking them there. Yeah I know, everyone complains about the clutter in My Documents, but at some point I can’t spend all of my time helping users locate files, and I have quite a few users that I deal with on a regular basis. AND one issue with that in a corporate setting: the IT department can move the users My Documents folders off the local drive and onto drive on a server and the database connection can get slow or not be available if not connected to their network. But most of my customers are consumer level, so I rarely run into that issue.

I would not recommend putting it with the executable which should go in \Program Files\… Not only is it not recommended, If the permissions are set tight enough you won’t be able to write to a file in your folder under PF.

I’ve never understood the logic of Windows hiding Program Data by default because you want to shield the contents from users, but making Program Files visible. Probably some reason for it, but I could give a rats rear; following the recommended placement of the database files in \Program Data\… was a support nightmare for that one year.

Yes, this file is hidden by default. So is AppData (the user-specific folder). And so is ~/Library on OS X. It seems the OS vendors don’t want user’s monkeying around with stuff there.

Regardless, those are the recommended places for saving many types of app data.

If the user may need to move or backup that data, then you could add those capabilities to your app.

Or if the data really is more like a document, you should probably prompt the user to choose their own specific location.

Thank you for the responses and input. I just wanted to make sure I wasn’t missing anything…

Warning: Shared application data is read only when UAC is turned on.

If that is the case then is it acceptable to write directly to the directory in which the application is running? Or, what is the other recommended location all users can access the data? (I can limit access within the application using passwords, etc.)

I see two possible configurations:

  1. User can select “my documents”, but may not understand that other users of the same computer will not be able to access that location.
  2. User will want to select a location that is accessible by all users. This seems like it should be SharedApplicationData but you’ve mentioned that this is read only if UAC is on which obviously would cause a problem. If it is read only, how can it be “Shared”?

In your install script create a folder in the root of the C: drive and place your data in that.

MS Logic?

You can also implement a backup option for users in app’s preferences, which essentially asks the user to choose a folder, and then keeps that folder in sync with the main app data.

Remember to implement a restore option too.
That way the user can choose to keep a backup of his app data into his MEDIAFIRE or MEGA folder (if they use that cloud services), and the app data is synced with their cloud account, and once they do a clean reinstall of their OS, they can safely and easily restore all their app data without getting their hands dirty and fooling around with the OS’s hidden app data folders.