Back
Chapters

What is CRUD

Search icon
Search Book
⌘K

In the software development world, CRUD consists of four operations - create, read, update, and delete.

  • Create: This operation would create a brand new entity. In terms of database, this would be INSERT statement.
  • Read: This operation would read something from the database and would not make any permanent changes to the database. In terms of database, this would be a READ operation.
  • Update: This operation would change an already existing entity. In terms of database it would be an UPDATE operation.
  • Delete: This operation would delete an entity. In terms of database this would be a DELETE operation.

CRUD in action

In Rails each resource typically performs these seven operations:

VERBURI PatternController#ActionUsed forOperation
GET/booksbooks#indexList booksREAD
POST/booksbooks#createCreate a bookCREATE
GET/books/newbooks#newForm for a new bookREAD
GET/books/:idbooks#editForm for editing bookREAD
GET/books/:idbooks#showShow info about bookREAD
PATCH/books/:idbooks#updateUpdate info about bookUPDATE
PUT/books/:idbooks#updateUpdate info about bookUPDATE
DELETE/books/:idbooks#destroyDelete info about bookDELETE

As we can see each of those seven actions could be assigned to one of these four operations - Create, Read, Update and Delete.

REST and CRUD

REST is an architectural system that deals with data through HTTP protocols. More info about REST is here.

Typically software applications create RESTful APIs to handle CRUD operations. More info about CRUD operations is here.

There aren't any changes to the application in this chapter. So let us clean up any accidental changes.

1git clean -fd