object identities a presentation by corey anderson inspired by abiteboul and kanellakis
TRANSCRIPT
Object Identities
A presentation by Corey Anderson
Inspired by Abiteboul and Kanellakis
2
The big idea
• Object-orientation in a database is good
• But no one uniform formalism exists yet
• So let’s use A&K’s formalism
– Object identities as First Class Citizens
3
Object Identity
• A unique identity for each object
adam [ name: “Adam”,spouse: eve,children: {cain, abel, seth, …} ]
oid o-value
4
Formalisms – basics
• oid– An identifier
• o-value– An oid, a constant, or a tuple of o-values
• Schema v. Instance
5
Formalisms – classes
• Classes P = { P1, P2, … }
– P = { 1st-gen, 2nd-gen }
(P) : P {oids} (1st-gen) = { adam, eve }
6
Formalisms – relations
• Relations R = { R1, R2, … }
– R = { ancestor-of-celebrity, founded-lineage }
(R) : R {o-values} (ancestor-of-celebrity) = {[seth, noah], …}
7
Formalisms – typing
• Everything has a type = {} | constant | class | tuple | {} | |
• Given , each type has an interpretation [] (i.e., the set of things that are of that type)
– [P] = (P)
– [[1, 2]] = {[v1,v2] | v1 [1], v2 [2]}
8
Formalisms – the last one!
• A schema S is a triple (R,P,T)– Relations R, classes P, type mapping T : RP
types(P)
• An instance I is a triple (, , )– o-value assignment , oid-assignment , oid-to-
o-value partial function
9
An Example Schema
• P = { 1st-gen, 2nd-gen }
• R = { ancestor-of-celebrity, founded-lineage }
• T(1st-gen) =
[name: string, spouse: 1st-gen, children: {2nd-gen}]
• T(2nd-gen) = [name: string, occupations: { string }]
• T(ancestor-of-celebrity) = 2nd-gen
• T(founded-lineage) =
[anc: 2nd-gen, desc: (string or [spouse: string])]
10
An Example Instance
(1st-gen) = { adam, eve } (2nd-gen) = { seth, cain, abel, other } (founded-lineage) = {cain, seth, other } (ancestor-of-celebrity) = {[anc: seth, desc: noah],
[anc: cain, desc: [spouse: “Ada”]] } (adam) = [name: “Adam”, spouse: eve,
children: {cain, abel, seth, other}] (abel) = [name: “Abel”, occupations: {“shepherd”}] (other) is undefined
• …
11
Posing Queries – IQL
• The Identity Query Language
• Rule-based, like Datalog
• Formally, (S, Sin, Sout)
– Sin, Sout are projections of S
– Convert an instance of input schema Sin to an instance of output schema Sout
• Typed
12
Simple IQL example
• Farmers who founded lineage– farmer-founders(x) 2nd-gen(x), founded-
lineage(x), x = [n, o], o = “farmer”
13
Less simple IQL example
• Make a class of all the occupationsS = { R, P {occupation},
T {T(occupation) = [name: string]}
Sin S Sin from earlier
Sout S Sout = {{}, {occupation}, …}
• What’s (S, Sin, Sout)?
14
The query
T(R1) = string T(R2) = [string, occupation]
R1(o) 2nd-gen(x), x = [n,o]
R2(o,z) R1(o) ;; Creates the oid z and ;; automagically sets ;; (occupation) = z
R2(o,z) ;; Define z’s o-valueoz ˆ
15
Another example – nesting
R = {R2, R3} T(R2) = [D, D] T(R3) = [D, {D}]
R4(x) R2(x,y)
R5(x,z) R4(x) ;; A new oid!
(y) R5(x,z), R2(x,y) ;; z is set-valued
R3(x, ) R5(x,z)
z
z
1
2
16
Why the authors like IQL
• IQL can express (almost) all possible database transformations– oid invention was necessary here
• IQL contains other cool query languages as sublanguages– Datalog, Datalog with negation, COL, …
17
Type inheritance
• Augment definition of schema to include type hierarchy– Schema S is a quadruple (R, P, T, ) where
is a partial order on P
• Augment definition of instance to account for oids being a subclass object (P) = { (P’) | P’ P, P’ P }
18
Take home messages
• oids are unique identifiers for objects
• oids and their use are formally defined
• IQL is a language with which to query OODBs