A column is a named field in a database table. Each row is a record, while each column holds one kind of field value, such as text, an integer, a decimal number, or a binary object. Unlike a delimited CSV field, a database column has a defined data type. section 10.3.1
Columns become more useful when their definitions describe how records fit into the larger application:
- A primary-key column uniquely identifies each record; in the Customer table, customer_id is an integer primary key. section 10.3.1 section 10.6.1
- A foreign-key column references another table's primary key, creating a relationship between records. section 10.3.1 section 10.6.1
- A model definition gives each column a name and compatible type while allowing SQLAlchemy to map Python attributes to database fields. section 10.6.1
A column in a SQLAlchemy model
A Customer model can define customer_id = db.Column(db.Integer, primary_key=True) and name = db.Column(db.String). The first column identifies each customer and can be auto-incremented; the second stores the customer's name. An Order model can define customer_id as a foreign key pointing to customer.customer_id. section 10.6.1
Use the ERD to scan a table's column names, data types, and primary-key designation before translating the design into model classes. section 10.3.1








