semantic modeling - a query language for the 21st century

Post on 08-Jul-2015

903 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

SemanticModelingAquerylanguageforthe21stcentury

CliffordHeath

Semantics• Thesharedmeaningsofacommunity

• Expressedinfacts

Here,amodelis:• Standardforcomparison

• Simplifiedrepresentationoftherealworld

• NOTaprototypeormockup

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

and contribute to them

Communicate!

Flickr, mknowles

ActiveFactsproject

• ConstellationQueryLanguage

• ConstellationAPI

• GUIdesigntools

A project of Data Constellation

ElementaryFactsaresimple

e.g.Thispersoniscalled‘John’

Theelementaryformmustbeourcode

•Modelsmustbeexecutable

• Toolsmusthandletheramifications

ActiveFactsGenerators

• CQLorORM2input

• Ruby,SQLoutput

• Later,C#,Java,etc,orwriteyourown

All code you will see in this part is as generated

ORM2Example

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

CQLandORM2sidebyside

ValueTypes

ORM2:

EachstatementcreatesorimpliestwoValueTypes

EntityTypes

ORM2:

CQL:=

Custom reading:

FactTypes

ORM2:

CQL:

One­to­one

ormoreaccurately:

ObjectifiedFactTypes

ORM2:

CQL:

andthenwecan:

Ternaryandhigher

subset:

CompositeIdentificationORM2:

CQL:

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

Subtypes,etc

ORM2:

CQL:

(non-identifying supertype)

also: unary fact type, ring constraint, XOR constraint

FactInstancesValueType:

EntityType:

Composite:

...notethejoinoverPerson

...thecontractedformisn’timplementedyet!

JoinContraction:

Subsetconstraints

Mandatory/Exclusive

Mandatoryandexclusive

Alsomandatorynon­exclusive,Exclusivenon­mandatory

Equivalence

Joinconstraints

“Product”isthesameinstanceinbothclauses

CodeGeneration

FromORMtoCQL

MappingFromFactstoER

• Identifiersdefinekeys

• Decideabsorption using uniqueness

• Composition­makescompositefacttypes

• Otherconstraintscanbeenforcedtoo

...Halpin

SQLComposition

GeneratedSQL­today

• Tables

• Columns

• Primarykeys/Uniqueconstraints

• ForeignKeyconstraints

GeneratedSQL­coming

•CHECKconstraints

• Indexesoverviewswhereneeded

• Triggersifnec.

• AutomaticMigration

• evendelayedmigration

GeneratedRuby

RubyAPI

•Usesmetaprogramming

• Relationshipscreatebothmethods

• Implementsmultipleinheritance

• ExcludesReadings(fornow)

Noneedtogeneratethecode

•Simply‘require’theCQL

• ActiveFactsgeneratesandeval’sRuby

•Openclassesallowyoutoextendthem

•Noneedtoeditgeneratedcode

APIDocumentation

• EveryRolehasamethod

•ORM2diagramisAPIdocumentation

• Couldalsogeneratedocumentation

<DogFood>

ActiveFacts uses its generated Ruby metamodel code

Programmingand

Persistence

ConstellationAPI

• Constellationisapopulationoffactinstancesoveravocabulary

ConstellationAPI

•AVocabularyisaRubymodule

• Everyconceptisaclass

• Everyinstanceisofaconcept(norawvalues)

• Noduplicateinstances

• Fullycross­referenced

• Nonew()­justassert/deny

•Onequeryforeachuseraction

• Eachqueryyieldsaconstellation

• Assert/denyanyfacts,then

•Onesave()

• Constraintenforcement

• Changesgetsavedtransactionally

Persistence(notimplementedyet)

Queries(workinprogress)

SimpleQuery

Personhasgiven­Name‘Daniel’?

DerivingFactTypes

family­NamecontrolsCompany:PersondirectsCompany,PersonhasfamilyName;

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

Querynesting

• Aquerycaninvokederivedfacttypes

• Sub­queriesreturndistinctinstances(handlesSQL’sDISTINCTandGROUPBY)

• AggregationfunctionsasperSQL

• Goal:morepowerthanSQLSELECT

“returning”

familyNamecontrolsCompany:PersondirectsCompany,PersonhasfamilyName,returningPerson,byCompany;

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

“returning”istransitive

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

Personiscalledfamily­Name‘Smith’,normalstuffforPerson?

Transitivequeries

EmployeeworksunderManager:EmployeeissupervisedbyManager[transitive];

EmployeeworksunderManager473?

either/or

familyNameisassociatedwithCompany:Person(asDirector)directsCompanyorPersonworksatCompany,

PersonhasfamilyName;

Units

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

WidthandHeightmaybestoredinmillimetres!

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

largePane?

DateandTime

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

future:“PersonwasbornonbirthDatebefore18yearsago”

Futurework

• APIPersistenceandDBMSadapters

• Queries,includingdrag­dropGUI

• Unitssupport

• Otherlanguages(naturalandcomputer)

• APRIMO,aweb­hostedsemanticdesigner

• Reverseengineering

• Automaticmigration

DemonstrationsandQuestions

CliffordHeathAvailableforconsultingandtraining

http://dataconstellation.com/

top related