math - How is a table like a mathematical relation? -


i have been been reviewing codd's relational algebra , relational databases. recall relation set of ordered tuples , function relation satisfies additional property each point in domain must map single point in codomain. in sense, each table defines finite-point function primary key onto space of codomain, defined other columns. sense in relation? if so, why relational algebra not functional algebra , why not call functional database instead?

thanks. btw, sorry if not quite normal form stackoverflow (hah, db joke!) looked @ forums , seemed best.

well, there c.j. date's "an introduction database systems", , h. darwen's "an introduction relational database theory". both excellent books , highly recommmend read them both.

now actual question. in mathematics, if have n sets a1, a2, ..., an, can form cartesian product a1 x a2 x ... x an, set of possible n-tuples (a1, a2, ..., an), ai element ai. n-ary relation r is, definition, subset of cartesian product of n sets.

functions binary relations — they're subsets of dom x cod. there're relations higher arity. example, if take set humans x humans x humans, can define, say, relation r, taking tuples (x, y, z) x , y parents of z.

now there 1 important notion logic: predicate. predicate map cartesian set a1 x a2 x ... x set of statements. let's @ predicate p(x,y,z) = "x , y parents of z". each tuple (x,y,z) humans x humans x humans obtain statement it, true or false. , set of tuples give true statements, predicate's truth set, is... relation!

and notice, having truth set need work predicate. so, when model our enterprise, invent bunch of predicates describe it, , store truth sets in relational database.

and so, each operation relations has corresponding operation predicates, when take relations, join , project , filter them, end new relation — , know predicate's truth set is: take corresponding predicates, , and them, , bound existential quantifiers, , new predicate, truth set know.

edit: now, have note since relation set, tuples not ordered. table model relation: can take different tables represent same relation. also, customary in relational theory work more defined tuples , cartesian products. defined higher tuple (a1, a2, ..., an) — basically, function {1,2,...,n} a1 u a2 u ... u (where i's image must in ai). in relational theory, take tuple function { name, name', ..., name } a1 u a2 u ... u — so, becomes record, tuple named components. , of course, means record's components not ordered: (x: 1, y: 2), function { "x", "y" } n maps x 1 , y 2, same tuple/record (y:2, x: 1).

so, if take table, swap rows, swap columns (with headers!), end new table, represent same relation.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -