News for hackers. Stuff that matters.
Re:What the Heck is a Relation? From Tables to Cartesian Pro... by csense on Thursday December 26, 2013 @02:41AM (#6965555)
In mathematics, a relation is a set of ordered pairs.

Strictly speaking, the relations of database theory are different objects, but closely related. (Yes, I just made an awesome pun.)

I'm surprised that the author didn't include "a relation is a set of tuples" as a definition in the article. Also, absolutely nothing is said about viewing a relation as a graph.

Re:What the Heck is a Relation? From Tables to Cartesian Pro... by cousin_it on Thursday December 26, 2013 @04:06AM (#6965702)
I suspect that using unordered sets as the foundation for databases might have been a mistake, and ordered lists with allowed repetition would've made a better model, if only because they can model tables and query results equally well (ORDER BY, SELECT without DISTINCT). Is there a good reason why this road was not taken?
Re:What the Heck is a Relation? From Tables to Cartesian Pro... by AlisdairO on Thursday December 26, 2013 @04:31AM (#6965754)
In most actual implementations of relational DBs there's nothing to disallow repetition in a table - you just don't specify a primary key (or preferably have a unique primary key that's just an ignored surrogate).

The difficulty with caring about ordering in the relational model is that suddenly you're imposing a lot more constraints: when you're joining two tables, whose order 'wins'? If you say (for example) that left side wins, you then need to keep track of that order through your query.

Re:What the Heck is a Relation? From Tables to Cartesian Pro... by eru on Thursday December 26, 2013 @04:29AM (#6965746)
Would you want bag semantics for things like union and intersection then?
Re:What the Heck is a Relation? From Tables to Cartesian Pro... by cousin_it on Thursday December 26, 2013 @05:49PM (#6968493)
Yes, that sounds reasonable. I don't know very much about the practical uses of union and intersection in SQL, though.
Re:What the Heck is a Relation? From Tables to Cartesian Pro... by tunesmith on Thursday December 26, 2013 @02:00AM (#6965487)
The followup article (http://merrigrove.blogspot.com/2013/12/the-occultation-of-re...) is really good, too. I particularly liked the concrete example of the "projection".
Re:What the Heck is a Relation? From Tables to Cartesian Pro... by k0n2ad on Thursday December 26, 2013 @02:21PM (#6967558)
"The self is a relation that relates itself to itself or is the relation's relating itself to itself in the relation; the self is not the relation but is the relation's relating itself to itself." - Kierkgaard

Sorry, had to chime in with that

Re:What the Heck is a Relation? From Tables to Cartesian Pro... by chris_wot on Thursday December 26, 2013 @12:20AM (#6965339)
You have the following material implications:

    EMPLOYEE(Daniel Smith, Marketing)  →  TRUE
    EMPLOYEE(Jebediah Vargas, Marketing)  →  FALSE
However, if the employee name in the function is not Daniel Smith but the employee is in marketing, the first predicate is true. How does that fit into relational databases?

P.S. Great article!

Re:What the Heck is a Relation? From Tables to Cartesian Pro... by siddboots on Thursday December 26, 2013 @02:07AM (#6965500)
The arrow notation here is not material implication, but function evaluation. The function itself can be interpreted as an Indicator Function[1] for the employee set, or alternatively, as simply evaluating the predicate.

In terms of tables, the rows are exactly the subset of predicates that are TRUE. So FALSE statements like the second one are indicated by their absence in the employee table.

[1] http://en.wikipedia.org/wiki/Indicator_function

Re:What the Heck is a Relation? From Tables to Cartesian Pro... by chris_wot on Thursday December 26, 2013 @06:42PM (#6968671)
Thanks! I had no idea