Download Document 8115068

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Motive (algebraic geometry) wikipedia , lookup

Homological algebra wikipedia , lookup

Category theory wikipedia , lookup

Transcript
Category Theory as a Unifying Database Formalism
David Spivak, Carlo A. Curino
Massachusetts Institute of Technology
HISTORY OF A PROBLEM: •The rela-onal model is based on logic and set-­‐theory (150 year old math)
• DB success mo-vated many system and theory advances
• Founda-onal fragmenta-ons resulted from many (independent) extensions to the core theory.
OBSERVATIONS:
•A parallel fragmenta-on naturally occurred in pure math (e.g., algebra, geometry, logic) •Category theory invented as a unifying formalism for pure math. • Category theory is used as a formal underpinning of much programming language theory, linguis-cs, physics.
THE SOLUTION
• We propose category theory as a unifying formalism for database theory
Schemas and Queries as Categories and Functors
Schema
Query
CREATE TABLE employee(
id int, ename varchar,
hiredate date, deptno int,
PRIMARY KEY (id),
FOREIGN KEY fk1 (deptno)
REFERENCES department(did)
);
SELECT e.hiredate, d.address
FROM employee e, department d
WHERE e.deptno = d.did AND e.id="7";
CREATE TABLE department(
did int, dname varchar,
address varchar, PRIMARY KEY (did)
);
COMMUTE:
deptno = did•fk1;
7•q_7 = id•q_employee
did•q_department =
deptno•q_employee;
COMMUTE:
deptno = did•fk1;
F: (obvious inclusion, i.e., object and arrow labels are preserved)
G: (object labels are preserved) hiredate èhiredate•q_employee
address è address•q_department
Instances and Updates as Functors
Schema (C)
DB Instance (I)
CREATE TABLE employee(
id int, hiredate date,
PRIMARY KEY (id),
);
e1,1,1970-01-01
e2,2,2008-01-02
e3,3,1987-02-09
...
Set
C
employee
hiredate
id
int
Update (U)
I (db instance
as a functor)
INSERT INTO employee
VALUES (e4,4,2011-01-28);
x02
e1,e2,...
C-Set
I'
H
1
C
U(I)
x01,x02,CE%$
1970-01-01,2008-01-02,...
date
I
K
1,2,3,...
D
"a$w:"
"david","carlo","fantastic",...
The awesome results we don’t have yet
• Exis-ng category theory proofs can be imported (e.g., functor composability is equivalent to classical DB mapping composi-on)
• We can leverage proof-­‐assistants (e.g., COQ)
• BeQer interac-on with PL (the category of Types)
• Unifying theory for updates, transac-ons, aggregates, triggers, 2PC, 2PL, etc...
Friday, March 11, 2011
E
B
F
G
A
Math Background
• C-­‐Set is the category of functors from CèSet; its morphisms are some-mes called “homomorphisms” in database theory.
•C-­‐Set is a topos: it has an internal logic that supports the Lambda calculus.
•A functor CèD induces migra-ons functors between C-­‐Set and D-­‐
Set, which can be used both to migrate data, or as a query (see above).