Data on the Inside versus Data on the Outside

43
Data on the Inside Data on the Inside versus versus Data on the Data on the Outside Outside Pat Helland Pat Helland Architect Architect Microsoft Corporation Microsoft Corporation

description

Outline Introduction Data: Then and Now Data on the Outside Data on the Inside Representations of Data Conclusion

Transcript of Data on the Inside versus Data on the Outside

Page 1: Data on the Inside versus Data on the Outside

Data on the Inside Data on the Inside versus versus Data on the OutsideData on the OutsidePat HellandPat HellandArchitectArchitectMicrosoft CorporationMicrosoft Corporation

Page 2: Data on the Inside versus Data on the Outside

Slide 2

OutlineOutlineIntroductionIntroductionData: Then and NowData: Then and NowData on the OutsideData on the OutsideData on the InsideData on the InsideRepresentations of DataRepresentations of DataConclusionConclusion

Page 3: Data on the Inside versus Data on the Outside

Slide 3

OutlineOutlineIntroductionIntroductionData: Then and NowData: Then and NowData on the OutsideData on the OutsideData on the InsideData on the InsideRepresentations of DataRepresentations of DataConclusionConclusion

Page 4: Data on the Inside versus Data on the Outside

Slide 4

Service Oriented ArchitecturesService Oriented ArchitecturesService-OrientationService-Orientation

IndependentIndependent Services ServicesChunks of Code and DataChunks of Code and Data

InterconnectedInterconnected via Messaging via Messaging Services Communicate with MessagesServices Communicate with Messages

Nothing ElseNothing ElseNo Other Knowledge about PartnerNo Other Knowledge about Partner

May Be HeterogeneousMay Be Heterogeneous

Service-A Service-B

Actually, we’ve been Actually, we’ve been doing this for years!doing this for years!

We’re just been We’re just been making it more pervasive…making it more pervasive…

Page 5: Data on the Inside versus Data on the Outside

Slide 5

Bounding Trust via EncapsulationBounding Trust via Encapsulation

Services Only Do Limited Things for Their PartnersServices Only Do Limited Things for Their PartnersThis Is How They Bound Their TrustThis Is How They Bound Their Trust

Encapsulation Is About Bounding TrustEncapsulation Is About Bounding TrustBusiness Logic Ensures Only the Desired Operations HappenBusiness Logic Ensures Only the Desired Operations HappenNo Changes to the Data Occur Except Through Locally No Changes to the Data Occur Except Through Locally Controlled Business Logic!Controlled Business Logic!

Service

Things I’ll Do for Outsiders• Deposit• Withdrawal• Transfer• Account Balance Check

Page 6: Data on the Inside versus Data on the Outside

Slide 6

Encapsulating Both Change and ReadsEncapsulating Both Change and ReadsEncapsulating ChangeEncapsulating Change

Ensures Integrity of the Service’s WorkEnsures Integrity of the Service’s WorkEnsures Integrity of the Service’s DataEnsures Integrity of the Service’s Data

Encapsulating Exported Data for ReadEncapsulating Exported Data for ReadEnsures Privacy by Controlling What’s ExportedEnsures Privacy by Controlling What’s ExportedAllows Planning for Loose Coupling and ExpirationsAllows Planning for Loose Coupling and Expirations

E.g. Wednesday’s Price-ListE.g. Wednesday’s Price-List

Business Request

Exported Data

Sanitized Datafor Export

PrivateInternal

Data

Data

Page 7: Data on the Inside versus Data on the Outside

Slide 7

Trust and TransactionsTrust and TransactionsFor This Talk, Services Do Not Share Transactions!For This Talk, Services Do Not Share Transactions!

This Ends Up Being a Definitional (Terminology) IssueThis Ends Up Being a Definitional (Terminology) IssueClearly Some Bodies of Code Are Distrusting of Each OtherClearly Some Bodies of Code Are Distrusting of Each Other

Those Bodies of Code Will Not Hold Locks for the PartnerThose Bodies of Code Will Not Hold Locks for the PartnerServices With Intermittent Connectivity Won’t Do 2-Phase Services With Intermittent Connectivity Won’t Do 2-Phase CommitCommit

We Are Considering the Implications of These CasesWe Are Considering the Implications of These CasesThe Word Service Is Being Used for The Word Service Is Being Used for Not Sharing Transactions!Not Sharing Transactions!

Service-BService-A Atomic “ACID” Transaction

Page 8: Data on the Inside versus Data on the Outside

Slide 8

Data Inside and Outside ServicesData Inside and Outside ServicesData Is Different Inside from OutsideData Is Different Inside from Outside

Outside the ServiceOutside the ServicePassed in MessagesPassed in MessagesUnderstood by Sender and ReceiverUnderstood by Sender and ReceiverIndependent Schema Definition ImportantIndependent Schema Definition ImportantExtensibility ImportantExtensibility Important

Inside the ServiceInside the ServicePrivate to ServicePrivate to ServiceEncapsulated by Encapsulated by Service CodeService Code

DataDataSQL

MSG

MSG

Data Outside Data Outside the Servicethe Service

Data Inside Data Inside the Servicethe Service

Page 9: Data on the Inside versus Data on the Outside

Slide 9

Operators and OperandsOperators and OperandsMessages Contain Messages Contain OperatorsOperators

Requests a Business OperationRequests a Business OperationOperators Provide Business SemanticsOperators Provide Business SemanticsPart of the Contract between the Two ServicesPart of the Contract between the Two Services

OperatorOperator Messages Contain Messages Contain OperandsOperandsDetails Needed To Do the Business OperationDetails Needed To Do the Business OperationThe Sending Service Must Put Them into the MessageThe Sending Service Must Put Them into the Message

Service

Deposit

OperatorOperands

Page 10: Data on the Inside versus Data on the Outside

Slide 10

OutlineOutlineIntroductionIntroductionData: Then and NowData: Then and NowData on the OutsideData on the OutsideData on the InsideData on the InsideRepresentations of DataRepresentations of DataConclusionConclusion

Page 11: Data on the Inside versus Data on the Outside

Slide 11

Transactions and Inside DataTransactions and Inside DataTransactions Make You Feel AloneTransactions Make You Feel Alone

No One Else Manipulates the Data When You AreNo One Else Manipulates the Data When You AreTransactional SerializabilityTransactional Serializability

The Behavior Is As If a Serial Order ExistsThe Behavior Is As If a Serial Order Exists

TkTl

Tm

TnToTh

Tg TjTe

Tf

Tb

Ta

Tc

Td

Ti

These TransactionsPrecede Ti

These TransactionsFollow Ti

Ti Doesn’t Know About TheseTransactions and They Don’t

Know About Ti

TransactionSerializability

TkTl

Tm

TnToThTh

Tg TjTe

Tf

Tb

Ta

Tc

Td

Ti

These TransactionsPrecede Ti

These TransactionsFollow Ti

Ti Doesn’t Know About TheseTransactions and They Don’t

Know About Ti

TransactionSerializability

Page 12: Data on the Inside versus Data on the Outside

Slide 12

Life in the “Now”Life in the “Now”Transactions Live in the “Now” Inside ServicesTransactions Live in the “Now” Inside Services

Time Marches ForwardTime Marches ForwardTransactions Commit Transactions Commit Advancing TimeAdvancing TimeTransactions See Transactions See the Committed the Committed TransactionsTransactions

A Service’s A Service’s Biz-Logic Lives Biz-Logic Lives in the “Now”in the “Now”

Service

Each Transaction Only Sees a Simple Advancing of Time with a Clear Set of

Preceding Transactions

ServiceServiceService

Each Transaction Only Sees a Simple Advancing of Time with a Clear Set of

Preceding Transactions

Page 13: Data on the Inside versus Data on the Outside

Slide 13

Sending Unlocked Data Isn’t “Now”Sending Unlocked Data Isn’t “Now”Messages Contain Unlocked DataMessages Contain Unlocked Data

Assume No Shared TransactionsAssume No Shared TransactionsUnlocked Data May ChangeUnlocked Data May Change

Unlocking It Allows ChangeUnlocking It Allows ChangeMessages Are Not From the “Now”Messages Are Not From the “Now”

They Are From the PastThey Are From the Past

There Is No Simultaneity At a Distance!• Similar to Speed of Light• Knowledge Travels at Speed of Light• By the Time You See a Distant Object It May Have Changed!• By the Time You See a Message, the Data May Have Changed!

Services, Transactions, and Locks Bound Simultaneity!• Inside a Transaction, Things Appear Simultaneous (to Others)• Simultaneity Only Inside a Transaction!• Simultaneity Only Inside a Service!

Page 14: Data on the Inside versus Data on the Outside

Slide 14

Outside Data: a Blast from the PastOutside Data: a Blast from the Past

All Data Seen From a Distant Service Is From the “Past”All Data Seen From a Distant Service Is From the “Past”By the Time You See It, It Has Been Unlocked and May ChangeBy the Time You See It, It Has Been Unlocked and May Change

Each Service Has Its Own PerspectiveEach Service Has Its Own PerspectiveInside Data Is “Now”; Outside Data Is “Past”Inside Data Is “Now”; Outside Data Is “Past”My Inside Is Not Your Inside; My Outside Is Not Your OutsideMy Inside Is Not Your Inside; My Outside Is Not Your Outside

All Data From Distant Stars Is From the Past• 10 Light Years Away; 10 Year Old Knowledge• The Sun May Have Blown Up 5 Minutes Ago

• We Won’t Know for 3 Minutes More…

Going to SOA Is Like Going From Newtonian to Einstonian Physics• Newton’s Time Marched Forward Uniformly

• Instant Knowledge• Before SOA, Distributed Computing Many Systems Look Like One

• RPC, 2-Phase Commit, Remote Method Calls…• In Einstein’s World, Everything Is “Relative” To One’s Perspective• SOA Has “Now” Inside and the “Past” Arriving in Messages

Page 15: Data on the Inside versus Data on the Outside

Slide 15

Versioned Images of a Single SourceVersioned Images of a Single SourceA Sequence of Versions Describing Changes to DataA Sequence of Versions Describing Changes to Data

Updates FromUpdates FromOne ServiceOne Service

Owner ControlledOwner ControlledOwner Changes Owner Changes the Datathe DataSends Changes Sends Changes as Messagesas Messages

Data Is SeenData Is SeenAs AdvancingAs AdvancingVersionsVersions

ListeningPartner

Service-1

ListeningPartner

Service-5

ListeningPartner

Service-7

ListeningPartner

Service-8

Tuesday’sPrice-List

Wednesday’sPrice-List

Wednesday’sPrice-List

Wednesday’sPrice-List

Monday’sPrice-List

Tuesday’sPrice-List

Wednesday’sPrice-List

Monday’sPrice-List

Tuesday’sPrice-List

Data Owning Service

Price-List

ListeningPartner

Service-1

ListeningPartner

Service-5

ListeningPartner

Service-7

ListeningPartner

Service-8

Tuesday’sPrice-ListTuesday’sPrice-ListTuesday’sPrice-List

Wednesday’sPrice-List

Wednesday’sPrice-List

Wednesday’sPrice-List

Wednesday’sPrice-List

Wednesday’sPrice-List

Wednesday’sPrice-List

Wednesday’sPrice-List

Wednesday’sPrice-List

Wednesday’sPrice-List

Monday’sPrice-ListMonday’sPrice-ListMonday’sPrice-List

Tuesday’sPrice-ListTuesday’sPrice-ListTuesday’sPrice-List

Wednesday’sPrice-List

Wednesday’sPrice-List

Wednesday’sPrice-List

Monday’sPrice-ListMonday’sPrice-ListMonday’sPrice-List

Tuesday’sPrice-ListTuesday’sPrice-ListTuesday’sPrice-List

Data Owning Service

Price-List

Data Owning Service

Price-List

Page 16: Data on the Inside versus Data on the Outside

Slide 16

Operators: Hope for the FutureOperators: Hope for the FutureMessages May Contain OperatorsMessages May Contain Operators

Requests for Business Functionality Part of the ContractRequests for Business Functionality Part of the ContractService-B Sends an Operator to Service-AService-B Sends an Operator to Service-A

If Service-A Accepts the Operator, It Is Part of Its FutureIf Service-A Accepts the Operator, It Is Part of Its FutureIt Changes the State ofIt Changes the State ofService-AService-A

Service-B Is HopefulService-B Is HopefulIt Wants Service-A To DoIt Wants Service-A To Dothe Workthe WorkWhen It Receives a Reply,When It Receives a Reply,It’s Future Is Changed!It’s Future Is Changed!

OperatorResponse

OperatorRequest

InvokingPartner

Service-B

InvokedPartner

Service-A

Hopeful for the Future…Decides to Issue Request

Ever Hopeful,Waiting for aResponse

Hopes Fulfilled,the Future Is Now

BlithelyIgnorant andMinding Its Own Business

A Future ForeverAltered by theProcessing of theRequest fromService-B

OperatorResponseOperatorResponseOperatorResponseOperatorResponse

OperatorRequestOperatorRequestOperatorRequestOperatorRequest

InvokingPartner

Service-B

InvokedPartner

Service-A

Hopeful for the Future…Decides to Issue Request

Ever Hopeful,Waiting for aResponse

Hopes Fulfilled,the Future Is Now

BlithelyIgnorant andMinding Its Own Business

A Future ForeverAltered by theProcessing of theRequest fromService-B

Page 17: Data on the Inside versus Data on the Outside

Slide 17

Operands: Past and FutureOperands: Past and FutureOperands May Live in the PastOperands May Live in the Past

Values Published As Reference DataValues Published As Reference DataCome From Service-A’s PastCome From Service-A’s Past

Operands May Live in the FutureOperands May Live in the FutureThey May Contain a Proposed Value Submitted to Service-AThey May Contain a Proposed Value Submitted to Service-A

Service-B Preparing a Request for Service-A

Friday’s Price-ListPublished:11PM Thursday

OperatorOperands

On Friday, Operands Are Extracted from

the Price-List Publishedon Thursday

Deposit

Service-B Preparing a Request for Service-A

Friday’s Price-ListPublished:11PM Thursday

Friday’s Price-ListPublished:11PM Thursday

OperatorOperands

On Friday, Operands Are Extracted from

the Price-List Publishedon Thursday

DepositDeposit

Page 18: Data on the Inside versus Data on the Outside

Slide 18

Between Services: Life in the “Then”Between Services: Life in the “Then”Everything Between Services Lives in the Past or FutureEverything Between Services Lives in the Past or Future

Operators Live in the FutureOperators Live in the FutureOperands Live in the Past or the FutureOperands Live in the Past or the Future

It’s Not Meaningful to Speak of “Now” Between ServicesIt’s Not Meaningful to Speak of “Now” Between ServicesNo Shared Transactions No Shared Transactions No Simultaneity No Simultaneity

Life in the “Then”Life in the “Then”Past or FuturePast or FutureNot NowNot Now

Each Service HasEach Service Hasa Separate “Now”a Separate “Now”

Different TemporalDifferent TemporalEnvironments!Environments!

Service-1

Service-2

Service-4

Service-3No Notion No Notion of of ““NowNow””

in Betweenin BetweenServices!Services!

Service-1Service-1Service-1

Service-2Service-2

Service-4Service-4

Service-3Service-3No Notion No Notion of of ““NowNow””

in Betweenin BetweenServices!Services!

Page 19: Data on the Inside versus Data on the Outside

Slide 19

Services: Dealing with “Now” and “Then”Services: Dealing with “Now” and “Then”Services Make the “Now” Meet the “Then”Services Make the “Now” Meet the “Then”

Each Service Lives in Its Own “Now”Each Service Lives in Its Own “Now”Messages Come and Go Dealing with the “Then”Messages Come and Go Dealing with the “Then”The Business-Logic of the Service Must Reconcile This!!The Business-Logic of the Service Must Reconcile This!!

The World Is No Longer Flat!• SOA Is Recognizing That There Is More Than One Computer• Multiple Machines Mean Multiple Time Domains• Multiple Time Domains Mandate We Cope with Ambiguity to Allow Coexistence, Cooperation, and Joint Work

Example: Accepting an Order• A Biz Publishes Daily Prices• Probably Want to Accept Yesterday’s Prices for a While• Tolerance for Time Differences Must Be Programmed

Example: “Usually Ships in 24 Hours”• Order Processing Has Old Info• Available Inventory Not Accurate• Deliberately “Fuzzy”• Allows Both Sides to Cope with Difference in Time Domains!

Page 20: Data on the Inside versus Data on the Outside

Slide 20

OutlineOutlineIntroductionIntroductionData: Then and NowData: Then and NowData on the OutsideData on the OutsideData on the InsideData on the InsideRepresentations of DataRepresentations of DataConclusionConclusion

Page 21: Data on the Inside versus Data on the Outside

Slide 21

Immutable And/Or Versioned DataImmutable And/Or Versioned Data

Data May Be Data May Be ImmutableImmutableOnce Written, It Is UnchangeableOnce Written, It Is Unchangeable

Immutable Data Needs an IDImmutable Data Needs an IDFrom the ID, Comes the From the ID, Comes the SameSame Data DataNo Matter No Matter WhenWhen, No Matter , No Matter WhereWhere

VersionsVersions Are Immutable Are ImmutableEach New Version Is IdentifiedEach New Version Is IdentifiedGiven the Identifier, the Same Data ComesGiven the Identifier, the Same Data Comes

Version Independent IdentifiersVersion Independent IdentifiersLet You Ask for a Recent VersionLet You Ask for a Recent Version

•Windows NT4, SP1Windows NT4, SP1• The Same Set of BitsThe Same Set of Bits Every Time Every Time

New York Times; 1/6/05 New York Times; 1/6/05 • Specific Version of the Paper Specific Version of the Paper -- Contents Don’t Change -- Contents Don’t Change

Latest SP of NT4Latest SP of NT4• Definitely NT4, Definitely NT4, Results Vary Over Time Results Vary Over Time

Recent NY TimesRecent NY Times• Maybe Today’s,Maybe Today’s, Maybe Yesterday’s Maybe Yesterday’s

VersionIndependent

Page 22: Data on the Inside versus Data on the Outside

Slide 22

Immutability of MessagesImmutability of MessagesRetries are a Fact of LifeRetries are a Fact of Life

Zero or more delivery semanticsZero or more delivery semanticsMessages Must Be ImmutableMessages Must Be Immutable

Retries Must Not See Differences…Retries Must Not See Differences…Once It’s Sent, You Can’t Un-send!Once It’s Sent, You Can’t Un-send!

Service-A

Once It’s Outside,Once It’s Outside,It’s Immutable!It’s Immutable!

Page 23: Data on the Inside versus Data on the Outside

Slide 23

Stability Of DataStability Of Data

Immutability Isn’t Enough!Immutability Isn’t Enough!We Need a Common UnderstandingWe Need a Common UnderstandingPresident Bush President Bush 1990 vs. President Bush 1990 vs. President Bush 2005 2005

Stable DataStable Data Has a Clearly Understood Meaning Has a Clearly Understood MeaningThe Interpretation of Values Must Be UnambiguousThe Interpretation of Values Must Be Unambiguous

AdviceAdvice• Don’t Recycle Don’t Recycle Customer-IDs Customer-IDs

ObservationObservation• Anything CalledAnything Called “Current” Is Not Stable “Current” Is Not Stable

SuggestionSuggestion• Timestamping or Timestamping or Versioning Makes Versioning Makes Stable Data Stable Data

ObservationObservation• A Monthly Bank StatementA Monthly Bank Statement Is Stable Data Is Stable Data

Page 24: Data on the Inside versus Data on the Outside

Slide 24

Schema and Immutable MessagesSchema and Immutable MessagesWhen a Message Is Sent, It Must Be ImmutableWhen a Message Is Sent, It Must Be Immutable

It Is Crossing Temporal BoundariesIt Is Crossing Temporal BoundariesRetries Mustn’t Give Different ResultsRetries Mustn’t Give Different Results

The Message’s Schema Must Be ImmutableThe Message’s Schema Must Be ImmutableIt Makes a Mess If the Interpretation of the Message ChangesIt Makes a Mess If the Interpretation of the Message Changes

Service-AMessage

MessageSchema

Immutable Message

Immutable Schema for the Message

Schema Versions Are Immutable• A Message Should Reference a Specific Version of Its Schema• The Schema Can Then Evolve Without Invalidating the Schema for the Existing Messages…

Page 25: Data on the Inside versus Data on the Outside

Slide 25

Reference-Based Data, Immutability, Reference-Based Data, Immutability, and Directed Acyclic Graphsand Directed Acyclic Graphs

Messages Must Be Interpreted Correctly Across TimeMessages Must Be Interpreted Correctly Across TimeStable Values Are EssentialStable Values Are EssentialReferences to Other Data Must Be Unambiguous Across TimeReferences to Other Data Must Be Unambiguous Across Time

Immutable and Stable ContentsImmutable and Stable ContentsReferenced Structures Can’t Change in Content or InterpretationReferenced Structures Can’t Change in Content or InterpretationOnly Works to Reference Pre-Existing Stuff that Doesn’t ChangeOnly Works to Reference Pre-Existing Stuff that Doesn’t Change

Version Independent ReferencesVersion Independent ReferencesCan Be Used with CautionCan Be Used with CautionThe Semantics of a Structure with Version Independent The Semantics of a Structure with Version Independent References Will Change over Time… Be Careful!References Will Change over Time… Be Careful!

Data“A”

Data“B”

Data“C”

Data“D”

Data“E”

Data“F”

Data“G”

Data“H”

Msg-I

Msg-J

Page 26: Data on the Inside versus Data on the Outside

Slide 26

DAGs of HistoryDAGs of HistoryService-1

Service-2

Service-3

Service-4

Data“A1”

Data“A1.1”

Data“C1”

Data“B1”

Data“D1.1”

Data“D1”

Data“C2”

Data“B2”

Data“C2.1”

Data“D1.2”

Data“D2”

Data“C3”

Data“A2”

Data“D2.1”

Data“B3”

Data“D3”

Page 27: Data on the Inside versus Data on the Outside

Slide 27

OutlineOutlineIntroductionIntroductionData: Then and NowData: Then and NowData on the OutsideData on the OutsideData on the InsideData on the InsideRepresentations of DataRepresentations of DataConclusionConclusion

Page 28: Data on the Inside versus Data on the Outside

Slide 28

Storing Incoming DataStoring Incoming DataWhen Data Arrives from the Outside, You Store It InsideWhen Data Arrives from the Outside, You Store It Inside

Most Services Keep Incoming DataMost Services Keep Incoming DataKeep for ProcessingKeep for ProcessingKeep for AuditingKeep for Auditing

Incoming Data

Inside Data

Page 29: Data on the Inside versus Data on the Outside

Slide 29

SQL, DDL, and SerializabilitySQL, DDL, and SerializabilitySQL’s DDL (Data Definition Language) is TransactionalSQL’s DDL (Data Definition Language) is Transactional

Changes Are Made Using TransactionsChanges Are Made Using TransactionsThe Structure of the Data May Be ChangedThe Structure of the Data May Be Changed

The Interpretation After the DDL Change Is DifferentThe Interpretation After the DDL Change Is Different

DDL Lives Within the Time Scope of the DatabaseDDL Lives Within the Time Scope of the DatabaseThe Database’s Shape Evolves Over TimeThe Database’s Shape Evolves Over TimeDDL Is the Change Agent for This EvolutionDDL Is the Change Agent for This Evolution

SQL Lives in the “Now”SQL Lives in the “Now”Each Transaction’s Execution Is Meaningful Only Within the Each Transaction’s Execution Is Meaningful Only Within the Schema Definition at the Moment of Its ExecutionSchema Definition at the Moment of Its ExecutionSerializability Makes This Crisp and Well-DefinedSerializability Makes This Crisp and Well-Defined

Page 30: Data on the Inside versus Data on the Outside

Slide 30

Extensibility versus ShreddingExtensibility versus ShreddingShredding the MessageShredding the Message

The Incoming Data Is Broken Down to Relational FormThe Incoming Data Is Broken Down to Relational FormEmpowers Query and Business IntelligenceEmpowers Query and Business IntelligenceAuditing ConsiderationsAuditing Considerations

Typically, Don’t Want to Change the Message ImageTypically, Don’t Want to Change the Message ImagePreserve for AuditingPreserve for AuditingMay Keep Unshredded Version Also for Non-RepudiationMay Keep Unshredded Version Also for Non-Repudiation

ExtensibilityExtensibilityThe Sender Added Stuff You Didn’t ExpectThe Sender Added Stuff You Didn’t ExpectMay or May Not Know How Utilize ExtensionsMay or May Not Know How Utilize Extensions

Extensibility Fights Shredding!Extensibility Fights Shredding!Hard To Map Extensions To Planned Relational TablesHard To Map Extensions To Planned Relational TablesOK To Partially ShredOK To Partially Shred

Yields Partial Query BenefitsYields Partial Query Benefits

Page 31: Data on the Inside versus Data on the Outside

Slide 31

Encapsulation of Inside DataEncapsulation of Inside Data

Inside Data Is Encapsulated Behind the Inside Data Is Encapsulated Behind the Business Logic of the ServiceBusiness Logic of the Service

Access To the Data Can Be Through the LogicAccess To the Data Can Be Through the LogicOccasionally, Subsets of the Inside Data Are Filtered Occasionally, Subsets of the Inside Data Are Filtered and Shipped Outsideand Shipped Outside

Inside Data

Page 32: Data on the Inside versus Data on the Outside

Slide 32

OutlineOutlineIntroductionIntroductionData: Then and NowData: Then and NowData on the OutsideData on the OutsideData on the InsideData on the InsideRepresentations of DataRepresentations of DataConclusionConclusion

Page 33: Data on the Inside versus Data on the Outside

Slide 33

XML, SQL, and ObjectsXML, SQL, and ObjectsXMLXML

Schematized Representation of MessagesSchematized Representation of MessagesHierarchical StructureHierarchical StructureSchema Supports Schema Supports Independent DefinitionIndependent Definition and Extensibility and Extensibility

SQLSQLStores Relational Data by ValueStores Relational Data by ValueAllows You to “Allows You to “RelateRelate” Fields by ” Fields by ValuesValuesIncredibly Query CapabilitiesIncredibly Query CapabilitiesRectangular RepresentationRectangular Representation

ObjectsObjectsVery Powerful Software Engineering ToolVery Powerful Software Engineering ToolBased on Based on EncapsulationEncapsulation

DataDataSQLSQL

Page 34: Data on the Inside versus Data on the Outside

Slide 34

Bounded And Unbounded Bounded And Unbounded Data RepresentationsData Representations

Relational Is Relational Is BoundedBoundedOperations Within the DatabaseOperations Within the DatabaseValue ComparisonsValue Comparisons Only Meaningful Inside Only Meaningful InsideTightly Managed SchemaTightly Managed Schema

XML-Infoset Is XML-Infoset Is UnboundedUnboundedOpen (Extensible) Schema Open (Extensible) Schema

Contributions to Schema from Contributions to Schema from Who-Knows-WhereWho-Knows-Where

ReferencesReferences (Not Just Values) (Not Just Values)URIs Known to Be UniqueURIs Known to Be Unique

XML-Infosets Can Be Interpreted AnywhereXML-Infosets Can Be Interpreted Anywhere

Page 35: Data on the Inside versus Data on the Outside

Slide 35

Encapsulation and Anti-EncapsulationEncapsulation and Anti-Encapsulation

SQL Is Anti-EncapsulatedSQL Is Anti-EncapsulatedUPDATE WHEREUPDATE WHERE

Query/Update by Joining Anything with AnythingQuery/Update by Joining Anything with AnythingTriggers/Stored-Procs Are Not Strongly Tied to Triggers/Stored-Procs Are Not Strongly Tied to Protected DataProtected Data

XML Is Anti-EncapsulatedXML Is Anti-EncapsulatedPlease Examine My Public Schema!Please Examine My Public Schema!

Components/Objects Offer EncapsulationComponents/Objects Offer EncapsulationLong Tradition of Cheating:Long Tradition of Cheating:

Reference Passing to Shared ObjectsReference Passing to Shared ObjectsWhacking on Shared DatabaseWhacking on Shared Database

Page 36: Data on the Inside versus Data on the Outside

Slide 36

The ServiceIs a

Black Box!

A Service’s View of EncapsulationA Service’s View of EncapsulationAnti-Encapsulation Is OK in Its PlaceAnti-Encapsulation Is OK in Its Place

SQL’s Anti-Encapsulation Is Only Seen by the Local Biz-LogicSQL’s Anti-Encapsulation Is Only Seen by the Local Biz-LogicXML’s Anti-Encapsulation Only Applies to the “Public” Behavior XML’s Anti-Encapsulation Only Applies to the “Public” Behavior and Data of the Serviceand Data of the Service

Encapsulation Is Strongly Enforced by the ServiceEncapsulation Is Strongly Enforced by the ServiceNo Visibility Is Allowed to the Internals of the Service!No Visibility Is Allowed to the Internals of the Service!

Business Request

Exported Data

Sanitized Datafor Export

PrivateInternal

Data

Data

Page 37: Data on the Inside versus Data on the Outside

Slide 37

Persistent ObjectID=Y

What About Persistent Objects?What About Persistent Objects?Persistent ObjectsPersistent Objects

Encapsulated by LogicEncapsulated by LogicKept in SQLKept in SQLUses Optimistic Concurrency (Low Update)Uses Optimistic Concurrency (Low Update)

Stored as Collection of RecordsStored as Collection of RecordsMay Use Records in Many TablesMay Use Records in Many TablesKeys of Records Prefixed with Unique IDKeys of Records Prefixed with Unique ID

This is the Object IDThis is the Object IDEncapsulation by ConventionEncapsulation by Convention

Encapsulation BrokenEncapsulation Brokenby Business Intelligenceby Business Intelligence

SQL

<record>ID-X <key1>Table-B

<record>ID-X <key2><record>ID-X <key3>

<record>ID-Y <key1><record>ID-Y <key2>

Database-Key<record>ID-X <key>

Table-A

<record>ID-Y <key><record>ID-Z <key>

Database-KeyDatabase-Key

Page 38: Data on the Inside versus Data on the Outside

Slide 38

Characteristics of Inside versus OutsideCharacteristics of Inside versus Outside

Temporal Nature NOW THEN

Schema Definition

Tightly Defined:

within DB Bounds; within a Transaction

Independent Definition------

Compose-able fromIndependent Pieces

UpdateabilityClassic DB Stuff

------Assume We Need

Normalization

Write Once------

Read Many

Need for Encapsulation

Encapsulation at theService Boundary;

------Services Are Big So WeNeed Objects Inside ‘Em

Just Data------

No Behavior

Inside Data Outside Data

Queryability Classic DB StuffMust Integrate Schemas

------What Are Cross-Schema

Semantics?

Page 39: Data on the Inside versus Data on the Outside

Slide 39

Today’s Ruling TriumvirateToday’s Ruling Triumvirate

Impossible:Can’t see the data!

Problematic:Schema inconsistency

Outstanding

ArbitraryQueries

ImpossibleCan’t see the data!

Outstanding

Impossible:Centralized Schema

Independent Data Definition

Outstanding

Impossible:Open Schema

Not via SQLEnforced by DBA

Encapsulation(Controls Data)

SQL It is fantastic to compare anything to anything and combine anything with anything in Relational (within the bounded database)

XML It is possible to have independent definition of schema and data in XML-Infosets. You can independently extend, too.

Components/Objects

Provide encapsulation of data behind logic. Ensure enforcement ofbusiness rules. Eases composition of logic.

ObjectsEncapsulated Data

XMLUnbounded Schema

SQLBounded Schema

Strengths andWeaknesses

Each model’s strength is simultaneously its weakness!You can’t enhance one to add features of the other without breaking it!

Footnote: Arguably, SQL constrains the data semantics to avoid problems andXML is a superset allowing the flexibility to get into problems SQL avoids.

Page 40: Data on the Inside versus Data on the Outside

Slide 40

OutlineOutlineIntroductionIntroductionData: Then and NowData: Then and NowData on the OutsideData on the OutsideData on the InsideData on the InsideRepresentations of DataRepresentations of DataConclusionConclusion

Page 41: Data on the Inside versus Data on the Outside

Slide 41

Putting It All Together!Putting It All Together!Today, Services Need All Three!Today, Services Need All Three!

XML-Infosets: Between the ServicesXML-Infosets: Between the ServicesObjects: Objects: Implementing the Business Logic Implementing the Business LogicSQL: SQL: Storing Private Data and Messages Storing Private Data and Messages

DataDataSQLSQL

Objects ImplementObjects Implementthe Biz Logicthe Biz Logic

SQL Holds SQL Holds the Datathe Data

XML-InfoSets forXML-InfoSets forMessages Between ServicesMessages Between Services

Page 42: Data on the Inside versus Data on the Outside

Slide 42

Data Inside and Outside ServicesData Inside and Outside ServicesData Is Different Inside from OutsideData Is Different Inside from Outside

Outside the ServiceOutside the ServicePassed in MessagesPassed in MessagesUnderstood by Sender and ReceiverUnderstood by Sender and ReceiverIndependent Schema Definition ImportantIndependent Schema Definition ImportantExtensibility ImportantExtensibility Important

Inside the ServiceInside the ServicePrivate to ServicePrivate to ServiceEncapsulated by Encapsulated by Service CodeService Code

DataDataSQLSQL

MSG

MSG

Data Outside Data Outside the Servicethe Service

Data Inside Data Inside the Servicethe Service

Page 43: Data on the Inside versus Data on the Outside

Slide 43

www.PatHelland.comwww.PatHelland.com

http://blogs.msdn.com/http://blogs.msdn.com/PatHellandPatHelland

http://msdn.microsoft.com/http://msdn.microsoft.com/architecturearchitecture

ResourcesResources