Android-迁移到会议室数据库

时间:2019-06-18 04:37:16

标签: android database android-room android-architecture-components

我需要从Sqlite数据库迁移到我的应用程序中的房间,但是在迁移之前,我有一些疑问,我已经搜索了许多站点,但是我对恢复房间数据库的性能却不满意。

  1. 我的表架构将通过API调用频繁更改,这可能在房间里吗?

  2. 我们需要实体以实体名称映射列名称,因为我的表架构经常更改,我如何创建实体?

  3. 是否可以将多列映射到实体中的单个字段属性,例如 表A具有三列COL_A,COL_B,COL_C

{
	"_id" : ObjectId("5d07685b964f7400e4de0382"),
	"name" : "Item1",
	"status" : "BOOKED",
	"products" : [
		{
			"status" : "Available",
			"internalName" : "Product1",
			"Name" : "ProductName1",
			"benefits" : [
				{
					"someProp" : "BenefitProp1",
					"internalName" : "BenefitName1",
					"cost" : [
						{
							"amount" : "100",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "200",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				},
				{
					"someProp" : "BenefitProp2",
					"internalName" : "BenefitName2",
					"cost" : [
						{
							"amount" : "300",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "400",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				}
			]
		},
		{
			"status" : "Available",
			"internalName" : "Product2",
			"Name" : "ProductName2",
			"benefits" : [
				{
					"someProp" : "BenefitProp3",
					"internalName" : "BenefitName3",
					"cost" : [
						{
							"amount" : "100",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "200",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				},
				{
					"someProp" : "BenefitProp4",
					"internalName" : "BenefitName4",
					"cost" : [
						{
							"amount" : "300",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "400",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				}
			]
		},
		{
			"status" : "BOOKED",
			"internalName" : "Product3",
			"Name" : "ProductName3",
			"benefits" : [
				{
					"someProp" : "BenefitProp5",
					"internalName" : "BenefitName5",
					"cost" : [
						{
							"amount" : "100",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "200",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				},
				{
					"someProp" : "BenefitProp6",
					"internalName" : "BenefitName6",
					"cost" : [
						{
							"amount" : "300",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "400",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				}
			]
		}
	],
	"tripId" : 3
},
{
	"_id" : ObjectId("5d07682c964f7400e4de0381"),
	"name" : "Item2",
	"status" : "Available",
	"products" : [
		{
			"status" : "BOOKED",
			"internalName" : "Product4",
			"Name" : "ProdcutName4",
			"benefits" : [
				{
					"someProp" : "BenefitProp7",
					"internalName" : "BenefitName7",
					"cost" : [
						{
							"amount" : "100",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "200",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				},
				{
					"someProp" : "BenefitProp8",
					"internalName" : "BenefitName8",
					"cost" : [
						{
							"amount" : "300",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "400",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				}
			]
		},
		{
			"status" : "BOOKED",
			"internalName" : "Product5",
			"Name" : "ProductName5",
			"benefits" : [
				{
					"someProp" : "BenefitProp9",
					"internalName" : "BenefitName9",
					"cost" : [
						{
							"amount" : "100",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "200",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				},
				{
					"someProp" : "BenefitProp10",
					"internalName" : "BenefitName10",
					"cost" : [
						{
							"amount" : "300",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "400",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				}
			]
		},
		{
			"status" : "Available",
			"internalName" : "Product6",
			"Name" : "ProductName6",
			"benefits" : [
				{
					"someProp" : "BenefitProp11",
					"internalName" : "BenefitName11",
					"cost" : [
						{
							"amount" : "100",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "200",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				},
				{
					"someProp" : "BenefitProp12",
					"internalName" : "BenefitName12",
					"cost" : [
						{
							"amount" : "300",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "400",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				}
			]
		}
	],
	"tripId" : 2
},

{
	"_id" : ObjectId("5d0767d6964f7400e4de0380"),
	"name" : "Item3",
	"status" : "BOOKED",
	"products" : [
		{
			"status" : "BOOKED",
			"internalName" : "Product7",
			"Name" : "ProductName7",
			"benefits" : [
				{
					"someProp" : "BenefitProp13",
					"internalName" : "BenefitName13",
					"cost" : [
						{
							"amount" : "100",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "200",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				},
				{
					"someProp" : "BenefitProp14",
					"internalName" : "BenefitName14",
					"cost" : [
						{
							"amount" : "300",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "400",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				}
			]
		},
		{
			"status" : "Available",
			"internalName" : "Product8",
			"Name" : "ProductName8",
			"benefits" : [
				{
					"someProp" : "BenefitProp15",
					"internalName" : "BenefitName15",
					"cost" : [
						{
							"amount" : "100",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "200",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				},
				{
					"someProp" : "BenefitProp16",
					"internalName" : "BenefitName16",
					"cost" : [
						{
							"amount" : "300",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "400",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				}
			]
		},
		{
			"status" : "Available",
			"internalName" : "Product9",
			"Name" : "ProductName9",
			"benefits" : [
				{
					"someProp" : "BenefitProp17",
					"internalName" : "BenefitName17",
					"cost" : [
						{
							"amount" : "100",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "200",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				},
				{
					"someProp" : "BenefitProp18",
					"internalName" : "BenefitProp18",
					"cost" : [
						{
							"amount" : "300",
							"isUsed":0,
							"currencyCode" : 1
						},
						{
							"amount" : "400",
							"isUsed":1,
							"currencyCode" : 2
						}
					]
				}
			]
		}
	],
	"tripId" : 1
}

是否可以在房间中创建上述实体? 任何人都可以消除以上疑问吗?

0 个答案:

没有答案