With diagrams: Commands, architecture and networking.

Image for post
Image for post
Photo by Toa Heftiba on Unsplash

Prerequisites:

  • None

Terminology

CRUD: The four basic functions of persistent storage; create, read, update, and delete

REST (REpresentational State Transfer): architectural style for providing standards between computer systems

REST

REST is a defining set of principles for developing an API. Uses HTTP protocols like GET, PUT, POST and DELETE to link resources to actions within a client-server relationship. The principles of RESTful architectures serve to create an application as a lighter weight alternative to SOAP. APIs may be web-based or designed for specific platforms such as Android or iOS, and a REST API makes it easy to implement other interfaces or applications over time which can turn an initial project from a single application into a platform.

The diagram:

Image for post
Image for post

The client may be a web browser requesting weather information in Washington i.e “washington” and receives a JSON string of [“16”]. REST API’s often use result codes (200 = OK; for example)

The client-server mandate

This shows there is a nature of separation between client and server. Services have multiple capabilities and listen for requests which are made by the consumer and accepted or rejected by the server.

Statelessness

Mandates the kinds of commands offered between the client and the server, which is initiated by the request. The request contains all the information necessary for the server to respond.

Cache

Server responses are either cacheable or not. A request can be cached by the consumer in an attempt to avoid re-submitting the same request twice.

Interface or uniform contract

RESTful architecture defines a Uniform Contract. This prohibits the use of multiple, self-contained interfaces within an API.

Layered system

Layers are discrete, and multiple layers are used to grow and expand the interface.

CRUD

CRUD is an acronym for CREATE, READ, UPDATE and DELETE. These form the standard database commands that are the foundation of CRUD, and CRUD’s origins are in database records now CRUD now has applications in the HTTP protocol, DDS and SQL.

CRUD can be thought of as a cycle rather than an architectural system.

  • POST: The client inserts or creates and object
  • GET: The client wants to read an object
  • PUT: The client wants to update an object
  • DELETE: The client wants to delete an object

Which is, of course, a typical use of CRUD

The diagram:

Image for post
Image for post

This diagram is based on tables (the following example is from iOS, although thinking of table rows as cells should not be too tricky). Note the first letter from each bullet point:

  • Create a new cell
  • Read a cell
  • Update a cell
  • Delete a cell

The principles of CRUD

Create
New records through INSERT statements.

Read
READ the data based on input parameters. RETRIEVE procedures grab records based on input parameters.

Update
UPDATE procedures modify records without overwriting them.

Delete
Delete procedures where specified.

Expanding CRUD: L
Sometimes CRUD is extended to CRUDL where the L stands for Listing. Listing helps with larger data sets that are not compatible with easy memory storage without resorting to pagination.

REST vs. CRUD

REST is a robust API architecture and CRUD is a cycle for keeping records current and permanent.

CRUD can be mapped to DDS, SQL and HTTP protocols. The HTTP protocols are a link between resources in RESTful architecture which is a core piece of REST’s foundation.

Mapping CRUD principles to REST means understanding that GET, PUT, POST and CREATE, READ, UPDATE, DELETE have striking similarities because the former grouping applies the principles of the latter.

CRUD is a cycle meant for maintaining permanent records in a database setting

REST is an architectural system centred around resources and hypermedia, via HTTP protocols.

CRUD principles are mapped to REST commands to comply with the goals of RESTful architecture

  • Performance
  • Scalability
  • Simplicity
  • Modifiability
  • Visibility
  • Portability
  • Reliability

These are the most basic functions of storage persistence, and are a good guide as to which features should be provided by your storage. It’s so common that people tend to implement CRUD without even thinking!

Conclusion

You’d be well advised to understand the difference between CRUD (or even CRUDL) and REST.
I hope this article has been useful in building your knowledge of these essential terms.

If you like it, why not hit me up on Twitter?

The Twitter contact:

Any questions? You can get in touch with me HERE

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store