Understanding Object Identities in Database Formalism
180 likes | 293 Vues
A presentation on object identity formalisms in databases based on Abiteboul and Kanellakis' work, covering classes, relations, typing, schemas, instances, examples, queries, IQL, and type inheritance.
Understanding Object Identities in Database Formalism
E N D
Presentation Transcript
Object Identities A presentation by Corey Anderson Inspired by Abiteboul and Kanellakis
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
Object Identity • A unique identity for each object oid o-value adam [ name: “Adam”, spouse: eve, children: {cain, abel, seth, …} ]
Formalisms – basics • oid • An identifier • o-value • An oid, a constant, or a tuple of o-values • Schema v. Instance
Formalisms – classes • Classes P = { P1, P2, … } • P = { 1st-gen, 2nd-gen } • (P) : P {oids} • (1st-gen) = { adam, eve }
Formalisms – relations • Relations R = { R1, R2, … } • R = { ancestor-of-celebrity, founded-lineage } • (R) : R {o-values} • (ancestor-of-celebrity) = {[seth, noah], …}
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]}
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
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])]
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 • …
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
Simple IQL example • Farmers who founded lineage • farmer-founders(x) 2nd-gen(x), founded-lineage(x), x = [n, o], o = “farmer”
Less simple IQL example • Make a class of all the occupations S = { R, P {occupation}, T {T(occupation) = [name: string]} SinSSin from earlier SoutSSout = {{}, {occupation}, …} • What’s (S, Sin, Sout)?
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-value
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) G1 G2
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, …
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 }
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