33

Matrices in SQL

Arrays are not the same thing as matrices. An array is a data structure whose elements are accessed by a numeric value called an index. A matrix is an array with mathematical operations defined on it. A matrix can be one, two, three, or more dimensional structures. The most common mathematical convention has been to use the letters i, j, and k for the indexes.

SQL had neither arrays nor matrices because the only data structure in the Relational Model is a table. Arrays violate the rules of First Normal Form (1NF) required for a relational database, which say that all columns are scalars.

This was unfortunately changed in SQL:2003 with the addition of collection types. You can now declare a column to be an array of one of the ...

Get Joe Celko's SQL for Smarties, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.