SemanticModeling Aquerylanguageforthe21 st century CliffordHeath - - PowerPoint PPT Presentation

semantic modeling
SMART_READER_LITE
LIVE PREVIEW

SemanticModeling Aquerylanguageforthe21 st century CliffordHeath - - PowerPoint PPT Presentation

SemanticModeling Aquerylanguageforthe21 st century CliffordHeath Semantics Thesharedmeaningsofacommunity Expressedinfacts Here,amodelis: Standardforcomparison


slide-1
SLIDE 1

Semantic
Modeling

A
query
language
for
the
21st
century Clifford
Heath

slide-2
SLIDE 2

Semantics

  • The
shared
meanings
of
a
community
  • Expressed
in
facts

Here,
a
model
is:

  • Standard
for
comparison
  • Simplified
representation
of


the
real
world

  • NOT
a
prototype
or
mockup
slide-3
SLIDE 3

Models must be expressed in a way that allows all parties to understand and contribute to them

Communicate!

Flickr, mknowles

slide-4
SLIDE 4

ActiveFacts
project

  • Constellation
Query
Language
  • Constellation
API
  • GUI
design
tools

A project of Data Constellation

slide-5
SLIDE 5

Elementary
Facts
are
simple

e.g.
This
person
is
called
‘John’

slide-6
SLIDE 6

The
elementary
form must
be
our
code

  • Models
must
be
executable
  • Tools
must
handle
the
ramifications
slide-7
SLIDE 7

ActiveFacts
Generators

  • CQL
or
ORM2
input
  • Ruby,
SQL
output
  • Later,
C#,
Java,
etc,
or
write
your
own

All code you will see in this part is as generated

slide-8
SLIDE 8

ORM2
Example

This and all other ORM2 examples were created using NORMA, the Neumont ORM2 Architect

slide-9
SLIDE 9

CQL
and
ORM2 side
by
side

slide-10
SLIDE 10

Value
Types

ORM2:

Each
statement
creates
or
implies
two
ValueTypes

slide-11
SLIDE 11

Entity
Types

ORM2: CQL:

Custom reading:

=

slide-12
SLIDE 12

Fact
Types

ORM2: CQL:

slide-13
SLIDE 13

One­to­one

  • r
more
accurately:
slide-14
SLIDE 14

Objectified
Fact
Types

ORM2: CQL:

and
then
we
can:

slide-15
SLIDE 15

Ternary
and
higher

subset:

slide-16
SLIDE 16

Composite
Identification

ORM2: CQL:

... Two Fact Types, each with 2 readings!

slide-17
SLIDE 17

Subtypes,
etc

ORM2: CQL:

(non-identifying supertype) also: unary fact type, ring constraint, XOR constraint

slide-18
SLIDE 18

Fact
Instances

Value
Type: Entity
Type: Composite: ...
note
the
join
over
Person ...
the
contracted
form
isn’t
implemented
yet! Join
Contraction:

slide-19
SLIDE 19

Subset
constraints

slide-20
SLIDE 20

Mandatory
/
Exclusive

Mandatory
and
exclusive Also
mandatory
non­exclusive, Exclusive
non­mandatory

slide-21
SLIDE 21

Equivalence

slide-22
SLIDE 22

Join
constraints

“Product”
is
the
same
instance
in
both
clauses

slide-23
SLIDE 23

Code
Generation

slide-24
SLIDE 24

From
ORM
to
CQL

slide-25
SLIDE 25

Mapping
From
Facts
to
ER

  • Identifiers
define
keys
  • Decide
absorption using uniqueness
  • Composition
­
makes
composite
fact
types
  • Other
constraints
can
be
enforced
too

...Halpin

slide-26
SLIDE 26

SQL
Composition

slide-27
SLIDE 27

Generated
SQL
­
today

  • Tables
  • Columns
  • Primary
keys
/
Unique
constraints
  • Foreign
Key
constraints
slide-28
SLIDE 28

Generated
SQL
­
coming

  • CHECK
constraints
  • Indexes
over
views
where
needed
  • Triggers
if
nec.
  • Automatic
Migration
  • even
delayed
migration
slide-29
SLIDE 29

Generated
Ruby

slide-30
SLIDE 30
slide-31
SLIDE 31

Ruby
API

  • Uses
meta
programming
  • Relationships
create
both
methods
  • Implements
multiple
inheritance
  • Excludes
Readings
(for
now)
slide-32
SLIDE 32

No
need
to
 generate
the
code

  • Simply
‘require’
the
CQL
  • ActiveFacts
generates
and
eval’s
Ruby
  • Open
classes
allow
you
to
extend
them
  • No
need
to
edit
generated
code
slide-33
SLIDE 33

API
Documentation

  • Every
Role
has
a
method
  • ORM2
diagram
is
API
documentation
  • Could
also
generate
documentation
slide-34
SLIDE 34

<DogFood>

slide-35
SLIDE 35
slide-36
SLIDE 36

ActiveFacts uses its generated Ruby metamodel code

slide-37
SLIDE 37

Programming and Persistence

slide-38
SLIDE 38

Constellation
API

  • Constellation
is
a
population
of


fact
instances
over
a
vocabulary

slide-39
SLIDE 39

Constellation
API

  • A
Vocabulary
is
a
Ruby
module
  • Every
concept
is
a
class
  • Every
instance
is
of
a
concept

(no
raw
values)
  • No
duplicate
instances
  • Fully
cross­referenced
  • No
new()
­
just
assert
/
deny
slide-40
SLIDE 40
  • One
query
for
each
user
action
  • Each
query
yields
a
constellation
  • Assert/deny
any
facts,
then
  • One
save()
  • Constraint
enforcement
  • Changes
get
saved
transactionally

Persistence
(not
implemented
yet)

slide-41
SLIDE 41

Queries

(work
in
progress)

slide-42
SLIDE 42

Simple
Query

Person
has
given­Name
‘Daniel’?

slide-43
SLIDE 43

Deriving
Fact
Types

family­Name
controls
Company
: Person
directs
Company, Person
has
family
Name; family
Name
controls
Company
‘Acme,
Inc’? family
Name
controls
Company? family
Name
‘Heath’
controls
Company?

slide-44
SLIDE 44

Query
nesting

  • A
query
can
invoke
derived
fact
types
  • Sub­queries
return
distinct
instances

(handles
SQL’s
DISTINCT

and
GROUP
BY)

  • Aggregation
functions
as
per
SQL
  • Goal:
more
power
than
SQL
SELECT
slide-45
SLIDE 45

“returning”

family
Name
controls
Company
: Person
directs
Company, Person
has
family
Name, returning
Person, by
Company;

  • “returning”
makes
Person.given_name
available
  • “returning
by”
applies
sorting
  • Inner
join
semantics
apply
if
family
Name
is
unknown
slide-46
SLIDE 46

“returning”
is
transitive

normal
stuff
for
Person: maybe
Person
was
born
on
birth
Date, maybe
Person
is
Employee, Employee
has
EmployeeNr, returning
birth
Date,
EmployeeNr; Person
is
called
family­Name
‘Smith’, normal
stuff
for
Person?

slide-47
SLIDE 47

Transitive
queries

Employee
works
under
Manager
: Employee
is
supervised
by
Manager
[transitive]; Employee
works
under
Manager
473?

slide-48
SLIDE 48

either/or

family
Name
is
associated
with
Company
: Person
(as
Director)
directs
Company
or Person
works
at
Company, Person
has
family
Name;

slide-49
SLIDE 49

Units

large
Pane: Pane
has
Area,
Area
>=
5
foot^2;

Width
and
Height
may
be
stored
in
millimetres!

Pane
has
Area: Pane
of
glass
has
Width, Pane
of
glass
has
Height, Width
*
Height
=
Area; large
Pane?

slide-50
SLIDE 50

Date
and
Time

Person
is
adult: Person
was
born
on
birth
Date, birth
Date
<
Now
­
18
years, returning
birth
Date;

future:
“Person
was
born
on
birth
Date
before
18
years
ago”

slide-51
SLIDE 51

Future
work

  • API
Persistence
and
DBMS
adapters
  • Queries,
including
drag­drop
GUI
  • Units
support
  • Other
languages
(natural
and
computer)
  • APRIMO,
a
web­hosted
semantic
designer
  • Reverse
engineering
  • Automatic
migration
slide-52
SLIDE 52

Demonstrations and
Questions

slide-53
SLIDE 53

Clifford
Heath

Available
for
consulting
and
training

http://dataconstellation.com/