Annotation Examples (12/18/2009)

Annotation Examples (12/18/2009)
0..*
Context
1..1
hasContextRelationship
0..*
hasContext
1..1
hasContextObservation
0..*
Observation
1..1
ofEntity
Relationship
Entity
1..1
0..*
1..1
Value
0..*
hasValue
hasMeasurement
0..*
Measurement
1..1
ofCharacteristic
Characteristic
0..*
1..1
usesStandard
Standard
OBOE Conceptual Model
1
Annotation Examples (12/18/2009)
<observation label="o1”>
observation "o1”
<entity id=”TemporalRange"/>
entity ”TemporalRange”
<measurement label="m1”>
measurement "m1”
<characteristic id=”Year"/>
characteristic ”Year”
<standard id=”DateTime"/>
standard ”DateTime”
</measurement>
observation "o2”
</observation>
entity “Tree”
<observation label="o2">
measurement "m2" precision: "0.1”
<entity id=“Tree"/>
characteristic “DBH”
<measurement label="m2" precision="0.1">
standard ”Centimeter”
<characteristic id=”DBH"/>
measurement "m3”
<standard id=”Centimeter"/>
characteristic “TaxonomicTypeName”
</measurement>
standard “ITIS”
<measurement label="m3">
measurement "m4”
<characteristic id=”TaxonomicTypeName"/>
characteristic “EntityName”
<standard id=”ITIS"/>
standard “LocalTreeNames”
</measurement>
context observation “o1” relationship “Within”
<measurement label="m4”>
map “yr" to “m1”
<characteristic id=”EntityName"/>
map “diam” to “m2" if diam > 0
<standard id=“LocalTreeNames"/>
map “spec" to “m4”
</measurement>
map “spp" to “m3" if spp == “piru” value=“Picea rubens”
<context observation="o1">
map “spp" to “m3" if spp == “abba” value=“Abies balsamea”
<relationship id=“Within"/>
</context>
</observation>
<map attribute="yr" measurement="m1"/>
<map attribute="diam" measurement="m2" if="diam ge 0"/>
<map attribute="spec" measurement="m4"/>
<map attribute="spp" measurement="m3" value="Picea rubens” if="spp eq 'piru'"/>
<map attribute="spp" measurement="m3" value="Abies balsamea” if="spp eq 'abba'"/>
* Code exists to read/write annotations using this XML format
Annotation Syntax2
Annotation Examples (12/18/2009)
Dataset
Annotation
Define
OBOE Concepts
uses terms from
(view def.)
Materialize
instantiates
observation-based
representation of
Query*
OBOE Model
(individuals/triples)
* Conceptually, we want to query datasets via annotations
3
Annotation Examples (12/18/2009)
Annotation
Dataset
observation "o1”
entity ”TemporalRange”
measurement "m1”
characteristic ”Year”
standard ”DateTime”
observation "o2”
entity “Tree”
measurement "m2" precision: "0.1”
characteristic “DBH”
standard ”Centimeter”
measurement "m3”
characteristic “TaxonomicTypeName”
standard “ITIS”
measurement "m4”
characteristic “EntityName”
standard “LocalTreeNames”
context observation “o1” relationship “Within”
map “yr" to “m1”
map “dbh” to “m2" if dbh > 0
map “spec" to “m4”
map “spp" to “m3" if spp == “piru” value=“Picea rubens”
map “spp" to “m3" if spp == “abba” value=“Abies balsamea”
yr
spec
spp
dbh
2007
1
piru
35.8
2007
1
piru
36.2
2008
2
abba
33.2
: Tempral
Range
hasContext
: Obs
: Meas
: Meas
: Year
2007
: DateTime
: Tempral
Range
: Centim.
: Tree
: Meas
: Meas
: TaxN
Picea. : EntN
1
: ITIS
: LocTN.
: Obs
: Tree
: Meas
: Meas
hasContext
: Year
2007
: DateTime
* Basic idea: go row-by-row through
dataset, generating individuals/triples
35.8
: Obs
: Meas
: Tempral
Range
: DBH
: Obs
: Meas
: DBH
36.2
: Centim.
: TaxN
Picea. : EntN
1
: ITIS
: LocTN.
: Obs
: Tree
: Meas
: Meas
hasContext
: Obs
: Meas
: Year
2008
: DateTime
: Meas
: DBH
33.2
: Centim.
: TaxN
Abie.
: ITIS
: EntN
2
: LocTN.4
Annotation Examples (12/18/2009)
Annotation
Dataset
observation "o1”
entity ”TemporalRange”
measurement "m1”
characteristic ”Year”
standard ”DateTime”
observation "o2”
entity “Tree”
measurement "m2" precision: "0.1”
characteristic “DBH”
standard ”Centimeter”
measurement "m3”
characteristic “TaxonomicTypeName”
standard “ITIS”
measurement "m4”
characteristic “EntityName”
standard “LocalTreeNames”
context observation “o1” relationship “Within”
map “yr" to “m1”
map “dbh” to “m2" if dbh > 0
map “spec" to “m4”
map “spp" to “m3" if spp == “piru” value=“Picea rubens”
map “spp" to “m3" if spp == “abba” value=“Abies balsamea”
yr
spec
spp
dbh
2007
1
piru
35.8
2008
1
piru
36.2
2008
2
abba
33.2
: Tempral
Range
hasContext
: Obs
: Meas
: Meas
: Year
2007
: DateTime
: Tempral
Range
: Centim.
: Tree
: Meas
: Meas
: TaxN
Picea. : EntN
1
: ITIS
: LocTN.
: Obs
: Tree
: Meas
: Meas
hasContext
: Year
2007
: DateTime
• Same Trees!! (both have name = 1)
• Same Year and year observation!!
35.8
: Obs
: Meas
: Tempral
Range
: DBH
: Obs
: Meas
: DBH
36.2
: Centim.
: TaxN
Picea. : EntN
1
: ITIS
: LocTN.
: Obs
: Tree
: Meas
: Meas
hasContext
: Obs
: Meas
: Year
2008
: DateTime
: Meas
: DBH
33.2
: Centim.
: TaxN
Abie.
: ITIS
: EntN
2
: LocTN.5
Annotation Examples (12/18/2009)
Annotation
Dataset
observation "o1” distinct yes
entity ”TemporalRange”
measurement "m1” key yes
characteristic ”Year”
standard ”DateTime”
observation "o2”
entity “Tree”
measurement "m2" precision: "0.1”
characteristic “DBH”
standard ”Centimeter”
measurement "m3”
characteristic “TaxonomicTypeName”
standard “ITIS”
measurement "m4” key yes
characteristic “EntityName”
standard “LocalTreeNames”
context observation “o1” relationship “Within”
map “yr" to “m1”
map “dbh” to “m2" if dbh > 0
map “spec" to “m4”
map “spp" to “m3" if spp == “piru” value=“Picea rubens”
map “spp" to “m3" if spp == “abba” value=“Abies balsamea”
yr
spec
spp
dbh
2007
1
piru
35.8
2008
1
piru
36.2
2008
2
abba
33.2
: Tempral
Range
hasContext
: Obs
: Meas
: Meas
: Year
2007
: DateTime
: Tempral
Range
: DBH
35.8
: Centim.
: Tree
: Meas
: Meas
: TaxN
Picea.
: EntN
: ITIS
: Obs
: Meas
: Year
2008
: Meas
: DBH
36.2
: Centim.
Every observation has an implicit
“distinct” attribute (set to “no”)
: Meas
: DBH
33.2
: Centim.
: Meas
: TaxN
: Meas
Picea. : EntN
1
: ITIS
: LocTN.
: Obs
: Tree
: Meas
: Meas
: TaxN
Abie.
: ITIS
1
: LocTN.
hasContext
: Obs
: DateTime
… and every measurement has an
implicit “key” attribute (set to “no”)
: Obs
: EntN
2
: LocTN.6
Annotation Examples (12/18/2009)
• Observation measurement keys
– Like a primary key constraint
– States that observation instances with the same measurement key
values are of the same entity instance
– Does not imply the same observation instance, unless the observation
is declared distinct
– All key measurements of an observation together form the primary
key
• Distinct observations
– Only applies if at least one key measurement is defined
– States that observation instances with the same entity instance are
the same observation instance
7
Annotation Examples (12/18/2009)
Annotation
Dataset
observation "o1” distinct yes
entity ”Plot”
measurement "m1” key yes
characteristic ”EntityName”
standard ”Nominal”
observation "o2”
entity “Tree”
measurement "m2" precision: "0.1”
characteristic “DBH”
standard ”Centimeter”
measurement "m3” key yes
characteristic “TaxonomicTypeName”
standard “ITIS”
context observation “o1” relationship “Within”
map “plt" to “m1”
map “dbh” to “m2”
map “spp" to “m3" if spp == “piru” value=“Picea rubens”
map “spp" to “m3" if spp == “abba” value=“Abies balsamea”
plt
spp
dbh
A
piru
35.8
A
piru
36.2
B
piru
33.2
: Plot
hasContext
: Obs
: Obs
: Meas
: Meas
: EntN
: DBH
A
: Nominal
: Meas
35.8
: TaxN
: Centim.
hasContext
: Obs
Here we don’t have unique ids for trees
i.e., at most one tree of a particular type
was measured (possibly multiple times)
in each plot
Picea.
: ITIS
: Meas
But, assume each spp name within a plot
uniquely identifies a tree …
: Tree
: DBH
36.2
: Meas
: TaxN
: Centim.
: Plot
: Obs
: Nominal
: ITIS
: Obs
: Meas
: Meas
: EntN
Picea.
B
: DBH
33.2
: Centim.
: Meas
: TaxN
Picea.
: ITIS
8
Annotation Examples (12/18/2009)
Annotation
Dataset
observation "o1” distinct yes
entity ”Plot”
measurement "m1” key yes
characteristic ”EntityName”
standard ”Nominal”
observation "o2”
entity “Tree”
measurement "m2" precision: "0.1”
characteristic “DBH”
standard ”Centimeter”
measurement "m3” key yes
characteristic “TaxonomicTypeName”
standard “ITIS”
context observation “o1” relationship “Within”
map “plt" to “m1”
map “dbh” to “m2”
map “spp" to “m3" if spp == “piru” value=“Picea rubens”
map “spp" to “m3" if spp == “abba” value=“Abies balsamea”
plt
spp
dbh
A
piru
35.8
A
piru
36.2
B
piru
33.2
: Plot
hasContext
: Obs
: Obs
: Meas
: Meas
: EntN
: DBH
A
: Nominal
: Meas
35.8
: TaxN
: Centim.
Picea.
: ITIS
hasContext
: Obs
: Meas
: DBH
• The Tree entity instance should
depend on the plot it is in!!! (context)
: Tree
36.2
: Meas
: TaxN
: Centim.
: Plot
: Obs
: Nominal
: ITIS
: Obs
: Meas
: Meas
: EntN
Picea.
B
: DBH
33.2
: Centim.
: Meas
: TaxN
Picea.
: ITIS
9
Annotation Examples (12/18/2009)
Annotation
Dataset
observation "o1” distinct yes
entity ”Plot”
measurement "m1” key yes
characteristic ”EntityName”
standard ”Nominal”
observation "o2”
entity “Tree”
measurement "m2" precision: "0.1”
characteristic “DBH”
standard ”Centimeter”
measurement "m3” key yes
characteristic “TaxonomicTypeName”
standard “ITIS”
context identifying yes
observation “o1”
relationship “Within”
map “plt" to “m1”
map “dbh” to “m2”
map “spp" to “m3" if spp == “piru” value=“Picea rubens”
map “spp" to “m3" if spp == “abba” value=“Abies balsamea”
plt
spp
dbh
A
piru
35.8
A
piru
36.2
B
piru
33.2
: Plot
hasContext
: Obs
: Obs
: Meas
: Meas
: EntN
: DBH
A
: Nominal
Uniqueness within context observation
Similar to a weak-entity constraint (ER)
: Meas
35.8
: TaxN
: Centim.
Picea.
: ITIS
hasContext
: Obs
: Meas
: DBH
Every context relationship has an
“identifying” qualifier (set to “no”)
: Tree
36.2
: Meas
: TaxN
: Centim.
: Plot
: Obs
: Nominal
: ITIS
: Obs
: Meas
: Meas
: EntN
Picea.
B
: DBH
33.2
: Centim.
: Tree
: Meas
: TaxN
Picea.
: ITIS
10
Annotation Examples (12/18/2009)
Representing instances …
• Annotation(AnnotId, Resource)
• Observation(ObsId, AnnotId, EntId)
• Measurement(MeasId, ObsId, MeasType, Value)
• Context(ObsId1, ObsId2, Rel)
• Relationship(RelId, RelType)
• Entity(EntId, EntType)
* Simple relational schema for OBOE models
(individuals/triples)
This could be queried itself and/or mapped to triples
Note that ObsIds are unique across annotations
Context.ObsId’s must be for the same annotation
11
Annotation Examples (12/18/2009)
Representing annotations …
•
Annotation(AnnotId, Res)
•
ObservationType(ObsTypeId, AnnotId, EntType, Unique)
•
MeasType(MeasTypeId, ObsTypeId, CharType, StdType, ProtType, Precision, Value, Key)
•
ContextType(ObsTypeId1, ObsTypeId2, RelType)
•
Map(ResAttribute, MeasType, Condition, Value)
12
Annotation Examples (12/18/2009)
Materialization Algorithm
• Start with simple case of no key, unique, and identifying
constraints
• Add these incrementally
• Define algorithm so that it works one row at a time
• Can we also define the algorithm as a view, to enable
querying through views (rewriting)?
– This was what the prolog code did …
13
Annotation Examples (12/18/2009)
MapRow(Row : Dom(A1)×Dom(A2)⋯Dom(An), AnnotId : int)
let D = []
/* D is a dictionary (ObsTypeId, Keys) → ObsId */
foreach ⟨Ai, MeasTypedId, Cond, Val⟩ in Map where satisfies(Row, Ai, Cond)
select ⟨MeasTypeId, ObsTypeId, Std, Key⟩ from MeasType for MeasTypeId
let MeasId = CreateNewId()
let Keys = GetObsTypeKeys(ObsTypeId, Row, AnnotId)
let ObsId = CreateObsId(ObsTypeId, Keys, D, Row, AnnotId)
D = D ∪ [(ObsTypeId, Keys) → ObsId]
let AiVal = GetValue(Row[Ai], Cond, Val)
insert ⟨MeasId, ObsId, Std, AiVal⟩ into Meas
end MapRow
14