[英]For a production platform what is the best way to evaluate the level till which DB should be normalized?
[英]Which is the best way to use SQLite DB?
正在開發Windows Store 8.1應用程序。
我想在我的應用程序中本地保存一些數據,所以我使用SQLite創建了一個數據庫並在其中添加了一些表,並從代碼中添加了一些數據。
以下哪一項是最佳選擇?
1)首次通過代碼從代碼創建數據庫
2)在解決方案文件夾中的應用程序中附加具有預定義結構的DB文件。
請為我建議最好的解決方案。
對於我自己的應用程序,我使用第一個選項:首次打開應用程序時創建數據庫。
public MyAppDataContext()
{
connection = new SQLiteConnection(new SQLitePlatformWinRT(), Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, DATABASE_NAME));
Initialize();
}
private void Initialize()
{
connection.CreateTable<Foo>();
connection.CreateTable<Bar>();
connection.CreateTable<Bas>();
}
無需擔心每次應用啟動時都會不必要地創建表,因為SQLiteConnection.CreateTable
在幕后使用了create if not exists
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.