Relational database
A relational database stores data in tables of rows and columns and links the tables through shared values called keys. It is the model behind most business systems, and SQL is the standard language for querying it.
What it is
A relational database is a database that holds data in tables, also called relations, where each row is one record and each column is one attribute of that record. Tables are connected by identifiers, which are values that appear in more than one table and let a row in one table be matched to rows in another.
The main parts are:
- Tables, each describing one kind of thing, such as customers or invoices.
- Rows, one per record, and columns, one per attribute with a fixed data type.
- Primary identifiers (PK), which identify each row of a table uniquely.
- Foreign identifiers (FK), which hold the PK value of a row in another table and so link the tables.
- Constraints, the rules that keep data valid, such as uniqueness and required values.
The ISO/IEC 9075 standard for SQL specifies the data structures and basic operations on this kind of data and the syntax for defining its structure and integrity constraints. Part 11 of the standard defines the schemas that describe the structure and constraints of SQL data.
Splitting data into linked tables avoids repeating the same facts. A customer name is stored once, and each invoice refers to the customer by its PK value.
Why it matters
Most transaction systems, ledgers and reporting databases in finance are relational. Identifier columns and constraints stop duplicate or orphan records from entering the data.
An analyst who understands the table structure can combine tables correctly. A join on a field that is not unique repeats rows and inflates totals.
Worked example
Illustrative numbers. A customers table has 3 rows with customer numbers 1, 2 and 3. An invoices table has 5 rows, and each row carries a customer number.
Invoices 1 and 2 belong to customer 1. Invoice 3 belongs to customer 2. Invoices 4 and 5 belong to customer 3.
Joining the two tables on customer number returns 5 rows, one per invoice, each with the customer name attached. If the customers table held customer number 1 twice, the join would return 7 rows and the total would be overstated.
Who uses it
- Data analysts read the table structure, then join and aggregate tables with SQL.
- Business intelligence analysts model reporting tables from relational sources.
- Master data specialists keep identifiers unique so that records are not duplicated.
- Regulatory reporting analysts trace filed figures back to source tables.
Common confusions
- A relational database is not a database that stores relationships as diagrams. Relation is the formal term for a table.
- A spreadsheet with several sheets is not a relational database, because it has no enforced identifiers or constraints.
- SQL and the relational database are different. SQL is the language; the database holds the data.
- Relational databases are not the only type. Document, name-value and graph databases organise data differently.