advice Question

Spring RESTful API based on many-to-many with JSON simple format

Avatar of dkim18
dkim18 asked on
JSONJavaREST* restful webservices
1 Comment1 Solution22 ViewsLast Modified:

Hi Experts,

I am working on simple Java Spring project that will serve as the base for a RESTful API. or


In the repository there are a and json data files which define sample Sites for this exercise. The files are located inside the project at main/resources/data:


  1. sites.json
  2. site_uses.json
  3. use_types.json


Here’s a visual of the data relationship:


  1. Implement a route to return a Site by id. Supplement the Site with its use-details:
    1. total_size, by summing the size_sqft associated with the site’s use(s).
    2. primary_type (an object with use_type id and name), where the primary type is the largest use_type (by size_sqft) in aggregate per-site.


For example, for site 1 (Measurabl HQ), there are four site uses: three offices with 3000 square feet each and one data center with 4000 square feet. This route should return:

"id": 1,
"name": "Measurabl HQ",
"address": "707 Broadway Suite 1000", "city": "San Diego",
"state": "CA",
"zipcode": "92101",
"total_size": 13000,
"primary_type": { id: 54, name: "Office" }

Note that office is the primary type because the total area for office is 9000 square feet (3 x 3000), compared to the 4000 of data center.

2. Implement a route which returns a list of all Sites.

3.  Implement a route to search Sites in a way you think might be useful. Returns a list of Sites.

4.  Implement a route to Create, Update, or Delete a Site or its Use.


Inserting the data can be done using any of the following approaches (dependencies already included in the project):


  1. Using JDBC
  2. Using Spring Repository pattern
  3. Using Hibernate
  4. Load the data using pure SQL derived from the above mentioned JSON files

My question is so far:

The relationship between 'site' and 'use_type' seems many-to-many. If so,  how does this 'site_use' come into play since all JSON format are simple? Any examples/tutorials out there?

Thanks in advance,


Senior Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros