liveBook · Manning

Primary key

As explained in Everyday Data Visualization

A primary key is a field whose value uniquely identifies each row in a table.

A primary key is a column whose value uniquely identifies each row in a table. It becomes especially important when tables contain many observations, such as visits, users, clicks, or transactions. section 3.5.1

A useful primary key should:

  • Contain a unique value for every row. section 3.5.1
  • Preferably use an integer, although an alphanumeric string can also work. section 3.5.1
  • Represent an identifier rather than descriptive information such as fruit type or taste score. section 3.5.1

Fruit ID

A fruit-tasting table assigns each observation a Fruit ID: 1 for apples, 2 for kiwis, and so on. Repeated fruit types can still have different primary keys because each row records a separate observation.

How Everyday Data Visualization covers it

How deep it goes
Defines uniqueness, recommends integer identifiers, and notes alphanumeric alternatives without addressing database constraints or implementation.
Examples
Uses fruit IDs, Social Security numbers, driver’s license numbers, license plates, and vehicle identification numbers as examples.
What you can do after
Evaluate whether a table includes a unique identifier for every observation.
How it connects
Connects primary keys to tabular data, big data, observations, and nested data.

Also explained in

Compare how 21 books explain primary key →

Related concepts

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