Database Technologies

What is a vector database and how does it work?

How a vector database searches by meaning: embeddings, cosine similarity and nearest neighbour search, with a worked example and when to use one instead of SQL.

  • 6 min read
  • 5 questions
  • +35 XP
Transcript

Vector databases, is explained by cats. Kitty has thousands of cat photos. Sleeping cats. Jumping cats. Loaf cats. Now Kitty wants to search: “Show me cats in loaf position.” A normal database is great for exact facts. Like: cat name is Mochi.

or. color is orange. But “loaf position” is not always saved as an exact label. So Kitty uses a vector database. First, each photo becomes a vector. A vector is just a list of numbers that represents meaning. Photos of loaf cats get numbers that end up close together.

Photos of other poses end up farther away. Then Kitty’s search also becomes a vector. The vector database looks for the closest matches. So it does not only search for exact words. It searches for similar meaning. That means even if no photo was labeled “loaf position,” Kitty can still find the loafiest cats. That is a vector database. It helps Kitty search by meaning, not just exact matches.