# Table-oriented programming

Table-oriented programming (TOP) is a data-focused programming paradigm (as opposed to code-focused), part of the data-oriented group of paradigms.
There are three main subtypes of table-oriented programming:
* General-purpose TOP languages with tables built in (xBase)
* Spreadsheets
* Relational database languages: Domain-specific tabular languages, often on a remote server, such as SQL

## History
### Mainframe era: 1960s–1978

During this era, table-oriented programming was called decision table programming.
The earliest known reference to Decision table programming is DETAB-X, in October 1962. This led to languages such as Filetab in the late 60s, whose descendants continued in the 70s and 80s.
The spreadsheet stream of TOP seems to have begun in 1969, with LANPAR.
The relational database concept was defined by E. F. Codd at IBM in 1970.

### PC era: 1978–1995

The general-purpose TOP languages during this era, when the paradigm was labelled at all, were sometimes called Data-oriented languages. The primary languages during this era were the xBase family (including Clipper and later xHarbour), and the FoxPro family.
This was also an era of rising popularity for spreadsheets. From the release of VisiCalc in 1979, and continuing to Lotus 1-2-3 and the rise of Microsoft Excel, spreadsheets followed the rise of the personal computer in popularity.
During this era, early versions were released of Oracle (1977 onwards), Ingres (1980s), and other Relational Database Management Systems (RDBMSs).

### Web 1.0 era: 1995–2008

During the Web 1.0 era, the general-purpose TOP stream fell into disuse. The reasons were twofold. One was that the languages didn't move to capitalise on the web the way others such as Java did. The second was the rise in popularity of object-oriented programming. While the code-focused languages gave birth to object-oriented descendants (e.g. C to C++ et al., Lisp to CLOS), the TOP languages never did so. While they had superior data-handling facilities, their code-handling facilities didn't compete with the object-oriented languages.
One contributing factor was advocacy by Bryce Jacobs (using the aliases Tablizer and TOPMind); the oppositional nature of these interactions led to TOP being dismissed as inferior to OOP (whereas the concepts of TOP could be quite useful within an object-oriented programming context), and his many valid points being dismissed by those not willing to spend the time deciphering his points. He does, however, seem to have been the first to use the name "table-oriented programming", which is the most accurate label for the paradigm.
This was an era of consolidation for spreadsheets; Microsoft Excel became the de facto standard, and was eventually left without competitors.
On the relational database front, this was the era when MySQL (1995) and PostgreSQL (1996) became popular.

### Web 2.0 era: 2008–2022

During this era, any necessary table-oriented programming was pushed into the RDBMS, and a standard separation of concerns into "frontend", "backend" and "database" was developed.
Spreadsheets continued as in the previous era, except on the web. Finally a competitor arose for Excel: Google Sheets.

## Features

General-purpose TOP languages share many features with other general-purpose languages.
The core feature of TOP is that tables be given a prominent place in the programming language.
Comparison of TOP streams :
| Header text | General-Purpose TOP | Spreadsheets | Relational Databases | Comments |
| Tables prominent in language | Yes | Yes | Yes |
| Code Stored in Tables | Yes | Yes | No |
| Conveniently manages many tables | Yes | No | Yes |
| Data Dictionaries | Yes | No | Yes |
| Column type | Named | Sequenced | Named |
| Row type | Sequenced | Sequenced | Sequenced |
| Single interface for multiple backends | Yes | No | Kind of | If all SQL is ANSI-compliant, then it is for RDBMSs, but not for other backends (e.g. in-memory, CSV, JSON) |

## Design patterns
### Decision tables

Decision tables are a commonly used pattern, especially in the general-purpose TOP languages. A decision table is a table with columns (usually multiple) which represent inputs, and columns (typically singular, but many be multiple) which represent the outputs. Each set of inputs is unique, and the rows of the table should cover all possible combinations of inputs.

### Control tables

Control tables are an expansion of decision tables; instead of having output columns, they have code stored in the table. When the row for that decision is selected, the code stored in the table is run.

## TOP languages
### General-purpose TOP languages

* DETAB-X (1962)
* Filetab (between 1965 and 1968)
* The XBase programming language family (1986 and following)
* Clarion (1986)

### Spreadsheets

* LANPAR (1969)
* Autoplan/Autotab (1968) -
* VisiCalc (1979)
* SuperCalc (1980)
* Multiplan (1982)
* Lotus 1-2-3 (1982)
* Microsoft Excel (1985)
* StarOffice (1985) → OpenOffice.org (2000) → Apache OpenOffice (2012) / LibreOffice Calc (2010)
* Google Sheets (2006)

### Relational databases

* Oracle Database (1977 onwards)
* Ingres (1980s)
* MySQL (1995)
* PostgreSQL (1996)