Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 176313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:51:15+00:00 2026-05-11T13:51:15+00:00

RESTful design seems to advocate flat or shallow structured representations (at least when resources

  • 0

RESTful design seems to advocate flat or shallow structured representations (at least when resources are represented as XML). A resource representation should contain just the resource, which the URI identifies. I’m wondering when it is sensible to present resource’s sub-resources within the parent resource?

To elaborate, consider this: Company may have multiple employees. Usually this situation would probably be designed as two separate resources, company and employee, where employee would be company’s sub-resource.

/company/acme/ /company/acme/employees/ /company/acme/employee/john 

With this URI design, company representation should include links to its employees, but the XML representation probably would not include emplyoyees per se.

Therefore, when does it make sense present sub-items through the parent? And is there a situation where it would be sensible to present sub-item only through their parent. I mean that there would be no URI for sub-items at all. They could be reached only through the parent resource.

<company> <name>Acme</name>  <employees>   <employee>John</employee>   <employee>Jack</employee>  </employees> </company> 

Is it sensible to offer only one method to access a resource: if a parent exposes its sub-items, can there be an explicit URI for the sub-items too? So, if the company’s XML contains company’s employees, would it make sense to offer /company/acme/employees URI dispite that you can get the same information through the company resource?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T13:51:16+00:00Added an answer on May 11, 2026 at 1:51 pm

    If the sub-resource only makes sense in the context of its parent, then yes, it should be returned nested within its parent. For instance, in HTML, an <li> element doesn’t make sense as a sub resource on its own.

    However, if a resource can stand alone, and you are going to want to manipulate a resource independent of any other resources, then it should have its own URI. That way, you can POST or PUT to that resource without affecting other related resources, and without having to parrot them back to the server. If you had to manipulate everything from the parent, think about what happens if one person does a GET, modifies one sub-item, and then does a PUT of the whole thing with that sub-item changed; what if someone else changed one of the others in the meantime? Then you need to be adding locks and transactional semantics, which defeats the whole statelessness of REST.

    For GET requests at least, it is likely to be a good idea to have some form of bulk query interface, by which a client can get a large number of resources at once; having to do a new HTTP request for each resource can take a long time, since it means a new round trip over the network for each GET. It may make sense to have bulk update functionality as well. But if you are going to want to be able to manipulate one resource at a time, you need to provide a URI for that one resource.

    And yes, it’s perfectly fine to have more than one way to access resource. You can think of it like a blog; you can get stories on the main page, or on archive pages, or by going to their permalink.

    edit: If you want to to a bulk update without running into the problem of having one client give stale data to the server, you basically have two options:

    1. Locking. One client tells the server ‘I want a lock on this whole set of data’, fetches the data it wants to modify, modifies the data, sends it back to the server, and unlocks it.
    2. Optimistic concurrency: The client downloads the set of data, which is marked with some sort of revision tag which the server changes every time it gets new data. The client modifies it, and sends it back to the server. If any of the other data in the set has been modified in the meantime, the revision tag will be out of data, and the server will respond with a ‘sorry, your data is out of date, try again.’

    These each have advantages and pitfalls. The problem with locking is that it is stateful, and so doesn’t fit into a REST architecture very well. If the client program crashes or otherwise dies while it has the lock, then that data will be permanently locked unless you have some kind of lock timeout, which can get tricky. Locking can also lead to deadlock if the clients are doing some kind of fancy transactions that involve multiple locks.

    The problem with optimistic concurrency is that if there is a high load on a data set, with a lot of clients changing it at once, it can take many, many tries before a given client can post its data; in fact, a slow client may end up being completely cut off from posting updates because other clients continually change the data in ways that mean that the slow clients changes always fail.

    You’ll need to decide for yourself which of these options suit you. These issues also come up when changing a single resource (one update may clobber another), but when you aggregate resources into a bulk interface, they are going to come up a lot more often. That’s why I would recommend having two interfaces, if you’re going to aggregate resources; one in which the resources can be accessed individually, and an optional bulk interface where many resources can be read and written at once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 78k
  • Answers 78k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Thanks for the pointers everyone, I've managed to come up… May 11, 2026 at 3:56 pm
  • added an answer If you are using SSL, noone can intercept the request.… May 11, 2026 at 3:56 pm
  • added an answer I thought this was a pretty elegant way to do… May 11, 2026 at 3:56 pm

Related Questions

I've been researching WADL and am wondering why it isn't more widely adopted? With
I'm looking for a light version of REST for a Java web application I'm
I am currently struggling with a design issue involving REST. The application I am
I can't seem to find a true restful Blog API - are there any?

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.