liveBook · Manning

Column

As explained in Build Python Web Apps with Streamlit

A database column is a named field in a table that stores one attribute of each row according to a defined data type.

A database column is a named field that stores one attribute of every row in a table. Its definition includes a data type and may include rules that control which values are allowed. section 8.2.1 section 8.2.4

When designing a table, decide what each column represents and how its values should behave:

  • Use a clear name such as username, author, or created_at to identify the stored attribute. section 8.2.4
  • Choose a data type, such as VARCHAR for variable-length text, and optionally set a length limit such as VARCHAR(100). section 8.2.4
  • Add constraints when the column has a special role: PRIMARY KEY uniquely identifies rows, while a foreign key connects a value to another table. section 8.2.4

A users table

A users table can define username as VARCHAR(100) PRIMARY KEY and password_hash as VARCHAR(128). Each row then stores one user, with username required to be unique. section 8.2.4

CREATE TABLE users (
  username VARCHAR(100) PRIMARY KEY,
  password_hash VARCHAR(128)
);

This CREATE TABLE statement shows column names, a VARCHAR type with a length limit, and a primary-key constraint together. section 8.2.4

Columns organize persistent database data: rows represent entries, while columns describe their attributes. SQL uses these definitions when creating, storing, and querying table data. section 8.2.1 section 8.2.4

How Build Python Web Apps with Streamlit covers it

How deep it goes
Explains column names, data types, length limits, primary keys, and foreign keys through worked PostgreSQL table definitions.
Examples
Uses username, password_hash, author, text, created_at, and haiku_id in users and haikus table definitions.
What it assumes
Starts from tables, rows, and fields before introducing schemas, data types, and column constraints.
What you can do after
Apply it via SQL by defining typed columns and constraints in CREATE TABLE statements.
How it connects
Connects columns with tables, rows, schemas, data types, SQL, primary keys, and foreign 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 Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.