Saturday, 9 May 2009

Cool URIs

When I design the use cases, I begin by listing the resources’ URIs for example in the Pizza Delivery use case:












../Customer/{Customer_ID}/has Address



Months ago, I had a discussion with my supervisor about the structure of the URI, should it be like this:{Order_ID}

Or like this: /{Order_ID} without the /Order/ Prefix.

We decided that the 2nd method was better, I believe the reason was that we wanted could have URIs in the following form Subject/Predicate/Object . But I think the problem was that we thought of URIs as an ID which is not the case. We initially thought of it the URIs way:{OrderID}/isOrderedby/{CustomerID}

But this isn’t quite correct because we are not using the whole URI for the Customer, to assert that an Order was ordered by him we need the customers’ URI not only the ID. So it should be like this:{OrderID}/isOrderedby/{CustomerID}

The reason I am going back to that is when I started implementing, I discovered that I need something in the URI to indicate what type of resource we are dealing with is it a Pizza, Customer or an Order? This indicator could be either something like /Order/{OrderID} or having a prefix to the ID like having all order ids starting with the characters “OID”.
Having a classifying URI is a requirement if I wanted to use existing REST frameworks. But even if I wanted to implement everything from scratch, how would my framework know where to forward an incoming request? For example if customer wanted to check the status of an Order with ID 12345 he would submit GET to

How would my framework know that this is an Order, not a Customer or a Pizza? Having an automatically generated stub for each dynamically created resource is not an option, so there must be a way to indicate which kind of resource this is. Maybe having an indicator in the URI is not bad.

I wanted to know the standard way to assign URIs, so I checked the W3C. In the document about Cool URIs for the Semantic Web, they used URIs in the following form

So to see if this is applied, I checked RKBexplorer, to see how they have been doing things. I checked for equivalent URIs -using their CRS- for Ian Millard a person that I’m sure is in the system. And these came up


I omitted the duplicates that had the same domain name because they used the same naming scheme. By checking the URIs we can see that it is a standard procedure to have an indicator in the URI to show what kind of resource it is.
There is something to watch out for however, if I want to adhere to Cool URIs for the Semantic Web, and that is the distinction between URIs for informational resources and non-informational resources. For more on that check

No comments:

Post a Comment