Vector Databases — What they are and how they differ from SQL/NoSQL

Learn what vector databases are, why they power semantic search and RAG, how they differ from SQL/NoSQL, example tools, and code snippets to get started with embeddings + ANN search.

Vector Databases — What they are and how they differ from SQL/NoSQL

TL;DR: Vector databases store and query high-dimensional embeddings produced by ML models. They provide fast approximate nearest neighbor (ANN) search across millions of vectors, enabling semantic search, recommendations, and retrieval-augmented generation (RAG). They are complementary to — not a replacement for — traditional SQL/NoSQL databases.

What is a vector database?

A vector database is a purpose-built system for storing, indexing and searching vector embeddings — dense numeric arrays that capture semantic meaning of text, images, audio or other data. Instead of matching keywords, vector search finds items whose embeddings are closest to the query embedding (using cosine similarity, dot product, or Euclidean distance).

Why embeddings?

Modern AI models turn raw content into vectors (embeddings). Nearby vectors imply semantic similarity — e.g. "car" and "automobile" have nearby embeddings even if the text differs. This property enables:

How vector DBs differ from traditional databases

Data model — SQL/NoSQL: tables, rows, documents, key-value pairs. Vector DB: vectors (float arrays) + optional metadata (id, text, tags).

Query type — SQL/NoSQL: exact match, filters, joins, aggregations. Vector DB: similarity / nearest-neighbor queries (ANN), often combined with metadata filtering.

Indexing — SQL/NoSQL: B-trees, hash indexes. Vector DB: ANN indexes — HNSW, IVF, PQ, OPQ — optimized for high-dimensional distance search.

Use cases — SQL/NoSQL: transactions, reporting, CRUD apps. Vector DB: semantic search, similarity search, RAG, recommender systems.

Key concepts

Popular vector databases & integrations

How indexing & search works (high level)

Brute-force nearest neighbor search (computing distances to every vector) is too slow at scale. Vector DBs use ANN indexes that trade a tiny amount of accuracy for big speed and memory gains. Common approaches:

Architectural patterns

Most production systems combine a vector DB with other components:

Getting started: Python examples

A) Prototyping locally with Sentence-Transformers + FAISS

# pip install sentence-transformers faiss-cpu
from sentence_transformers import SentenceTransformer
import numpy as np
import faiss

model = SentenceTransformer('all-MiniLM-L6-v2')
docs = ["How to cook rice", "Best way to learn python", "Introduction to vector databases"]
embs = model.encode(docs, convert_to_numpy=True)

d = embs.shape[1]
index = faiss.IndexFlatL2(d)
index.add(embs)

query = "vector search tutorial"
q_emb = model.encode([query])
k = 2
D, I = index.search(q_emb, k)
print("Top docs:", [docs[i] for i in I[0]])

B) Production-like flow with Qdrant

# pip install sentence-transformers qdrant-client
from sentence_transformers import SentenceTransformer
from qdrant_client import QdrantClient
from qdrant_client.http.models import Distance

model = SentenceTransformer('all-MiniLM-L6-v2')
texts = ["How to cook rice", "Best way to learn python", "Introduction to vector databases"]
embs = model.encode(texts, convert_to_numpy=True)

client = QdrantClient(url='http://localhost:6333')
collection_name = 'docs'
client.recreate_collection(collection_name=collection_name, vector_size=embs.shape[1], distance=Distance.COSINE)
payloads = [{"text": t} for t in texts]
client.upload_records(collection_name=collection_name, records=[(i, embs[i].tolist(), payloads[i]) for i in range(len(texts))])

query = "vector database guide"
q_emb = model.encode([query])[0].tolist()
res = client.search(collection_name=collection_name, query_vector=q_emb, top=3)
for hit in res:
    print(hit.payload['text'], "score:", hit.score)

Best practices

When NOT to use a vector DB

If you only need transactional queries, strict ACID semantics, complex joins or analytics, a relational DB (Postgres, MySQL) or a document store (MongoDB) is still the right choice. Vector DBs complement — not replace — those systems.

Summary

Vector databases are a foundational piece of modern AI systems: they make semantic retrieval fast and scalable. Choose a local library (FAISS) to prototype, an open-source DB (Qdrant, Milvus, Weaviate) for control, or a managed service (Pinecone) for rapid production deployment. Combine vector search with metadata and re-ranking to deliver accurate, explainable results.

← Back to Blog Index