You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

The simplest answer to this question is that a resource (aka web resource) is digital content returned by a server that is referenced by a URL.

If we want to dig a little deeper, there is a practical and academic answer to this question. Both are important.

The Practical Answer

Given that this question is being asked within the context of using OpenInsight as a source for RESTful APIs and that OpenInsight is primarily a database environment that is exposed through procedures that enforce business rules, a resource is most often derived from a database row. The specific column data contained in the resource and the format (e.g., JSON, XML, etc.) of the resource will vary based on other factors.

It is a mistake to relate resources to database tables too closely. Doing so will restrict your ability to expose resources in ways that might not fit well within your database model. Resources and databases should be loosely coupled so as to allow for the evolution of both without breaking how your APIs work.

Because resources are the most significant content returned from an API, we have provided the HTTP_Resource_Services module to help. By default, the SRP HTTP Framework returns resources in JSON format.

The Academic Answer

Let's also answer another question, "Why do we use the word resource?" The answer is because our method for referencing a resource, i.e., a URL, stands for Uniform Resource Locator. Since we are building web APIs that rely upon the standards for URIs (the generic of URL) and HTTP, we want to use the terms already employed.

According to the HTTP standards "a resource could be anything". The URI standards tells us that the term "is used in a general sense for whatever might be identified by a URI". While these might not seem overly helpful, they are very important to understand because this tells us that we should avoid pre-conceived notions of what a resource is or is not.

In our practical answer above, there is a warning about tightly binding resources to database tables. Resources can be abstractions of anything meaningful and are often aggregates of digital information that is pulled from multiple sources (which is why one-to-one relationships between resources and tables is discouraged). OpenInsight developers already have some direct appreciation for this concept: Calculated Columns. A calculated column provides a way for a table to draw information from other sources, whether they are other tables, OS files, or even data stored in other types of database servers.

  • No labels