Showing posts with label Data Modeling Made Simple. Show all posts
Showing posts with label Data Modeling Made Simple. Show all posts

Saturday, November 15, 2025

Introduction to Vector Indexing in SQL Server 2025

SQL Server 2025 introduces native support for vector data types, searches, and indexing directly within the SQL Database Engine. This allows developers and data professionals to store, index, and query high-dimensional vector embeddings—numerical representations of data like text, images, or audio—alongside traditional structured and unstructured data. Vector indexing is particularly useful for AI-driven applications, such as semantic search, recommendation systems, and retrieval-augmented generation (RAG), without needing external vector databases or services.


Key Concepts and Terminology

  • Vectors and Embeddings: A vector is an ordered array of floating-point numbers (e.g., [0.1, 0.2, 0.3]) that captures the semantic meaning of data. Embeddings are these vectors generated by machine learning models, like those from Azure OpenAI, to enable similarity comparisons.
  • Distance Metrics: Measures of similarity between vectors:
    • Cosine Distance: Focuses on direction (angle) between vectors, ideal for text embeddings.
    • Euclidean Distance: Measures straight-line distance, sensitive to magnitude.
    • Dot Product: Computes the (negative) scalar product, often used for normalized vectors.
  • Nearest Neighbor Search (k-NN): Finds the top-k most similar vectors to a query vector.
    • Exact k-NN: Brute-force calculation across all vectors—accurate but slow for large datasets (<50,000 vectors recommended).
    • Approximate Nearest Neighbor (ANN): Uses indexes for faster queries with slight accuracy trade-offs, scaling to millions of vectors.

Vector indexing in SQL Server 2025 powers ANN searches using the DiskANN algorithm, a graph-based method optimized for SSD storage that balances speed, recall, and resource efficiency.

Key Features

  • VECTOR Data Type: Stores vectors as binary-optimized arrays, with dimensions up to 16,000. Vectors can be created via casting from JSON arrays or built-in functions like AI_GENERATE_EMBEDDINGS.
  • Built-in Functions:
    • VECTOR_DISTANCE(metric, query_vector, target_vector): Computes distance between two vectors.
    • VECTOR_SEARCH: Performs ANN queries on indexed columns.
  • Performance Benefits: Indexes reduce query time from O(n) (exact search) to near-constant time for large datasets, leveraging SSDs for low-latency graph traversal.
  • Integration: Works seamlessly with T-SQL, no external dependencies required.

How Vector Indexing Works

  1. Storage: Vectors are stored in a dedicated VECTOR column.
  2. Index Creation: A vector index builds a DiskANN graph structure on the column, partitioning vectors into clusters for efficient navigation. The index uses the specified metric (e.g., cosine) to organize relationships.
  3. Querying: During ANN search, the engine starts from entry points in the graph, traverses to similar neighbors, and refines results—achieving high recall (e.g., 95%+) while minimizing CPU/memory use.
  4. Trade-offs: Approximate searches are faster but may miss some exact matches; tune via index parameters for your workload.

Supported Platforms

  • SQL Server 2025 (17.x) Preview (full support for indexes).
  • Azure SQL Database and Managed Instance (with 2025 update policy).
  • SQL in Microsoft Fabric (preview).

Vector features are in active development; check Microsoft Docs for updates. For hands-on demos, explore sample databases like those for Wikipedia embeddings.

Monday, December 18, 2017

Data Modelling vs Dimensional Modelling

Data have become a real resource of interest across most industries in every field which is exactly considered the gateway to competitive advantage and disruptive strategy. Now a day, most of the enterprises are focusing on methods enabling simpler use of data to drive their business and advancement in data related technologies because data is high-volume and high-velocity and/or high-variety information assets that demand cost-effective, innovative forms of information processing that enable enhanced insight, decision-making, and process automation. 
If we are talking about the data models then it has been treated in two different terminologies such as data modeling and dimension modeling which are differ from each other because Steve Hoberman is stated in his book called Data Modeling Made Simple the distinction between the two types of models is this: 
  • Relational Data Models captures the business solution for how part of the business works, a.k.a business process
  • Dimensional Data Models capture the details the business needs to answer questions about how well it is doing

It can be claimed that a relational model can also be used as a foundation upon which to answer business questions, but at a strategic level. "How many orders are in an unfulfilled status for the customer XXX due to credit hold?" But the distinction is that of where the reporting question needs the 'native grain' of the table and when the reporting question can be answered with summarized data.
To better understanding, we can take an example of Historical Sale Data having product, state and sales cash value as a relational point-of-view-
Product
State
Sales Cash
Beer
Delhi
5000
Beer
Punjab
4500
Beer
Haryana
6000
Wine
Delhi
6500
Wine
Punjab
7500
Wine
Haryana
5000
Vodka
Delhi
4500
Vodka
Punjab
2500
Vodka
Haryana
2000
If we modified the above data as dimensional point-of-view:
Product
Delhi
Punjab
Haryana
Beer
5000
4500
6000
Wine
6500
7500
5000
Vodka
4500
2500
2000
But it seems like both points of view would nonetheless be implemented in an identical star schema and a star schema really lies at the intersection of the relational model of data and the dimensional model of data. It's really a way of starting with a dimensional model, and mapping it into SQL tables that somewhat resembles the SQL tables you get if you start from a relational model.
Product Dim



State Dim
Product Id

Sales Fact

State Id
Product Name

Product Id

State Name


State Id




Sales Cash








The standard approach to relational data modelling is not fit for purpose for Business Intelligence workloads. This is because a relational data modelling is a combination of multiple tables and multiple joins but in dimension modelling, we force to use de-normalize multiple related tables into one table to analyze the data in a very sophisticated manner.