Beginner

Introduction to Vector Databases

Understand what vector databases are, why modern AI applications need them, and how they fundamentally differ from the traditional databases you already know.

What Are Vector Databases?

A vector database is a specialized database designed to store, index, and search high-dimensional vectors (also called embeddings). Unlike traditional databases that search by exact matches or keyword patterns, vector databases find data by meaning — returning results that are semantically similar to a query.

When you convert text, images, audio, or any data into numerical vectors using an embedding model, you need a place to store those vectors and search through them efficiently. That is exactly what a vector database does.

💡
Key insight: Traditional databases answer "find the exact match." Vector databases answer "find the most similar." This shift from exact matching to similarity search is what makes AI applications possible.

Why Do We Need Vector Databases?

AI models understand the world through vectors — dense numerical representations that capture semantic meaning. To build applications on top of these models, you need infrastructure that can:

  • Store millions to billions of vectors efficiently in memory or on disk.
  • Search by similarity rather than by exact value — find the closest vectors to a query vector.
  • Return results in milliseconds even at massive scale, using approximate nearest neighbor (ANN) algorithms.
  • Filter results by metadata (e.g., "find similar documents, but only from the last 30 days").
  • Update in real time as new data arrives.

How Vector Databases Differ from Traditional Databases

Feature SQL Database NoSQL Database Vector Database
Data model Rows and columns Documents, key-value, graph Vectors + metadata
Query type Exact match, range, JOIN Key lookup, document query Similarity search (nearest neighbor)
Search method B-tree, hash index B-tree, hash, full-text ANN index (HNSW, IVF, LSH)
Best for Structured, relational data Flexible schemas, scale-out Embeddings, similarity, AI/ML
Example query WHERE name = 'John' db.find({name: "John"}) "Find documents similar to this text"

Core Concepts

Vectors (Embeddings)

A vector is a list of numbers (e.g., [0.12, -0.34, 0.56, ...]) that represents a piece of data in a high-dimensional space. Embedding models convert text, images, or other data into vectors such that similar items have similar vectors.

Conceptual Example
# "king" and "queen" have similar vectors because
# they are semantically related
king  = [0.21, 0.85, -0.12, 0.67, ...]   # 1536 dimensions
queen = [0.19, 0.82, -0.10, 0.71, ...]   # very close in vector space

# "banana" has a very different vector
banana = [-0.45, 0.12, 0.88, -0.33, ...]  # far away in vector space

Similarity Search

Given a query vector, a vector database finds the k most similar vectors in its index. Similarity is measured using distance metrics like cosine similarity, Euclidean distance, or dot product.

Approximate Nearest Neighbor (ANN)

Searching through millions of vectors by comparing every single one (brute force) is too slow. ANN algorithms build clever index structures that trade a tiny bit of accuracy for massive speed improvements — returning results in milliseconds instead of minutes.

Think of it this way: If you need to find the most similar book in a library of 10 million books, you would not read every single one. Instead, you would organize books by genre, topic, and style, then only search the relevant section. ANN algorithms do the same thing with vectors.

Use Cases for Vector Databases

  1. Retrieval-Augmented Generation (RAG)

    Store your documents as vectors. When a user asks a question, find the most relevant documents and feed them to an LLM for accurate, grounded answers. This is the most popular use case today.

  2. Semantic Search

    Search by meaning, not keywords. A search for "affordable Italian restaurants downtown" can match a document containing "budget-friendly pasta places in the city center" even though no keywords overlap.

  3. Recommendation Systems

    Represent users and items as vectors. Find items whose vectors are closest to a user's preference vector for personalized recommendations.

  4. Image Search

    Convert images to vectors using models like CLIP. Search for visually similar images by querying with an image or text description.

  5. Anomaly Detection

    Normal data points cluster together in vector space. Anomalies are vectors that are far from any cluster, making them easy to detect.

The Vector Database Ecosystem

The vector database landscape has exploded in recent years. In this course, we will cover four of the most popular options in depth:

  • Pinecone — Fully managed, serverless. Best for teams that want zero infrastructure management.
  • ChromaDB — Open-source, embeddable. Perfect for prototyping and local development.
  • Weaviate — AI-native with built-in vectorizers and hybrid search. Great for complex queries.
  • pgvector — PostgreSQL extension. Ideal if you already run PostgreSQL.

We will also compare these with Qdrant and Milvus in the Comparison lesson.

💡 Think About It

Consider a project you are working on or plan to build. Could similarity search improve the user experience? Think about search features, recommendations, or content discovery.

Identifying real use cases helps you choose the right vector database and design better AI-powered features.