liveBook · Manning

Industry type

As explained in Build Financial Software with Generative AI (From Scratch)

An industry type is a database-defined type that restricts an industry value to an approved set of categories.

An industry type restricts a company’s industry value to approved categories instead of accepting arbitrary text. In a company database, defining it as a database ENUM adds validation at the field level while keeping the allowed list small and relatively stable. section 10.2.1

Choose the implementation according to how the categories will be managed:

  • Use a database-defined type when the set of values is limited and changes infrequently. section 10.2.1
  • Use strings or numeric values with labels elsewhere when application needs or team preferences favor flexible storage. section 10.2.1
  • Use a separate table when adding categories would otherwise require database change requests or when the application needs a managed lookup list. section 10.2.1

Company database and API

Define industry_type with categories such as basic materials, healthcare, technology, and utilities, then use INDUSTRY_TYPE for the nullable industry column in company. Mirror those values in a Python IndustryType enumeration and use it in the API response model so returned company data remains constrained.

How Build Financial Software with Generative AI (From Scratch) covers it

How deep it goes
Defines the database and Python representations, compares storage alternatives, and stops short of detailed migration procedures.
Examples
Uses industry categories in PostgreSQL, a company.industry column, a Python IndustryType enum, and an API overview record.
What you can do after
Build it from scratch by defining approved categories, applying the type to a company field, and exposing matching API values.
How it connects
Connects database validation, ENUM types, relational tables, Python enumerations, API schemas, and company records.

This explainer was generated by Manning's knowledge graph from the text of Build Financial Software with Generative AI (From Scratch). The section links point to the parts of the book it draws on.