liveBook · Manning

Database

As explained in Investing for Programmers

A database is an organized system for storing, retrieving, and managing structured or semi-structured data.

A database organizes data so applications can store, retrieve, and reuse it. In AI-assisted financial analysis, it can hold reusable prompts, tags, transcripts, filings, and other context that an LLM cannot access directly. section 9.2.1 section 9.3.2

A prompt repository can start with two relational tables: one identifies each prompt and stores its text; another connects prompts with searchable tags. This simple design supports refinement and reuse across companies, industries, and analytical scenarios. section 9.2.1

A database supports an AI retrieval workflow by:

  • Separating data loading from prompt submission: one process fetches information from files, APIs, web sources, or databases, while another retrieves context for the LLM. section 9.3.2
  • Keeping recent or restricted information available, including earnings-call transcripts and company filings that may not appear in model training data. section 9.3.2
  • Supporting retrieval after documents are loaded, chunked, and added to an in-memory vector database for similarity search. section 9.3.2

Prompt repository schema

A minimal repository defines a prompt table with an ID and required prompt text, then adds a tag table containing tag names and prompt IDs. A prompt such as a BCG Framework question can use a {company} placeholder, which Python later fills with a specific company. section 9.2.1

Listing 9.1 DDL Scripts for creating a prompt repository
create table prompt
(
    id     TEXT primary key,
    prompt TEXT not null
);

create table main.tag
(
    tag_name  TEXT not null,
    prompt_id TEXT not null
);

Inspect the DDL for the prompt repository, including its primary key, required prompt field, and tag relationship. section 9.2.1

Listing 9.9 Adding all text in an in-memory vector database
from langchain_openai import OpenAIEmbeddings
embeddings = OpenAIEmbeddings(model="text-embedding-3-large")
from langchain_core.vectorstores import InMemoryVectorStore
vector_store = InMemoryVectorStore(embeddings)
document_ids = vector_store.add_documents(documents=all_splits)

Inspect the Python construction of an in-memory vector database that stores embedded document chunks for similarity search. section 9.3.2

How Investing for Programmers covers it

How deep it goes
Demonstrates relational DDL and an in-memory vector retrieval workflow, but does not develop database administration or production persistence.
Examples
Uses prompt schemas, company placeholders, earnings-call transcripts, filings, document chunks, and similarity-search results.
What it assumes
Assumes basic Python and LLM familiarity while teaching prompt storage, document loading, chunking, and retrieval through concrete code.
What you can do after
Build it from scratch as a tagged prompt repository or in-memory vector store supporting retrieved context for LLM answers.
How it connects
Connects databases with prompts, tagging, retrieval-augmented generation, embeddings, vector databases, and large language models.

Also explained in

Compare how 24 books explain database →

Related concepts

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