I have a desktop app that uses sqlite db.
I am in a dilemma. When the app runs for the first time, should it run a ddl script to create a new database or should I just ship a template database and use a copy of it as a new datab开发者_如何学编程ase?
Which method is better?
Thanks.
The question does not have a single good answer, you can provide a ddl script, OR a template empty database, both these solutions are OK from a software engineering point of view in my opinion, just go with what you are easier with. With a large DB for which running lots of DDL takes time going with a template db is advantageous. Also the template db approach is easier I believe.
I'd go with a DDL script. Then, during application start up, you can always check if the database is there and create it if needed. That way your application can re-initialize itself if the user deletes part of their configuration (i.e. deletes your SQLite database).
精彩评论