I have an Angular JS JSON client interface that interacts with the JAVA / MySQL stack. Since MySQL is an RDBMS, all my data is normalized (the first three forms, of course).
My question can be illustrated by the following example.
I have an Example object and a User object returned by the server.
Example - [{ userId:1, ... ... .. }, { userId:2, ...}, { userId:3, ...}]; User - [ { userId - 1, firstName - "John", lastName - "Doe", .. }, { userId - 2, firstName - "Jane", lastName - "Doe", .. }, {...}... ]
When I look at the Example collection using Angular "example_entry in the example" and display the elements of the Example collection, I only have userId. But if I want to display firstName and lastName, I canβt do it like in another collection βUserβ. I have to write an Angular controller / service helper method to get the name firstName, lastName from the user collection and associate it with the objects in the Example collection.
To avoid this problem, I could De-Normalize Java Ojbects and send ready-to-use JSON like this.
Example - [{ userId:1, firstName - "John", lastName - "Doe", ... ... .. }, { userId - 2, firstName - "Jane", lastName - "Doe", ...}, { userId:3, ...}];
But is it good / bad / terrible? Since my Java domain objects now have firstName, LastName is duplicated in the Example object as well as in the user object. Any advice which route is better?
De-Normalize and have ready to use JSON Keep Data Normalized to avoid duplication and write converter methods on the Client as needed