liveBook · Manning

Column

As explained in Grokking Relational Database Design

A column is a named field in a relational table whose values share a defined meaning and data type.

A column is a named field in a relational table. It represents one attribute of the table’s entity, such as a product’s name, price, or manufacturer. Every column has a data type that describes the kind of value it stores. section 1.3 section 1.10

When defining a column, decide:

  • What the column is called, such as name, price, or product_id. section 1.10
  • Which data type fits its values: INT for integers, TEXT for strings, or DECIMAL for numeric values with controlled precision. section 1.10
  • Whether the column permits NULL, which represents a missing or unknown value. section 1.10
  • Whether it identifies rows uniquely, as product_id does when defined as a primary key. section 1.3

Product columns

A product table can define product_id as INT PRIMARY KEY, name and description as TEXT, price as DECIMAL(5, 2), and manufacturer as TEXT. Each product occupies one row; these columns describe that product. section 1.10 section 1.3

CREATE TABLE product (
 product_id INT PRIMARY KEY,
 name TEXT NOT NULL,
 description TEXT NOT NULL,
 price DECIMAL(5, 2) NOT NULL,
 manufacturer TEXT NOT NULL
);

Use this CREATE TABLE example to see column names, data types, and a primary-key constraint together. section 1.10

Columns can change as a design evolves. ALTER TABLE can add a column or modify a column’s data type, while dropping the table removes all its columns and data permanently. section 1.11

How Grokking Relational Database Design covers it

How deep it goes
Defines names, data types, NULL handling, keys, and basic alteration, but defers deeper primary-key discussion.
Examples
Uses product_id, name, description, price, manufacturer, and serial_number in product-table SQL examples.
What it assumes
Assumes familiarity with a spreadsheet-like table while teaching entities, attributes, data types, and NULL values from their basic meanings.
What you can do after
Build it from scratch by defining typed columns and constraints in CREATE TABLE, then revise them with ALTER TABLE.
How it connects
Connects columns with relational tables, rows, entities, attributes, data types, NULL values, and primary keys.

Also explained in

Compare how 9 books explain column →

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.