我刚开始使用NoSQL结构,特别是使用Firebase,这与MySQL或理性数据库有很大的不同。
我正在开发一款能够列出体育游戏的应用程序;用户可以检索所有游戏的列表并选择他们想要参与的游戏。
在2012年,2013年,2014年,2015年,2016年(现在),2017年(未来)等游戏的游戏列表中,或者至少将持续多年,等等...
我的MySQL表中的表结构具有以下主键组合(gameid,yearid,sportType);原因是每个新的一年而不是仅仅增加游戏玩法,它将重新启动1,需要年份才能使其成为唯一的sportType,因为它可以输入棒球,足球,曲棍球等......
我创建了JSON结构,我想我正在质疑自己并且需要帮助,如果你能检查它是否是非规范化的,或者我是否能以某种方式改进它?
我认为我遵循理性方法,但我想有以下几点:
{
"games" : {
"gameid" : {
"desc" : "Week 1 ",
"teamid" : 123
"sportType" : "football",
"year" : 2016
etc...
它遵循我为MySQL做的主要索引,但我需要的是问题!?我想我不是,但是因为我是新手,我想要其他的意见......
我在想我应该遵循:
time = [0,0.166666666666667,0.333333333333333,0.500000000000000,0.666666666666667,0.833333333333333,1,1.16666666666667,1.33333333333333,1.50000000000000,1.66666666666667,1.83333333333333,2,2.16663888888889,2.33330555555556,2.49997222222222,2.66663888888889,2.83330555555556,2.99997222222222,3.16663888888889,3.33330555555556,3.49997222222222,3.66663888888889,3.83330555555556,3.99997222222222,4.16663888888889,4.33330555555556,4.49997222222222,4.66663888888889,4.83330555555556,4.99997222222222,5.16663888888889,5.33327777777778,5.49997222222222,5.66661111111111,5.83327777777778,5.99994444444444,6.16661111111111,6.33327777777778,6.49994444444444,6.66661111111111,6.83327777777778,6.99994444444444,7.16661111111111,7.33327777777778,7.49994444444444,7.66661111111111,7.83327777777778,7.99994444444444,8.16661111111111,8.33327777777778,8.49994444444445,8.66661111111111,8.83325000000000,8.99991666666667,9.16658333333333,9.33325000000000,9.49991666666667,9.66658333333333,9.83325000000000,9.99991666666667,10.1665833333333,10.3332500000000,10.4999166666667,10.6665833333333,10.8332500000000,10.9999166666667,11.1665833333333,11.3332500000000,11.4999166666667,11.6665833333333,11.8332222222222,11.9998888888889,12.1665555555556,12.3332222222222,12.4998888888889,12.6665555555556,12.8332222222222,12.9998888888889,13.1665555555556,13.3332222222222,13.4998888888889,13.6665555555556,13.8332222222222,13.9998888888889,14.1665555555556,14.3332222222222,14.4998888888889,14.6665555555556,14.8332222222222,14.9998611111111,15.1665277777778,15.3331944444444,15.4998611111111];
Abs=[0.0756333346168200,,0.0822666635115941,0.101066668828328,0.125066662828128,0.147433335582415,0.169966672857602,0.192199997603893,0.211166655023893,0.231433339416981,0.256133330365022,0.279866663118203,0.295566670596600,0.309466672440370,0.323400000731150,0.335233343144258,0.348299992581209,0.359700001776218,0.371433332562447,0.383333327869574,0.394433322052161,0.404166663686434,0.413666687905788,0.423499998946985,0.432733344535033,0.443266667425633,0.453899989525477,0.463699989020824,0.475066669285297,0.485300009449323,0.495999989410241,0.504966656366984,0.514033327500025,0.523766654233138,0.532566664119562,0.541033337513606,0.550333333512147,0.559733323752880,0.567733330031236,0.575466672579447,0.583399988710880,0.591433353722096,0.597833327949047,0.604699979225794,0.610233349104722,0.616733354826768,0.622800009946028,0.628666676580906,0.634199996789297,0.638966679573059,0.644799992442131,0.650733329355717,0.654566655556361,0.661333315074444,0.666366661588351,0.671233326196671,0.675699991484483,0.679433315992355,0.682733337084452,0.686333330969016,0.689166650176048,0.693133344252904,0.697366672257582,0.699333322544893,0.702233329415321,0.705400002499422,0.707699996729692,0.709999985992909,0.711533337831497,0.712800003588200,0.713633326192697,0.714666672050953,0.714533333977064,0.713999989132086,0.714266665279865,0.714066684246063,0.714266670246919,0.713733327885469,0.713066659867764,0.712200003365676,0.711600005626679,0.710400002698104,0.710399977862835,0.709799999992053,0.708366667230924,0.706933336953322,0.706766667465369,0.706199998656909,0.704266687234243,0.703333348035812,0.702399998903275,0.701133318245411,0.700166669984659,0.698799995084604,0.697700018684069];
u=linspace(0,15.49986111,500);
v=pchip(time,Abs,u);
p0 = [0.075633335,0.05,0.01]; %First value = Abs value at t=0
options=optimset('MaxFunEvals',10000,'MaxIter',5000,'Display','iter');
[p,error,residual]=lsqcurvefit(@gompertz,p0,time,Abs,[],[],options)
syms x t
f=p(1)*exp(-exp(((p(2)*exp(1))/p(1))*(p(3)-t)+1));
f1=diff(f,t); %Find first derivative of equation W wrt t
f2=diff(f,t,2); %Find second derivative wrt t and to allow inflection point to be defined
crit_pts = solve(f1); %Find local maxima and minima
crit_pts=double(crit_pts);
flimit = limit(f,inf); %Find find horizontal asymptote of function f by taking limit of f as x approaches infinity
function_horizontal_asymptote=double(limit);
有人可以帮我指导一下吗?!
答案 0 :(得分:1)
我认为你是在正确的道路上。但是如果你有一个像teamDetail这样的对象,你应该移动详细信息,将其指向teamDetail。
{
"games" : {
"gameid" : {
"desc" : "Week 1 ",
"teamid" : 123
"sportType" : "football",
"year" : 2016
"teamDetail": {
"name": team1,
"country": c1,.. etc
}
etc...
上面针对teamDetail对象的非规范化版本。
{
"games" : {
"gameid" : {
"desc" : "Week 1 ",
"teamid" : 123
"sportType" : "football",
"year" : 2016
"teamDetail": {
"team1id": true,
"team2id": true, ...etc...
}
etc...
teamDetails:{
"team1id": {
"name": team1,
"country": c1,.. etc
}
"team2id": {
"name": team2,
"country": c2,.. etc
}
}
所以我想你想要概述以下内容:
{
“团队”:{
“teamid”:{
“名字”:“等等”,
“teamcity”:“L.A。”
等等...并且在游戏中JSON引用teamid以获取团队细节,但是将其作为实际游戏定义的一部分包含在内,因为它将被重复,并且在实例中团队更改名称或城市必须是游戏的所有条目都改变了吗?我这样做是对的!?