5

I'm developing a webapp where I have sets of data stored locally on my computer and I run a tool which transforms the data and uploads it to my webapp. However, I need to be able to rerun the tool on all the sets of data at once. The only option I have thought of is to associate the transformed object's reference in the database with the path to my file on my local computer.

The problems with this approach are apparent, however; for example, what if the file paths change and the database isn't updated?

Another approach is to store all of the data on a cloud server, however this makes it extremely complex to edit the data (download, edit, upload, test, etc).

I'm wondering how this is usually handled in a business environment and whether there are any other methods I haven't thought of.

7
  • So the set of data you are talking of is part of the source code of your application? Store where you store every other piece of source: in your VCS's repository.
    – Doc Brown
    Nov 20, 2016 at 20:10
  • @DocBrown No, this data is separate from the application. It populates the webapp. But I have to manually create this data and modify it, and sometimes I make changes to the way the tool transforms the data, which is why I'd like to be able to mass-update all the data
    – CC Inc
    Nov 20, 2016 at 20:16
  • So you (as a the developer, and not as a user) created this data, you modifiy it, you are responsible for it and it is needed to run the application. Sounds to my like there is not much difference between your source code and that data from the lifecycly perspective. If that is true, put it into your VCS, as I wrote.
    – Doc Brown
    Nov 20, 2016 at 20:44
  • 2
    Having your data stored in a VCS repo and use the repo path (relative to the repo root) as URN is probably more reliable than using a local file path.
    – Doc Brown
    Nov 20, 2016 at 21:01
  • 1
    Or add a guid to each input file and store the guid with the transformed data. Nov 20, 2016 at 21:54

2 Answers 2

5

Youre correct in suggesting you should probably avoid storing the full filepath in your database.

A solution to this is to store a relative path to the files in the database, and store the root file path as a configuration option for your application.

0

Absolute path should not be stored in the database. As you and others suggested what if the base path changes... I think you should have a service/class/method that knows the base path (from config) and given a file from the database it can give you the base path to the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.