Coming from a MySQL background I've been wondering for some time why a table is actually called a relation in postgresql. Does it have to do with the SQL:2008 ISO/ANSI standard? Because it confused the hell out of me and colleagues on the first few encounters with postgres.
I'm asking because knowing the reasoning behind it might clear up some things or might make the adoption a little easier.
In a relational database, the table is a relation because it stores the relation between data in its column-row format. The columns are the table's attributes, and the rows represent the data records.
PostgreSQL is a relational database management system ( RDBMS ). That means it is a system for managing data stored in relations. Relation is essentially a mathematical term for table.
A relation, also known as a table or file, is a subset of the Cartesian product of a list of domains characterized by a name. And within a table, each row represents a group of related data values. A row, or record, is also known as a tuple. The columns in a table is a field and is also referred to as an attribute.
A table in a relational database is much like a table on paper: It consists of rows and columns. The number and order of the columns is fixed, and each column has a name. The number of rows is variable — it reflects how much data is stored at a given moment.
This originates from terminology used by academics, rather than that used by software engineers. You will find this occurs much with PostgreSQL and their documentation leaves you frequently in need of a technical dictionary if you are unfamiliar with it.
The formal language for databases is referred to as "Relational algebra".
As mentioned by mark bannister, this link may be helpful for terminology:
http://en.wikipedia.org/wiki/Relational_databases#Terminology
Edit
To be clear on what I mean by this: SQL is a standard that was written by industry (Oracle had a big part in it). SQL does not mention relational algebra, indeed its origin was a language designed to be be easily human readable rather algebraic.
Relational algebra is in general the domain of the academic world and is not commonly used by the engineering world.
Posgresql community has greater ties with the academic community than other implementations and it seems that they chose their terminology from relational algebra rather than copying the engineers. Some might argue that this is in error since PostgreSQL is a SQL database management system, rather than a relational database management system.
Does it have to do with the SQL:2008 ISO/ANSI standard?
The Standard SQL specs have always purposely avoided the term "relation" and its derivatives.
A relation by definition has no attributes with duplicated names, no anonymous columns, no duplicate tuples and no nulls. The same cannot be said of a SQL table. If the postgreSQL documentation equates "relation" with "table" then they are using these terms loosely.
Its just a way to name things. Some people have tables with rows and columns, others have relations with tuples and attributes. It's not postgresql specific, moreover using these other designations implies a certain way to organize your tables, see "relational model" in wikipedia.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With