Concepts / UPDATE: Modifying Existing Data

UPDATE: Modifying Existing Data

CRUD is an acronym representing the four fundamental database operations: Create, Read, Update, and Delete.

  • Programming

One Record, Four Possible Operations

A database application manages data repeatedly throughout the data's existence. A record may be added, retrieved, changed, and eventually removed. These four fundamental operations are known together as CRUD: Create, Read, Update, and Delete. The focus of this article is UPDATE, the operation used when an existing record is modified.

The Complete Data Lifecycle

CRUD provides a complete framework for thinking about data management. Create adds a new record, Read retrieves data, Update modifies an existing record, and Delete removes a record. Together, these operations describe how data moves through its lifecycle in database applications.

thenif changedview againwhen removedCreatenew recordReadretrieve dataUpdatemodify recordDeleteremove record
How do Create, Read, Update, and Delete connect to form the complete lifecycle of data in a database?

Consider a customer record in an e-commerce database. The record can first be created, later read by the application, updated when existing customer information changes, and eventually deleted. This example shows why CRUD is described as a lifecycle rather than as a single database action.

CRUD and SQL Commands

Each CRUD operation maps directly to a SQL command. This mapping connects the general idea of managing data with the concrete commands that databases understand and execute.

CRUD operationPurposeSQL command
CreateAdd a new recordINSERT
ReadRetrieve dataSELECT
UpdateModify an existing recordUPDATE
DeleteRemove a recordDELETE
maps tomaps tomaps tomaps toCreateINSERTReadSELECTUpdateUPDATEDeleteDELETE
Which SQL command corresponds to each CRUD operation?

What Changes During UPDATE

An UPDATE operation acts on data that already exists. The record remains part of the database, but one or more of its existing values are modified. The important distinction is that UPDATE changes an existing record; it does not represent the creation of a new record.

existing recordmodified recordCustomer recordexisting valuesUPDATEmodify existing dataCustomer recordmodified values
What changes in a database record when an UPDATE operation modifies existing field values?

Classifying a changed customer record

An existing customer record in an e-commerce database is modified.

Identify the record's status: The scenario says that the customer record already exists, so this is not a Create operation.

Identify the action: The record is being modified rather than merely retrieved or removed.

Map the operation to SQL: Modifying an existing record is Update, and Update maps to the SQL command UPDATE.

CRUD operation: Update. SQL command: UPDATE.

Choosing the Operation

To classify a data-management scenario, focus on the action being performed. Ask whether the application is adding a new record, retrieving data, modifying an existing record, or removing a record. After identifying the action, use the CRUD-to-SQL mapping to select the corresponding command.

ScenarioCRUD operationSQL command
A user retrieves their balanceReadSELECT
A new product record is addedCreateINSERT
An existing customer record is modifiedUpdateUPDATE
An email record is removedDeleteDELETE
Temperature data is retrievedReadSELECT
A new patient record is addedCreateINSERT

Classifying common data-management scenarios

EASY

Classify each scenario as Create, Read, Update, or Delete, then name the matching SQL command: an existing customer record is changed.

Hints
  • Look for whether the record already exists.
  • The key action is changed or modified.
  • After identifying the CRUD operation, use the CRUD-to-SQL mapping.
Output
Answer: Update, which maps to UPDATE.

Mistakes in CRUD Classification

  • Treating every database action as an UPDATE

    Retrieving data is Read, not Update.

    Fix: Map Read to SELECT.

  • Confusing a new record with a modified record

    The scenario describes Create because the record is new.

    Fix: Map Create to INSERT.

  • Confusing removal with modification

    Removing data is Delete, not Update.

    Fix: Map Delete to DELETE.

  • Remembering the CRUD word but not the SQL mapping

    Each CRUD operation has a specific corresponding SQL command.

    Fix: Memorize the complete mapping: Create–INSERT, Read–SELECT, Update–UPDATE, Delete–DELETE.

Separate two questions when reading a scenario: What happened to the data, and which SQL command represents that action? This prevents the operation's meaning from being confused with its command name.

Key Takeaways

  1. CRUD stands for Create, Read, Update, and Delete.
  2. UPDATE is the CRUD operation for modifying an existing record.
  3. The SQL commands map directly as follows: Create to INSERT, Read to SELECT, Update to UPDATE, and Delete to DELETE.
  4. CRUD forms a complete framework for understanding how data is managed throughout its lifecycle.
  5. To classify a scenario, identify whether data is being added, retrieved, modified, or removed.

Key Takeaways

  • CRUD describes the four fundamental database operations: Create, Read, Update, and Delete.
  • UPDATE modifies an existing record rather than adding, retrieving, or removing one.
  • The SQL command for Update is UPDATE.
  • The complete CRUD mapping is Create–INSERT, Read–SELECT, Update–UPDATE, and Delete–DELETE.
  • Identifying the action in a scenario is the first step toward choosing the correct CRUD operation.