Semantic Modeling - A Query Language for the 21st century

53
Semantic Modeling A query language for the 21 st century Clifford Heath

Transcript of Semantic Modeling - A Query Language for the 21st century

Page 1: Semantic Modeling - A Query Language for the 21st century

SemanticModelingAquerylanguageforthe21stcentury

CliffordHeath

Page 2: Semantic Modeling - A Query Language for the 21st century

Semantics• Thesharedmeaningsofacommunity

• Expressedinfacts

Here,amodelis:• Standardforcomparison

• Simplifiedrepresentationoftherealworld

• NOTaprototypeormockup

Page 3: Semantic Modeling - A Query Language for the 21st century

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

and contribute to them

Communicate!

Flickr, mknowles

Page 4: Semantic Modeling - A Query Language for the 21st century

ActiveFactsproject

• ConstellationQueryLanguage

• ConstellationAPI

• GUIdesigntools

A project of Data Constellation

Page 5: Semantic Modeling - A Query Language for the 21st century

ElementaryFactsaresimple

e.g.Thispersoniscalled‘John’

Page 6: Semantic Modeling - A Query Language for the 21st century

Theelementaryformmustbeourcode

•Modelsmustbeexecutable

• Toolsmusthandletheramifications

Page 7: Semantic Modeling - A Query Language for the 21st century

ActiveFactsGenerators

• CQLorORM2input

• Ruby,SQLoutput

• Later,C#,Java,etc,orwriteyourown

All code you will see in this part is as generated

Page 8: Semantic Modeling - A Query Language for the 21st century

ORM2Example

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

Page 9: Semantic Modeling - A Query Language for the 21st century

CQLandORM2sidebyside

Page 10: Semantic Modeling - A Query Language for the 21st century

ValueTypes

ORM2:

EachstatementcreatesorimpliestwoValueTypes

Page 11: Semantic Modeling - A Query Language for the 21st century

EntityTypes

ORM2:

CQL:=

Custom reading:

Page 12: Semantic Modeling - A Query Language for the 21st century

FactTypes

ORM2:

CQL:

Page 13: Semantic Modeling - A Query Language for the 21st century

One­to­one

ormoreaccurately:

Page 14: Semantic Modeling - A Query Language for the 21st century

ObjectifiedFactTypes

ORM2:

CQL:

andthenwecan:

Page 15: Semantic Modeling - A Query Language for the 21st century

Ternaryandhigher

subset:

Page 16: Semantic Modeling - A Query Language for the 21st century

CompositeIdentificationORM2:

CQL:

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

Page 17: Semantic Modeling - A Query Language for the 21st century

Subtypes,etc

ORM2:

CQL:

(non-identifying supertype)

also: unary fact type, ring constraint, XOR constraint

Page 18: Semantic Modeling - A Query Language for the 21st century

FactInstancesValueType:

EntityType:

Composite:

...notethejoinoverPerson

...thecontractedformisn’timplementedyet!

JoinContraction:

Page 19: Semantic Modeling - A Query Language for the 21st century

Subsetconstraints

Page 20: Semantic Modeling - A Query Language for the 21st century

Mandatory/Exclusive

Mandatoryandexclusive

Alsomandatorynon­exclusive,Exclusivenon­mandatory

Page 21: Semantic Modeling - A Query Language for the 21st century

Equivalence

Page 22: Semantic Modeling - A Query Language for the 21st century

Joinconstraints

“Product”isthesameinstanceinbothclauses

Page 23: Semantic Modeling - A Query Language for the 21st century

CodeGeneration

Page 24: Semantic Modeling - A Query Language for the 21st century

FromORMtoCQL

Page 25: Semantic Modeling - A Query Language for the 21st century

MappingFromFactstoER

• Identifiersdefinekeys

• Decideabsorption using uniqueness

• Composition­makescompositefacttypes

• Otherconstraintscanbeenforcedtoo

...Halpin

Page 26: Semantic Modeling - A Query Language for the 21st century

SQLComposition

Page 27: Semantic Modeling - A Query Language for the 21st century

GeneratedSQL­today

• Tables

• Columns

• Primarykeys/Uniqueconstraints

• ForeignKeyconstraints

Page 28: Semantic Modeling - A Query Language for the 21st century

GeneratedSQL­coming

•CHECKconstraints

• Indexesoverviewswhereneeded

• Triggersifnec.

• AutomaticMigration

• evendelayedmigration

Page 29: Semantic Modeling - A Query Language for the 21st century

GeneratedRuby

Page 30: Semantic Modeling - A Query Language for the 21st century
Page 31: Semantic Modeling - A Query Language for the 21st century

RubyAPI

•Usesmetaprogramming

• Relationshipscreatebothmethods

• Implementsmultipleinheritance

• ExcludesReadings(fornow)

Page 32: Semantic Modeling - A Query Language for the 21st century

Noneedtogeneratethecode

•Simply‘require’theCQL

• ActiveFactsgeneratesandeval’sRuby

•Openclassesallowyoutoextendthem

•Noneedtoeditgeneratedcode

Page 33: Semantic Modeling - A Query Language for the 21st century

APIDocumentation

• EveryRolehasamethod

•ORM2diagramisAPIdocumentation

• Couldalsogeneratedocumentation

Page 34: Semantic Modeling - A Query Language for the 21st century

<DogFood>

Page 35: Semantic Modeling - A Query Language for the 21st century
Page 36: Semantic Modeling - A Query Language for the 21st century

ActiveFacts uses its generated Ruby metamodel code

Page 37: Semantic Modeling - A Query Language for the 21st century

Programmingand

Persistence

Page 38: Semantic Modeling - A Query Language for the 21st century

ConstellationAPI

• Constellationisapopulationoffactinstancesoveravocabulary

Page 39: Semantic Modeling - A Query Language for the 21st century

ConstellationAPI

•AVocabularyisaRubymodule

• Everyconceptisaclass

• Everyinstanceisofaconcept(norawvalues)

• Noduplicateinstances

• Fullycross­referenced

• Nonew()­justassert/deny

Page 40: Semantic Modeling - A Query Language for the 21st century

•Onequeryforeachuseraction

• Eachqueryyieldsaconstellation

• Assert/denyanyfacts,then

•Onesave()

• Constraintenforcement

• Changesgetsavedtransactionally

Persistence(notimplementedyet)

Page 41: Semantic Modeling - A Query Language for the 21st century

Queries(workinprogress)

Page 42: Semantic Modeling - A Query Language for the 21st century

SimpleQuery

Personhasgiven­Name‘Daniel’?

Page 43: Semantic Modeling - A Query Language for the 21st century

DerivingFactTypes

family­NamecontrolsCompany:PersondirectsCompany,PersonhasfamilyName;

familyNamecontrolsCompany‘Acme,Inc’?familyNamecontrolsCompany?familyName‘Heath’controlsCompany?

Page 44: Semantic Modeling - A Query Language for the 21st century

Querynesting

• Aquerycaninvokederivedfacttypes

• Sub­queriesreturndistinctinstances(handlesSQL’sDISTINCTandGROUPBY)

• AggregationfunctionsasperSQL

• Goal:morepowerthanSQLSELECT

Page 45: Semantic Modeling - A Query Language for the 21st century

“returning”

familyNamecontrolsCompany:PersondirectsCompany,PersonhasfamilyName,returningPerson,byCompany;

• “returning”makesPerson.given_nameavailable• “returningby”appliessorting• InnerjoinsemanticsapplyiffamilyNameisunknown

Page 46: Semantic Modeling - A Query Language for the 21st century

“returning”istransitive

normalstuffforPerson:maybePersonwasbornonbirthDate,maybePersonisEmployee,EmployeehasEmployeeNr,returningbirthDate,EmployeeNr;

Personiscalledfamily­Name‘Smith’,normalstuffforPerson?

Page 47: Semantic Modeling - A Query Language for the 21st century

Transitivequeries

EmployeeworksunderManager:EmployeeissupervisedbyManager[transitive];

EmployeeworksunderManager473?

Page 48: Semantic Modeling - A Query Language for the 21st century

either/or

familyNameisassociatedwithCompany:Person(asDirector)directsCompanyorPersonworksatCompany,

PersonhasfamilyName;

Page 49: Semantic Modeling - A Query Language for the 21st century

Units

largePane:PanehasArea,Area>=5foot^2;

WidthandHeightmaybestoredinmillimetres!

PanehasArea:PaneofglasshasWidth,PaneofglasshasHeight,Width*Height=Area;

largePane?

Page 50: Semantic Modeling - A Query Language for the 21st century

DateandTime

Personisadult:PersonwasbornonbirthDate,birthDate<Now­18years,returningbirthDate;

future:“PersonwasbornonbirthDatebefore18yearsago”

Page 51: Semantic Modeling - A Query Language for the 21st century

Futurework

• APIPersistenceandDBMSadapters

• Queries,includingdrag­dropGUI

• Unitssupport

• Otherlanguages(naturalandcomputer)

• APRIMO,aweb­hostedsemanticdesigner

• Reverseengineering

• Automaticmigration

Page 52: Semantic Modeling - A Query Language for the 21st century

DemonstrationsandQuestions

Page 53: Semantic Modeling - A Query Language for the 21st century

CliffordHeathAvailableforconsultingandtraining

http://dataconstellation.com/