SQL

The Structured Query Language is the standard for data query and manipulation in relational database systems. It implements many (but not all) concepts of the relational model.

History

Table vs. Relation

The basic concept of the SQL implementation is the table. When going from the relation model to the SQL implementation relations become tables.

An SQL table is similar to a relation, with some important differences:

Data Types

Numbers:

SQL92 standard numeric data types:

Postgres: DECIMAL(p, s) and NUMERIC(p, s) equivalent.

Other Types:

A desirable Feature

Conceptually, types are distinct from their representation, e.g.

TYPE POINT
  POSSREP CARTESIAN ( X RATIONAL, Y RATIONAL )
  POSSREP POLAR (R RATIONAL, THETA RATIONAL )

Associated idea: valid operations, ADT, e.g. certain operations with part weights and quantities make sense, while others don't:

SQL92: named types in terms of primitive types, no operation restrictions

Postgres:

create domain ssn char(10);
create table emp (id ssn not null, name char(20) not null, primary key(id));
insert into emp (id, name) values ('846312041972', 'Jones');
ERROR:  value too long for type character(10)