liveBook · Manning

Unsigned integer

As explained in Grokking Relational Database Design

An unsigned integer is a nonnegative integer representation without a negative sign.

An unsigned integer stores whole numbers without negative values. Compared with a signed integer using the same storage size, it can represent a larger maximum value. section 4.6

Keep these practical rules in mind:

  • TINYINT, SMALLINT, INT, and BIGINT use 1, 2, 4, and 8 bytes, respectively. section 4.6
  • An unsigned TINYINT reaches 255, while a signed TINYINT reaches 127. section 4.6
  • An unsigned INT reaches 4,294,967,295; values beyond that require BIGINT. section 4.6

Choosing a type for an identifier

For a payment_id attribute, first identify it as numeric and then choose a suitable integer type. TINYINT is too small, SMALLINT may be too small for a very large store, and INT is sufficient for now; BIGINT provides more capacity. section 4.6

Compare the ranges available to signed and unsigned integer types. section 4.6

How Grokking Relational Database Design covers it

How deep it goes
Defines signedness, compares capacities, and applies type selection to an identifier without detailing storage internals.
Examples
Uses signed and unsigned TINYINT limits, unsigned INT capacity, and payment_id type selection.
What it assumes
Assumes basic database requirements and sample data, then teaches integer signedness and capacity from the beginning.
What you can do after
Evaluate database attributes and choose an appropriately sized integer type for nonnegative values.
How it connects
Connects unsigned integers with signed numbers, integer data types, numeric IDs, and database attributes.

Also explained in

Compare how 9 books explain unsigned integer →

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.