Module 01

What Is a Vector Database?

Retrieval & Knowledge Vector Databases

Module 1 — What Is a Vector Database?

The big idea (explained simply)

Imagine a giant library. In a normal library, you find a book by its exact label: title, author, ISBN. If you don’t know the exact words on the spine, you’re stuck. This is how traditional databases work — they match exact values. “Find the user whose email is g@x.com.” “Find orders where price = 50.” Computers are great at exact matching.

But humans don’t think in exact matches. You think: “I want a book that feels like Harry Potter but for adults.” There’s no column in a database called feels_like. You’re searching by meaning, not by exact words.

A vector database is a library organized by meaning. Instead of shelving books by title, it shelves them by what they’re about, so that similar ideas sit near each other. Ask for “a cozy mystery in a small town” and it walks you to the right shelf even if none of those exact words appear in any book.

That’s the whole game: search by meaning instead of by exact keywords.

How does it pull off “meaning”?

It cheats in a beautiful way. It converts every piece of content — a sentence, a paragraph, an image, a song — into a long list of numbers, like:

"a cozy mystery" → [0.12, -0.88, 0.34, ..., 0.05]   (often 384, 768, or 1536 numbers long)

This list of numbers is called a vector or an embedding (Module 2 is entirely about these). The magic property is:

Content with similar meaning produces vectors that are numerically close to each other.

So “cozy mystery” and “small-town whodunit” land near each other in number-space, while “quantum physics textbook” lands far away. The database’s only real job is: given a query vector, find the stored vectors closest to it, fast. That “find the closest” operation is called similarity search or nearest-neighbor search, and it’s the engine room of every vector database.

A picture in your head

Think of a 2D map (real embeddings have hundreds of dimensions, but 2D is enough for intuition):

        physics

                                 • chemistry

  • cozy mystery
     • small-town whodunit
                          • space opera
        • detective novel

Books about detectives cluster in one corner; science books in another. To answer “find me something like this detective novel,” you drop a pin where the query lands and grab the nearest dots. Distance on the map = difference in meaning.

Why now? Why is everyone suddenly talking about this?

Three things collided:

  1. Embeddings got good. Around 2018–2023, AI models (BERT, then the GPT family, then dedicated embedding models) became excellent at turning messy human content into meaningful vectors. The “meaning → numbers” step finally worked well.
  2. LLMs created a killer use case. Large Language Models like Claude and GPT are smart but have two problems: they don’t know your private data, and they can make things up. The fix is RAG (Retrieval-Augmented Generation): before the model answers, you retrieve relevant facts from your own documents and hand them to the model. The retrieval step is a vector search. Suddenly every company wanted one. (Module 8 builds a RAG app.)
  3. Scale became normal. Companies have millions or billions of documents. You need specialized infrastructure to search that many vectors in milliseconds.

What a vector database actually does (the job description)

A production vector database handles five responsibilities:

  1. Store vectors plus their metadata (the original text, a URL, a timestamp, tags, permissions).
  2. Index them with clever data structures so search is fast (the ANN indexes in Module 5).
  3. Search — given a query vector, return the top-k most similar items, often combined with metadata filters (“only docs from 2024,” “only this user’s files”).
  4. Manage data lifecycle — insert, update, delete, and re-index without taking the system down.
  5. Operate at scale — sharding across machines, replication for reliability, security, and observability.

If it only did #1 and #3 on a laptop, that’s a library (like FAISS). When it does all five reliably across a cluster, it’s a database (like Milvus, Qdrant, Pinecone, Weaviate). We’ll cover both ends of that spectrum.

Vector database vs. traditional database — side by side

Traditional (SQL/NoSQL)Vector database
StoresRows, documents, key-valuesHigh-dimensional vectors + metadata
Finds things byExact match, ranges, joinsSemantic similarity (nearest neighbors)
Query exampleWHERE city = 'Paris'”Find passages that mean the same as this”
Core operationB-tree lookup, hash joinApproximate nearest-neighbor search
Great atPrecise, structured queriesFuzzy, meaning-based retrieval
Bad at”Find similar”Exact transactional bookkeeping

Key insight: they’re not competitors — they’re teammates. Most real systems use both. In fact, modern systems increasingly put vectors inside a traditional database (Postgres with the pgvector extension is the most popular example), so you get filters, joins, and similarity in one place.

Where vector databases show up in real life

  • Semantic search over docs, support tickets, code, legal contracts.
  • RAG chatbots that answer from your company’s knowledge base.
  • Recommendation systems (“users who liked this also liked…”, “similar products”).
  • Image / video / audio search (“find photos that look like this one”).
  • Deduplication and fraud (“is this near-identical to something we’ve seen?”).
  • Anomaly detection (“flag transactions that don’t sit near any normal cluster”).
  • Agent memory — giving AI agents long-term recall of past interactions.

Gotchas (read these now, thank yourself later)

  • A vector database does not understand anything. It only measures distance between numbers. All the “intelligence” lives in the embedding model that produced the numbers. Garbage embeddings → garbage search, no matter how fancy the database.
  • You don’t always need one. If you have 10,000 documents, a plain array and a loop (or Postgres + pgvector) is plenty. Specialized vector databases earn their keep at large scale or high query volume. Don’t over-engineer.
  • “Similar” is defined by the model, not by you. Two sentences you consider unrelated might be “close” to the model. Choosing and evaluating the embedding model (Module 2, Module 11) matters more than choosing the database.

Check yourself

  1. In one sentence, what is the fundamental operation a vector database performs?
  2. Why did LLMs cause an explosion in vector-database demand?
  3. Where does the actual “understanding of meaning” come from — the database or something else?
  4. Give one situation where you should not reach for a dedicated vector database.

Answers: (1) Given a query vector, find the stored vectors closest to it (nearest-neighbor search). (2) RAG — LLMs need to retrieve relevant private facts before answering, and retrieval is a vector search. (3) From the embedding model that converts content into vectors; the database just measures distance. (4) Small datasets or low query volume, where a loop or Postgres+pgvector is simpler.

➡️ Next: 02-embeddings.md — how content actually becomes numbers. This is the most important module in the course.