Escolar Documentos
Profissional Documentos
Cultura Documentos
I commonly see
explanations such as this:
an RDBMS is called a relational database system because the data is stored in tables.
The most common explanation or reason I hear cited for the name is that it’s because of
relationships between data. But this isn’t really accurate.
The real reason is because of something called relational algebra, which takes its name
from a mathematical construct called a relation. It really doesn’t have any obvious or
intuitive association with “relationships.” It’s one of those words that a mathematician
redefined for a very specific purpose, and that was the end of it. Just like in computer
science, where we use words such as “inheritance,” “class,” and “instantiate” in very
specific ways that don’t make sense to non-programmers, “relation” has a meaning that
makes most people’s eyes glaze over.
Now, we can get into further arguments about whether relational databases are really
relational—and lots of people do that—but I’ll stay away from that for the time being.
And in my best Paul Harvey voice, it’s time to say “and now you know… the rest of the
story!”
Many people wonder why relational databases are called “relational.” Some
think that it’s because of a logical entity-relationship model you often start
your design with. Or, because you have tables and relationships (aka foreign
keys) between them. But that’s not the case.
The name comes from the mathematical notion of “relation.” It all started with E. F.
Codd who in 1970 (in the article A Relational Model of Data for Large Shared Data
Banks) proposed something now called relational algebra as the mathematical
foundation of databases.
If you’re used to thinking that a relation is something like “a divides b” or “a is less than
b” then this approach might be difficult to understand. But the difference is really in
your head [1]. Instead of giving explanation of a relation you enumerate the facts that
hold. The relation r above is subtraction in {0,1,2}: (x,y,z) ∈ r if x-y = z. An infinite
enumeration
----------
| r |
|--------|
| 0| 0| 0|
| 0| 1|-1|
| 0| 2|-2|
| 1| 0| 1|
| 1| 1| 0|
| 1| 2|-1|
| 2| 0| 2|
| 2| 1| 1|
| 2| 2| 0|
----------
----------------------------------------
| supply |
|--------------------------------------|
|--------------------------------------|
| 1 | 2 | 5 | 17 |
| 1 | 3 | 5 | 23 |
| 2 | 3 | 7 | 9 |
| 2 | 7 | 5 | 4 |
| 4 | 1 | 1 | 12 |
----------------------------------------
Anything you do with tables in a database yields a relation. The result of an SQL query is
a relation.
-------------------
| supplier | part |
|-----------------|
| 1 | 2 |
| 1 | 3 |
| 4 | 1 |
-------------------