TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
 Specialized Dev Zones Research Center eBook Library .NET Java C++ Web Dev Architecture Database Security Open Source Enterprise Mobile Special Reports 10-Minute Solutions DevXtra Blogs Slideshow

# SQL Techniques for Performing Operations on Matrices

## SQL does not support direct operations on matrices, but it does allow easy manipulations with matrices. Learn a few SQL techniques for performing some basic operations on matrices.

 by Alex Kozak
 Dec 11, 2008
 Page 1 of 4

### WEBINAR:On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning

atrices are very useful mathematical objects that science and technology professionals use to describe real-life scenarios and build abstract models for those scenarios. You will find matrices used in economics and statistics, in cryptography and genetics, and in computer graphics. Unfortunately for database developers, SQL and SQL Server do not support direct operations on matrices. However, because tables and matrices share the same structures, SQL allows easy manipulations with matrices. This article demonstrates a few SQL techniques for performing some basic operations on matrices.

Some Matrix Operation Definitions
A matrix is a rectangular array of elements, where the elements can be symbols, symbolic expressions, or numbers (see Figure 1 below):

 Figure 1. Matrix Representation: A matrix is a rectangular array of elements, which can be symbols, symbolic expressions, or numbers.

In general, matrix A in Figure 1 can be denoted by the following:

In this denotation, m is the number of rows and n is the number of columns in the matrix A. Notation m x n represents the size of the matrix, so matrix A can also be denoted by Am x n or by [A]m x n.

The first matrix in Figure 1 has three rows and four columns. Therefore, the size of that matrix is 3 x 4. The size of the second matrix in Figure 1 is 3 x 3. This matrix is also called a square matrix, because the number of rows is equal to the number of columns.

Each element of the matrix Am x n is denoted by aij, where the row number is 1 ≤ i ≤ m and the column number is 1 ≤ j ≤ n. The element a23 of the first matrix is located in the third column of the second row. Similarly, you can find the location of element a23 in the second matrix. The value of that element is a23 = 20.