liveBook · Manning

Bytes

As explained in API Design Patterns

Byte data is binary content represented as a sequence of bytes.

Bytes represent binary content as a sequence of byte values. In API and database design, choosing byte-based storage affects allocation, identifier size, indexing, and compatibility. section 5.4.1 section 6.4.5

Use raw bytes when the underlying system handles binary identifiers efficiently, but compare the main storage alternatives:

  • Store an identifier as raw bytes when the database supports binary fields, uniqueness constraints, and indexed single-key lookups. section 6.4.5
  • Use a string representation when simplicity and customer-facing readability matter, while recognizing that encoded strings consume more space. section 6.4.5
  • Convert the bytes to an integer when the identifier fits a common 32- or 64-bit type; this usually offers the broadest database support. section 6.4.5

Binary identifier storage

For a database that indexes binary values well, store an identifier using a raw-bytes field such as MySQL BINARY. Enforce uniqueness and add an index for fast single-key lookups. section 6.4.5

How API Design Patterns covers it

How deep it goes
Explains allocation units and storage alternatives, stopping short of detailed binary encoding algorithms.
Examples
Uses UTF-32 sizing, MySQL BINARY fields, and 32- or 64-bit integer representations as concrete examples.
What you can do after
Evaluate identifier storage formats and configure raw-byte fields with uniqueness constraints and indexes.
How it connects
Ties bytes to strings, Unicode, identifiers, primary keys, indexes, Base32, and integers.

Also explained in

Compare how 7 books explain bytes →

Related concepts

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