liveBook · Manning

Encryption

As explained in Grokking Relational Database Design

Encryption is the transformation of readable data into encoded information that cannot be understood without the appropriate decryption capability.

Encryption changes readable sensitive data into encoded information that cannot be understood without the appropriate decryption capability. In a database, it is a safeguard for confidentiality: it helps keep sensitive values protected even if unauthorized access occurs. section 3.6 section 7.4

Do not store payment-method information in plain text. A database breach could expose every stored card number; encrypted information provides protection in that worst-case scenario. section 3.6

When designing storage for encrypted values:

  • Identify sensitive information that should not be saved in plain text. section 3.6
  • Choose an appropriate encryption method and encrypt the data. section 7.14
  • Allocate enough space in each corresponding column for the encrypted result. section 7.14

Payment-method columns

A payment_method table can reserve larger fixed-length fields for encrypted card_number and expiry_date values. The important design check is that the encrypted values fit the columns, rather than assuming the original values’ sizes are sufficient. section 7.4 section 7.14

-- comment: works for MySQL and MariaDB
-- comment: consult ChatGPT on adaptations 
-- comment: for other RDBMS
ALTER TABLE payment_method
 MODIFY COLUMN card_number CHAR(45),
 MODIFY COLUMN expiry_date CHAR(45);

Shows a MySQL/MariaDB ALTER TABLE statement that changes payment-method fields to CHAR(45), illustrating storage allocation for encrypted values. section 7.4

How Grokking Relational Database Design covers it

How deep it goes
Gives storage-design steps—choose a method, encrypt data, and size columns—without explaining encryption algorithms or decryption.
Examples
Uses customers’ credit-card information and payment_method card_number and expiry_date columns as storage examples.
What it assumes
Assumes a database design with sensitive fields while explaining the plain-text risk in everyday terms.
What you can do after
Apply it by selecting an encryption method and designing database columns with room for encrypted sensitive values.
How it connects
Connects encryption with confidentiality, access control, database security, and payment-method storage.

Also explained in

Compare how 16 books explain encryption →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Relational Database Design. The section links point to the parts of the book it draws on.