Tag Info

Hot answers tagged

4

I think you are starting from the wrong end. API design is about what the client/requester requires not about how you represent the data internally. If the client need the category name then just provide it along with the id (if its useful to the client). As a Post belongs to only one category there is no reason to have anything other than a flat structure. ...


3

Structurally, I would reconsider the notion that a post belongs to a category. That's a strange way to model the relationship, especially considering a post very well may form a relationship with multiple categories. So in my mind a post has multiple categories. As @James Anderson initiated, you shouldn't think about your API as a result of your persistence ...


1

While I agree with James, sometimes for whatever reasons you may want to have objects, so as to have a better representation of the actual data. In those cases, there are two considerations: Having just CategoryId, if you laways or almost always need the name, will require another request; Having both options is pretty useless since Post.CategoryId is not ...



Only top voted, non community-wiki answers of a minimum length are eligible