Advice on the data model that I'm using

I’m working on an application that has been going OK, but I’ve now hit a wall. It feels to me like one of the problems comes down to the fact that the JSON nodes have no identifiers. This makes it hard to keep track across the whole JSON structure when I want to make changes to nodes, particularly if it gets big (and it does).

Is there a way to associate an identifier with a JSON node so that I can change the node name without losing track of its child nodes?

The more I look into this the more I’m wondering whether I have picked the wrong data storage model for this application. Though I’m no fan of relational databases, is this maybe a case for tables, rows and columns? Or would a MongoDB document allow me to do the sort of querying, tracking and editing that I want to do (I’m think this because Mongo uses JSON IIRC)?

Any advice would be appreciated. I’ve been working on this idea for quite a while and it’s a little frustrating to have uncovered such a serious problem at this stage.

An example of the JSON I’m creating is below. It shows a couple of options between which I want to make a choice, together with some relevant parameters and the objective and personal scores for each parameter. The scorecard value is arrived at by some maths using the scores.

Thanks,

Ian.

{
	"Easter eggs" : {
		"M&S" : {
			"Cocoa content" : {
				"IndependentScore" : "59",
				"MyScore" : "90"
			},
			"Cost" : {
				"IndependentScore" : "48",
				"MyScore" : "40"
			},
			"Scorecard Value" : "59.25"
		},
		"Hotel Chocolat" : {
			"Cocoa content" : {
				"IndependentScore" : "80",
				"MyScore" : "93"
			},
			"Cost" : {
				"IndependentScore" : "15",
				"MyScore" : "40"
			},
			"Scorecard Value" : "57"
		}
	}
}

If your json gets big and complicated then it’s time to switch to a relational database. Your problems will collapse as soon as the data is in a database.

1 Like