SlideShare a Scribd company logo
1 of 26
Download to read offline
From relational data to
ObjectSpaces
(…and then O/RMs)
 Andrea Saltarello
 Solution Architect @ Managed Designs
 andreas@manageddesigns.it
 http://twitter.com/andysal74
 http://blogs.ugidotnet.org/mrbrightside

    http://creativecommons.org/licenses/by-nc-nd/2.5/
Agenda
   Scenario
   Model vs. Model
   Object-relational mapping
   Object/Relational Mappers
The Scenario
   Face it: most software does access databases
   As of today, most of the time dabatase==RDBMS
   During the ’90s object based|oriented gained
    momentum
   Gentlemen prefer Blondes, and Developers
    prefer Objects
OO Recap
   Object: an identifiable, encapsulated entity that
    is interacted with by sending messages. Objects
    have behavior, state and identity
   Type: specifies the public behavior and
    conceptual grouping for objects that are
    members of the type
   Identity: the ability to tell an object apart from
    another object independently of whether their
    type and state is equal
Relational Model Recap
   Relation: a truth predicate. It defines what attributes
    are involved in the predicate and what the meaning
    of the predicate is.
     Person: {SSN#, Name, City} There exists a person with social
      security number SSN#, who has the name Name and lives in
      a city named City
   Attribute: identifies a name that participates in the
    relation and specifies the domain (type) from which
    values of the attribute must come
     Person: {SSN#: SSN, Name: string, City: string}
   Tuple: a truth statement in the context of a relation.
    Tuples are values and two tuples are identical if their
    relation and atribute values are equal.
     Person SSN#=‘123-456-78’ Name=‘Mario Rossi’ City=‘Milan’
Relational Model Recap
 Relation Value: the composition of a relation (the
  heading) and a set of tuples (the body). All the tuples
  must have the same relation as the heading. The
  body is unordered and does not contain duplicates
 Relation Variable: holds onto a single Relation Value
  at any point in time, but can change value at any
  point in time. Relvars are typed to a particular
  relation, so they will always hold relation values that
  have a heading with that relation.
 Database: a collection of relvars. It can change state
  by changing relvars and can answer questions about
  its particular state
Impedance mismatch
   Tuples have neither identity nor encapsulation
   Tuple attribute values are pure values, so they
    have no identity
   Relational modeling seems to have no way of
    representing any of the object modeling
    properties nicely (inheritance, composition, M:N
    associations, …)
Object-Relational mapping
In 1997 Mark Fussels wrote a document whose aim
   was to integrate objects into the relational model
   by means of a ‘’mapping’’ process:

  object-relational mapping is the process of
  transforming between object and relational
  modeling approaches and between the systems
  that support these approaches [FORM, 5]
Object-Relational mapping
ObjectShadow: the informations needed to see that
an object exists without any true representation of
the real object [FORM, 21]

   ObjectShadows are composed by:
     IdentityKeys: the value that represents the object’s
      identity
     Distinguishers: a value that represents the type of the
      object
   Objects are built from tuples by means of
    ObjectShadows
Here comes the O/RM
ObjectSpace: a closed, self-contained collection of
  objects based on a single (possibly very large)
  schema
Fussels own work inspired the inception of O/RM
  toolkits which:
 Allow to define an O/R mapping
 Allow to query an ObjectSpace
 Allow an ObjectSpace to be persisted onto a
  database
Demo
O/RM overview
The ObjectSpace is the Database
To make an ObjectSpace look as a ‘’DBMS’’, an
  O/RM should at least:
 Make it queryable, with support for partitioning
  of fetched data
 Support transactions
Query Object [P of EAA, 316]
A Query Object is an interpreter
  [Gang of Four], that is, a
  structure of objects that can
  form itself into a SQL query.
  You can create this query by
  referring to classes and fields
  rather than tables and
  columns. In this way those
  who write the queries can do
  so independently of the
  database schema and
  changes to the schema can
  be localized in a single place.
Query Object @ .NET
   Every O/RM ships its own query object (es:
    NHibernate’s Criteria API)
   Starting from v 3.5, .NET provides an idiomatic
    query object: LINQ
Demo
Query (Object): NH & LINQ
Repository [P of EAA, 322]
Mediates between the domain and data mapping layers
using a collection-like interface for accessing domain
objects.
Demo
Repository: NSK
Partitioning
Do you remember those old days when we run
  queries like:
  SELECT FirstName, LastName AS FamilyName
  FROM Persons

In order to fetch only the data we’re going to use?
Demo
Partitioning: NHibernate’s Projections & «LINQ
feat. Anonymous Types»
Unit of Work [P of EAA, 184]

            When you're pulling data in and
            out of a database, it's important to
            keep track of what you've
            changed. Similarly you have to
            insert new objects you create and
            remove any objects you delete.

            A Unit of Work keeps track of
            everything you do during a
            business transaction that can
            affect the database.
Demo
ISession
Identity Map [P of EAA, 195]
Ensures that each object gets loaded only once by
keeping every loaded object in a map. Looks up objects
using the map when referring to them
Demo
Identity Map
O/RM «Magic»: Object Tracking
object tracking allows an O/RM to know which
  quota of a graph has been modified so to
  dynamically generate optimized SQL code
Demo
Persistence
Books & Publications
[FORM] Foundations of Object-Relational
   Mapping, Mark L. Fussell
[P of EAA] Pattern of Enterprise Application
   Architecture, Martin Fowler, Addison-Wesley
[NSK] NSK, http://nsk.codeplex.com

More Related Content

Similar to From relational data to object spaces

OOAD unit1 introduction to object orientation
 OOAD unit1 introduction to object orientation OOAD unit1 introduction to object orientation
OOAD unit1 introduction to object orientationDr Chetan Shelke
 
Object-oriented modeling and design.pdf
Object-oriented modeling and  design.pdfObject-oriented modeling and  design.pdf
Object-oriented modeling and design.pdfSHIVAM691605
 
OOAD with UML (Interaction Diagramming)
OOAD with UML (Interaction Diagramming)OOAD with UML (Interaction Diagramming)
OOAD with UML (Interaction Diagramming)jsm1979
 
Data resource management
Data resource managementData resource management
Data resource managementNirajan Silwal
 
Modeling- Object, Dynamic and Functional
Modeling- Object, Dynamic and FunctionalModeling- Object, Dynamic and Functional
Modeling- Object, Dynamic and FunctionalRajani Bhandari
 
MIT302 Lesson 2_Advanced Database Systems.pptx
MIT302 Lesson 2_Advanced Database Systems.pptxMIT302 Lesson 2_Advanced Database Systems.pptx
MIT302 Lesson 2_Advanced Database Systems.pptxelsagalgao
 
3. Chapter Three.pdf
3. Chapter Three.pdf3. Chapter Three.pdf
3. Chapter Three.pdffikadumola
 
implementing oop_concept
 implementing oop_concept implementing oop_concept
implementing oop_conceptAmit Gupta
 
OBJECT DIAGRAM.pptx
OBJECT DIAGRAM.pptxOBJECT DIAGRAM.pptx
OBJECT DIAGRAM.pptxAhmarBilal3
 
Understanding-Objects-in-Javascript.pptx
Understanding-Objects-in-Javascript.pptxUnderstanding-Objects-in-Javascript.pptx
Understanding-Objects-in-Javascript.pptxMariaTrinidadTumanga
 
SOFTWARE ENGINEERING AND SOFTWARE PROJECT MANAGEMENT
SOFTWARE ENGINEERING AND SOFTWARE PROJECT MANAGEMENTSOFTWARE ENGINEERING AND SOFTWARE PROJECT MANAGEMENT
SOFTWARE ENGINEERING AND SOFTWARE PROJECT MANAGEMENTARAVINDRM2
 
L2s 090701234157 Phpapp02
L2s 090701234157 Phpapp02L2s 090701234157 Phpapp02
L2s 090701234157 Phpapp02google
 
Uml diagram assignment help
Uml diagram assignment helpUml diagram assignment help
Uml diagram assignment helpsmithjonny9876
 
Object Modelling Technique " ooad "
Object Modelling Technique  " ooad "Object Modelling Technique  " ooad "
Object Modelling Technique " ooad "AchrafJbr
 
Data Modeling PPT
Data Modeling PPTData Modeling PPT
Data Modeling PPTTrinath
 
Use analyzed requirements in the design of database.pptx
Use analyzed requirements in the design of database.pptxUse analyzed requirements in the design of database.pptx
Use analyzed requirements in the design of database.pptxMwangaPrayGod
 

Similar to From relational data to object spaces (20)

OOAD unit1 introduction to object orientation
 OOAD unit1 introduction to object orientation OOAD unit1 introduction to object orientation
OOAD unit1 introduction to object orientation
 
Object-oriented modeling and design.pdf
Object-oriented modeling and  design.pdfObject-oriented modeling and  design.pdf
Object-oriented modeling and design.pdf
 
Unit 2 DBMS
Unit 2 DBMSUnit 2 DBMS
Unit 2 DBMS
 
OOAD with UML (Interaction Diagramming)
OOAD with UML (Interaction Diagramming)OOAD with UML (Interaction Diagramming)
OOAD with UML (Interaction Diagramming)
 
Data resource management
Data resource managementData resource management
Data resource management
 
Modeling- Object, Dynamic and Functional
Modeling- Object, Dynamic and FunctionalModeling- Object, Dynamic and Functional
Modeling- Object, Dynamic and Functional
 
MIT302 Lesson 2_Advanced Database Systems.pptx
MIT302 Lesson 2_Advanced Database Systems.pptxMIT302 Lesson 2_Advanced Database Systems.pptx
MIT302 Lesson 2_Advanced Database Systems.pptx
 
3. Chapter Three.pdf
3. Chapter Three.pdf3. Chapter Three.pdf
3. Chapter Three.pdf
 
Chap08
Chap08Chap08
Chap08
 
implementing oop_concept
 implementing oop_concept implementing oop_concept
implementing oop_concept
 
OBJECT DIAGRAM.pptx
OBJECT DIAGRAM.pptxOBJECT DIAGRAM.pptx
OBJECT DIAGRAM.pptx
 
Understanding-Objects-in-Javascript.pptx
Understanding-Objects-in-Javascript.pptxUnderstanding-Objects-in-Javascript.pptx
Understanding-Objects-in-Javascript.pptx
 
SOFTWARE ENGINEERING AND SOFTWARE PROJECT MANAGEMENT
SOFTWARE ENGINEERING AND SOFTWARE PROJECT MANAGEMENTSOFTWARE ENGINEERING AND SOFTWARE PROJECT MANAGEMENT
SOFTWARE ENGINEERING AND SOFTWARE PROJECT MANAGEMENT
 
L2s 090701234157 Phpapp02
L2s 090701234157 Phpapp02L2s 090701234157 Phpapp02
L2s 090701234157 Phpapp02
 
Uml diagram assignment help
Uml diagram assignment helpUml diagram assignment help
Uml diagram assignment help
 
Object Modelling Technique " ooad "
Object Modelling Technique  " ooad "Object Modelling Technique  " ooad "
Object Modelling Technique " ooad "
 
Ooad unit – 1 introduction
Ooad unit – 1 introductionOoad unit – 1 introduction
Ooad unit – 1 introduction
 
Data Modeling PPT
Data Modeling PPTData Modeling PPT
Data Modeling PPT
 
Jit abhishek sarkar
Jit abhishek sarkarJit abhishek sarkar
Jit abhishek sarkar
 
Use analyzed requirements in the design of database.pptx
Use analyzed requirements in the design of database.pptxUse analyzed requirements in the design of database.pptx
Use analyzed requirements in the design of database.pptx
 

More from Andrea Saltarello

The Fine Art of Time Travelling: implementing Event Sourcing
The Fine Art of Time Travelling: implementing Event SourcingThe Fine Art of Time Travelling: implementing Event Sourcing
The Fine Art of Time Travelling: implementing Event SourcingAndrea Saltarello
 
Idiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRSIdiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRSAndrea Saltarello
 
Never Mind the Bollocks: here's the Domain Driven Design
Never Mind the Bollocks: here's the Domain Driven DesignNever Mind the Bollocks: here's the Domain Driven Design
Never Mind the Bollocks: here's the Domain Driven DesignAndrea Saltarello
 
Layered Expression Trees feat. CQRS
Layered Expression Trees feat. CQRSLayered Expression Trees feat. CQRS
Layered Expression Trees feat. CQRSAndrea Saltarello
 
How I did it (in .NET): idiomatic Domain Driven Design
How I did it (in .NET): idiomatic Domain Driven DesignHow I did it (in .NET): idiomatic Domain Driven Design
How I did it (in .NET): idiomatic Domain Driven DesignAndrea Saltarello
 
Code Contracts and Generics: implementing a LINQ-enabled Repository
Code Contracts and Generics: implementing a LINQ-enabled RepositoryCode Contracts and Generics: implementing a LINQ-enabled Repository
Code Contracts and Generics: implementing a LINQ-enabled RepositoryAndrea Saltarello
 
Idiomatic Domain Driven Design
Idiomatic Domain Driven DesignIdiomatic Domain Driven Design
Idiomatic Domain Driven DesignAndrea Saltarello
 
Build a LINQ-enabled Repository
Build a LINQ-enabled RepositoryBuild a LINQ-enabled Repository
Build a LINQ-enabled RepositoryAndrea Saltarello
 
Layered Expression Trees: una terza via (idiomatica) verso il DDD
Layered Expression Trees: una terza via (idiomatica) verso il DDDLayered Expression Trees: una terza via (idiomatica) verso il DDD
Layered Expression Trees: una terza via (idiomatica) verso il DDDAndrea Saltarello
 

More from Andrea Saltarello (12)

The Fine Art of Time Travelling: implementing Event Sourcing
The Fine Art of Time Travelling: implementing Event SourcingThe Fine Art of Time Travelling: implementing Event Sourcing
The Fine Art of Time Travelling: implementing Event Sourcing
 
ASP.NET Core essentials
ASP.NET Core essentialsASP.NET Core essentials
ASP.NET Core essentials
 
Idiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRSIdiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRS
 
Never Mind the Bollocks: here's the Domain Driven Design
Never Mind the Bollocks: here's the Domain Driven DesignNever Mind the Bollocks: here's the Domain Driven Design
Never Mind the Bollocks: here's the Domain Driven Design
 
Layered Expression Trees feat. CQRS
Layered Expression Trees feat. CQRSLayered Expression Trees feat. CQRS
Layered Expression Trees feat. CQRS
 
How I did it (in .NET): idiomatic Domain Driven Design
How I did it (in .NET): idiomatic Domain Driven DesignHow I did it (in .NET): idiomatic Domain Driven Design
How I did it (in .NET): idiomatic Domain Driven Design
 
ASP.NET MVC: Full Throttle
ASP.NET MVC: Full ThrottleASP.NET MVC: Full Throttle
ASP.NET MVC: Full Throttle
 
Code Contracts and Generics: implementing a LINQ-enabled Repository
Code Contracts and Generics: implementing a LINQ-enabled RepositoryCode Contracts and Generics: implementing a LINQ-enabled Repository
Code Contracts and Generics: implementing a LINQ-enabled Repository
 
Idiomatic Domain Driven Design
Idiomatic Domain Driven DesignIdiomatic Domain Driven Design
Idiomatic Domain Driven Design
 
Build a LINQ-enabled Repository
Build a LINQ-enabled RepositoryBuild a LINQ-enabled Repository
Build a LINQ-enabled Repository
 
Layered Expression Trees: una terza via (idiomatica) verso il DDD
Layered Expression Trees: una terza via (idiomatica) verso il DDDLayered Expression Trees: una terza via (idiomatica) verso il DDD
Layered Expression Trees: una terza via (idiomatica) verso il DDD
 
MVC2: non solo tecnologia
MVC2: non solo tecnologiaMVC2: non solo tecnologia
MVC2: non solo tecnologia
 

Recently uploaded

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

From relational data to object spaces

  • 1. From relational data to ObjectSpaces (…and then O/RMs) Andrea Saltarello Solution Architect @ Managed Designs andreas@manageddesigns.it http://twitter.com/andysal74 http://blogs.ugidotnet.org/mrbrightside http://creativecommons.org/licenses/by-nc-nd/2.5/
  • 2. Agenda  Scenario  Model vs. Model  Object-relational mapping  Object/Relational Mappers
  • 3. The Scenario  Face it: most software does access databases  As of today, most of the time dabatase==RDBMS  During the ’90s object based|oriented gained momentum  Gentlemen prefer Blondes, and Developers prefer Objects
  • 4. OO Recap  Object: an identifiable, encapsulated entity that is interacted with by sending messages. Objects have behavior, state and identity  Type: specifies the public behavior and conceptual grouping for objects that are members of the type  Identity: the ability to tell an object apart from another object independently of whether their type and state is equal
  • 5. Relational Model Recap  Relation: a truth predicate. It defines what attributes are involved in the predicate and what the meaning of the predicate is.  Person: {SSN#, Name, City} There exists a person with social security number SSN#, who has the name Name and lives in a city named City  Attribute: identifies a name that participates in the relation and specifies the domain (type) from which values of the attribute must come  Person: {SSN#: SSN, Name: string, City: string}  Tuple: a truth statement in the context of a relation. Tuples are values and two tuples are identical if their relation and atribute values are equal.  Person SSN#=‘123-456-78’ Name=‘Mario Rossi’ City=‘Milan’
  • 6. Relational Model Recap  Relation Value: the composition of a relation (the heading) and a set of tuples (the body). All the tuples must have the same relation as the heading. The body is unordered and does not contain duplicates  Relation Variable: holds onto a single Relation Value at any point in time, but can change value at any point in time. Relvars are typed to a particular relation, so they will always hold relation values that have a heading with that relation.  Database: a collection of relvars. It can change state by changing relvars and can answer questions about its particular state
  • 7. Impedance mismatch  Tuples have neither identity nor encapsulation  Tuple attribute values are pure values, so they have no identity  Relational modeling seems to have no way of representing any of the object modeling properties nicely (inheritance, composition, M:N associations, …)
  • 8. Object-Relational mapping In 1997 Mark Fussels wrote a document whose aim was to integrate objects into the relational model by means of a ‘’mapping’’ process: object-relational mapping is the process of transforming between object and relational modeling approaches and between the systems that support these approaches [FORM, 5]
  • 9. Object-Relational mapping ObjectShadow: the informations needed to see that an object exists without any true representation of the real object [FORM, 21]  ObjectShadows are composed by:  IdentityKeys: the value that represents the object’s identity  Distinguishers: a value that represents the type of the object  Objects are built from tuples by means of ObjectShadows
  • 10. Here comes the O/RM ObjectSpace: a closed, self-contained collection of objects based on a single (possibly very large) schema Fussels own work inspired the inception of O/RM toolkits which:  Allow to define an O/R mapping  Allow to query an ObjectSpace  Allow an ObjectSpace to be persisted onto a database
  • 12. The ObjectSpace is the Database To make an ObjectSpace look as a ‘’DBMS’’, an O/RM should at least:  Make it queryable, with support for partitioning of fetched data  Support transactions
  • 13. Query Object [P of EAA, 316] A Query Object is an interpreter [Gang of Four], that is, a structure of objects that can form itself into a SQL query. You can create this query by referring to classes and fields rather than tables and columns. In this way those who write the queries can do so independently of the database schema and changes to the schema can be localized in a single place.
  • 14. Query Object @ .NET  Every O/RM ships its own query object (es: NHibernate’s Criteria API)  Starting from v 3.5, .NET provides an idiomatic query object: LINQ
  • 16. Repository [P of EAA, 322] Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects.
  • 18. Partitioning Do you remember those old days when we run queries like: SELECT FirstName, LastName AS FamilyName FROM Persons In order to fetch only the data we’re going to use?
  • 19. Demo Partitioning: NHibernate’s Projections & «LINQ feat. Anonymous Types»
  • 20. Unit of Work [P of EAA, 184] When you're pulling data in and out of a database, it's important to keep track of what you've changed. Similarly you have to insert new objects you create and remove any objects you delete. A Unit of Work keeps track of everything you do during a business transaction that can affect the database.
  • 22. Identity Map [P of EAA, 195] Ensures that each object gets loaded only once by keeping every loaded object in a map. Looks up objects using the map when referring to them
  • 24. O/RM «Magic»: Object Tracking object tracking allows an O/RM to know which quota of a graph has been modified so to dynamically generate optimized SQL code
  • 26. Books & Publications [FORM] Foundations of Object-Relational Mapping, Mark L. Fussell [P of EAA] Pattern of Enterprise Application Architecture, Martin Fowler, Addison-Wesley [NSK] NSK, http://nsk.codeplex.com