我应该如何构造我的firebase数据(基础 - 运动数据)?
我已经使用Java创建了一个Android应用程序,并且使用了Firebase实时数据库。通过休息,我得到了JSON-DATA的城市。 “数据”的意思是:
- 基本数据例如城市ID,姓名或人口。他们很少改变。这在我的模型类“基础”中表示。
- (移动)数据每天都会改变。该课程称为“ CityData”。
基于目前是 citydata 的一部分:
public class CityData
{
private BaseData baseData;
private int cases;
//...
}
目前,我只能在今天请求数据。当我将CityData-Object保存在DB中时,看起来像这样:

我的下一步:在过去的7天中保存数据。但是:Firebase也将每天保存基本数据。 我可以防止此(=>仅在不存在时保存或在发生变化时更新时保存)? 否则,我必须更改数据结构。但是哪个最好的可能性? 我的第一个想法是:创建这样的两个单独的途径:

但是,我必须从CityData中提取基于基础,并每次加入它们,例如,当我需要城市名称时,通常是。这是最好的方法吗?这是我第一次与NOSQL一起使用,所以每一个帮助都很好!
I've created an android app with Java and I use a Firebase realtime-database. Via REST, I get JSON-data for cities. "Data" means:
- base data like the city-id, name or population. They rarely change. This is represented in my model class "BaseData".
- (movement) data which changes every day. The class is called "CityData".
BaseData is currently part of the CityData:
public class CityData
{
private BaseData baseData;
private int cases;
//...
}
At this time, I can only request data for today. When I save a CityData-object in my db, it looks like this:
My next step: Save the data for the last 7 days. But: Firebase would also save the base data every day. Can I prevent this (=> only save when not exists or update when something changes)? Otherwise, I have to change the data struct. But which is the best possibility?
My first idea: Create two seperate paths like this:
But then, I have to extract BaseData from CityData and join them every time, for example when I need the city name, which is often. Is this the best way? It's my first time with NoSql, so every help would be nice!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论