SQLite Database – Best Practices for File Storage

designsqlite

I'm writing an application for learning foreign words of exactly one language (english at the moment), which has currently an ineffective design.

I use Java and SQLite-jdbc for saving the words. After starting, the application downloads a comma separated wordlist and inserts each value pair into the Database. I hosted the wordlist on an extra github repository, because i thought I shouldn't store the database file inside the development git repository – its binary, so everytime I do sth with the database, the hash of the database file will change. I don't like that, because then Id have to create unreadable commit messages, and the actual change to the database would be hard to understand.

Therefore my actual question: Is there a more elegant solution of saving the DB file than saving it inside the git repo? Should I simply store the current database file on another filehost? What are the best practices for such a situation?

Best Answer

Store the words using a text format, and build a database during the build.

Instead of storing the information in binary format and storing the binary file in the version control, keep the pairs in a CSV file. This allows you to easily change it, commit the changes and, later, diff the changes with ease.

Later, when you actually need this data in a database, do a bulk insert from the CSV file. This can be done during a build or deployment. By the way, SQLite has a feature which makes it possible (and more importantly fast) to import data from CSV files.

Related Topic