SlideShare a Scribd company logo
OR Impedance Mismatch
OR Impedance Mismatch Conflicting type systems Conflicting design goals Database system focuses specifically on the storage and retrieval of data, whereas an object system focuses specifically on the union of state and behavior for easier programmer manipulation Conflicting architectural style Most database products are built to assume a fundamentally client/server style of interaction, assuming the database is located elsewhere on the network, and programs accessing the database will be doing so via some sort of remote access protocol. Object systems assume the precise opposite, and in fact, perform significantly worse when distributed. Differing structural relationships Relational data stores track entities in terms of relations between tuples and tuplesets; object-oriented systems instead prefer to track entities in terms of classes, compilation of state and behavior that relates to one another through IS-A and/or HAS-A style unidirectional connections. Where databases use foreign-key relationships to indicate relations, objects use references or pointers
OR Impedance Mismatch Differing identity constructs Object systems use an implicit sense of identity to distinguish between objects of similar state (the ubiquitous this pointer or reference), yet databases require that sense of identity to be explicit via primary key column or columns. In fact, in modern object-oriented languages an object system cannot be built without a sense of object identity, whereas relational tables can have no primary key whatsoever, if desired. Transactional boundaries Object systems do not have any sense of "transactional demarcation" when working with the objects, whereas database instances must in order to deal with the multi-user requirements of a modern client/server-based system . Query/access capabilities Retrieving data stored in a relational database makes use of SQL, a declarative language predicated on the mathematical theory of relational algebra and predicate. In object systems, the entire object is required in order to navigate from one object to the next, meaning that the entire graph of objects is necessary in order to find two disparate parts of data—for a system intended to remain entirely in working memory, this is of no concern, but for a system whose principal access is intended to be distributed, as relational database are, this can be a crippling problem.
Object Relational Mapping Wikipedia  defines an ORM as: “a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages. This creates, in effect, a "virtual object database," which can be used from within the programming language.” An ORM has to provide a facility to map database tables to domain objects, using a design surface or wizard. This mapping is in-between your database and domain model, independent from the source code and the database. The ORM runtime then converts the commands issued by the domain model against the mapping into back end database retrieval and SQL statements. Mapping allows an application to deal seamlessly with several different database models, or even databases.
The LINQ Project Standard Query Operators DLinq (ADO.NET) XLinq (System.Xml) .NET Language Integrated Query C# VB Others… Objects <book> <title/> <author/> <year/> <price/> </book> XML SQL WinFS
Data Access In APIs Today SqlConnection c = new SqlConnection(…); c.Open();  SqlCommand cmd = new SqlCommand( @&quot;SELECT c.Name, c.Phone   FROM Customers c   WHERE c.City = @p0&quot; ); cmd.Parameters.AddWithValue(&quot;@po&quot;, &quot;London&quot;);  DataReader dr = c.Execute(cmd);  while (dr.Read()) { string name = dr.GetString(0); string phone = dr.GetString(1); DateTime date = dr.GetDateTime(2); } dr.Close(); Queries in quotes Arguments loosely bound Results loosely typed Compiler cannot help catch mistakes
Data Access with DLINQ public class Customer { public int Id; public string Name; public string Phone; … } Table<Customer> customers = db.Customers; var contacts = from c in customers where c.City == &quot;London&quot; select new { c.Name, c.Phone }; Classes describe data Tables are collections Query is natural part of the language The compiler helps you out
DLinq For Relational Data public class Customer {  …  } public class Northwind: DataContext { public Table<Customer> Customers; … } Northwind db = new Northwind( … ); var contacts = from c in db.Customers where c.City == &quot;London&quot; select new { c.Name, c.Phone }; Accessing   data with DLinq Classes  describe data Strongly typed  connection Integrated  query syntax Strongly typed  results Tables are  like collections
Architecture LINQ Query Objects SubmitChanges() SQL Query from c in db.Customers where c.City == &quot;London&quot; select  new { c.Name, c.Phone } select Name, Phone from customers where city = 'London' Rows SQL or Stored Procs DLinq (ADO.NET) SQLServer Application Services: - Change tracking - Concurrency control - Object identity
Key Takeaways Language integrated data access Maps tables and rows to classes and objects Builds on ADO.NET and .NET Transactions Mapping Encoded in attributes Relationships map to properties Manually authored or tool generated Persistence Automatic change tracking Updates through SQL or stored procedures DataContext Strongly typed database
Querying For Objects
Key Takeaways Language Integrated Query Compile-time type checking, IntelliSense SQL-like query syntax With support for hierarchy and relationships Intelligent object loading Deferred or immediate
Updating Objects
Key Takeaways Auto-generated updates Using optimistic concurrency Transactions Integrates with System.Transactions SQL pass-through Returning objects from SQL queries
DLinq Summary Allows access to relational data as objects Supports Language Integrated Query Works with existing infrastructure Unifies programming model for objects, relational and XML
When to Use LINQ to SQL? The primary scenario for using LINQ to SQL is when building applications with a rapid development cycle and a simple one-to-one object to relational mapping against the Microsoft SQL Server family of databases. In other words, when building an application whose object model is structured very similarly to the existing database structure, or when a database for the application does not yet exist and there is no predisposition against creating a database schema that mirrors the object model
When to Use LINQ to SQL? I want to… LINQ to SQL is applicable Use an ORM solution and my database is 1:1 with my object model Use an ORM solution with inheritance hierarchies that are stored in a single table Use my own plain CLR classes instead of using generated classes or deriving from a base class or implementing an interface Leverage LINQ as the way I write queries Use an ORM but I want something that is very performant and where I can optimize performance through stored procedures and compiled queries

More Related Content

PDF
Deep dive into the native multi model database ArangoDB
RTF
Bdc Screens
PPT
PPT
Web service
PPTX
Nosql
PDF
AvocadoDB query language (DRAFT!)
PPTX
PPTX
Presentation1
Deep dive into the native multi model database ArangoDB
Bdc Screens
Web service
Nosql
AvocadoDB query language (DRAFT!)
Presentation1

What's hot (20)

PDF
Introduction to column oriented databases
PPTX
Data base connectivity and flex grid in vb
PDF
Introduction and overview ArangoDB query language AQL
PPTX
3. ADO.NET
PPT
Data Connection using ADO DC
PPTX
Fyp presentation 2 (SQL Converter)
PPTX
Silverlight Developer Introduction
PPT
Semantic RDF based integration framework for heterogeneous XML data sources
PPTX
Web based database application design using vb.net and sql server
PPT
ADO CONTROLS - Database usage
PPT
Database programming in vb net
PPTX
Database application and design
PPTX
Grid Vew Control VB
PPSX
Annotating search results from web databases-IEEE Transaction Paper 2013
PPT
ASP.NET 09 - ADO.NET
DOCX
Data mining with ms access
PDF
Domain Driven Design and NoSQL TLV
PPT
PPT
Ado.net
PDF
Part2- The Atomic Information Resource
Introduction to column oriented databases
Data base connectivity and flex grid in vb
Introduction and overview ArangoDB query language AQL
3. ADO.NET
Data Connection using ADO DC
Fyp presentation 2 (SQL Converter)
Silverlight Developer Introduction
Semantic RDF based integration framework for heterogeneous XML data sources
Web based database application design using vb.net and sql server
ADO CONTROLS - Database usage
Database programming in vb net
Database application and design
Grid Vew Control VB
Annotating search results from web databases-IEEE Transaction Paper 2013
ASP.NET 09 - ADO.NET
Data mining with ms access
Domain Driven Design and NoSQL TLV
Ado.net
Part2- The Atomic Information Resource
Ad

Similar to L2s 090701234157 Phpapp02 (20)

PPT
Object Relational Mapping with LINQ To SQL
PPTX
Unit 2
PPT
Document Databases & RavenDB
PPT
Dbms & prog lang
PPTX
Building N Tier Applications With Entity Framework Services 2010
PPTX
Building nTier Applications with Entity Framework Services (Part 1)
PPT
Open Conceptual Data Models
PPTX
Arches Getty Brownbag Talk
PPTX
NHibernate
PPTX
Building nTier Applications with Entity Framework Services (Part 1)
PPTX
3.Implementation with NOSQL databases Document Databases (Mongodb).pptx
PPT
Introduction to ado
PDF
No sql databases
PDF
The Glory of Rest
PPTX
PPT temp.pptx
PPTX
111111112222223333335555555666Unit-4.pptx
PPTX
NoSQL Basics and MongDB
PDF
Free Hibernate Tutorial | VirtualNuggets
PPTX
Ado.net
PDF
dvprimer-concepts
Object Relational Mapping with LINQ To SQL
Unit 2
Document Databases & RavenDB
Dbms & prog lang
Building N Tier Applications With Entity Framework Services 2010
Building nTier Applications with Entity Framework Services (Part 1)
Open Conceptual Data Models
Arches Getty Brownbag Talk
NHibernate
Building nTier Applications with Entity Framework Services (Part 1)
3.Implementation with NOSQL databases Document Databases (Mongodb).pptx
Introduction to ado
No sql databases
The Glory of Rest
PPT temp.pptx
111111112222223333335555555666Unit-4.pptx
NoSQL Basics and MongDB
Free Hibernate Tutorial | VirtualNuggets
Ado.net
dvprimer-concepts
Ad

More from google (12)

PPT
Rolling Linq Wcf Silverlight Old4830
PPT
Linq To Sql 1221970293242272 9
PPT
Linq 1207579553462901 8
PPT
Linq E Ef 1207668728621762 9
PPT
Linq 1224887336792847 9
PPT
Linq 090701233237 Phpapp01
PPT
Introduccion A Linq 1205779028184546 5
PPTX
Seminarv2 0 090609060123 Phpapp01
PPTX
Linqtosql 090629035715 Phpapp01
PPTX
Linq 090611123548 Phpapp02
PPTX
Kdahlby 200908 Stldodn Linqinternals 090903222505 Phpapp01
DOC
Linq
Rolling Linq Wcf Silverlight Old4830
Linq To Sql 1221970293242272 9
Linq 1207579553462901 8
Linq E Ef 1207668728621762 9
Linq 1224887336792847 9
Linq 090701233237 Phpapp01
Introduccion A Linq 1205779028184546 5
Seminarv2 0 090609060123 Phpapp01
Linqtosql 090629035715 Phpapp01
Linq 090611123548 Phpapp02
Kdahlby 200908 Stldodn Linqinternals 090903222505 Phpapp01
Linq

Recently uploaded (20)

PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPT
Teaching material agriculture food technology
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
KodekX | Application Modernization Development
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
sap open course for s4hana steps from ECC to s4
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Electronic commerce courselecture one. Pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation_ Review paper, used for researhc scholars
Reach Out and Touch Someone: Haptics and Empathic Computing
Teaching material agriculture food technology
Understanding_Digital_Forensics_Presentation.pptx
Machine learning based COVID-19 study performance prediction
Building Integrated photovoltaic BIPV_UPV.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
KodekX | Application Modernization Development
Dropbox Q2 2025 Financial Results & Investor Presentation
sap open course for s4hana steps from ECC to s4
MIND Revenue Release Quarter 2 2025 Press Release
Electronic commerce courselecture one. Pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Unlocking AI with Model Context Protocol (MCP)
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
MYSQL Presentation for SQL database connectivity
Encapsulation_ Review paper, used for researhc scholars

L2s 090701234157 Phpapp02

  • 2. OR Impedance Mismatch Conflicting type systems Conflicting design goals Database system focuses specifically on the storage and retrieval of data, whereas an object system focuses specifically on the union of state and behavior for easier programmer manipulation Conflicting architectural style Most database products are built to assume a fundamentally client/server style of interaction, assuming the database is located elsewhere on the network, and programs accessing the database will be doing so via some sort of remote access protocol. Object systems assume the precise opposite, and in fact, perform significantly worse when distributed. Differing structural relationships Relational data stores track entities in terms of relations between tuples and tuplesets; object-oriented systems instead prefer to track entities in terms of classes, compilation of state and behavior that relates to one another through IS-A and/or HAS-A style unidirectional connections. Where databases use foreign-key relationships to indicate relations, objects use references or pointers
  • 3. OR Impedance Mismatch Differing identity constructs Object systems use an implicit sense of identity to distinguish between objects of similar state (the ubiquitous this pointer or reference), yet databases require that sense of identity to be explicit via primary key column or columns. In fact, in modern object-oriented languages an object system cannot be built without a sense of object identity, whereas relational tables can have no primary key whatsoever, if desired. Transactional boundaries Object systems do not have any sense of &quot;transactional demarcation&quot; when working with the objects, whereas database instances must in order to deal with the multi-user requirements of a modern client/server-based system . Query/access capabilities Retrieving data stored in a relational database makes use of SQL, a declarative language predicated on the mathematical theory of relational algebra and predicate. In object systems, the entire object is required in order to navigate from one object to the next, meaning that the entire graph of objects is necessary in order to find two disparate parts of data—for a system intended to remain entirely in working memory, this is of no concern, but for a system whose principal access is intended to be distributed, as relational database are, this can be a crippling problem.
  • 4. Object Relational Mapping Wikipedia defines an ORM as: “a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages. This creates, in effect, a &quot;virtual object database,&quot; which can be used from within the programming language.” An ORM has to provide a facility to map database tables to domain objects, using a design surface or wizard. This mapping is in-between your database and domain model, independent from the source code and the database. The ORM runtime then converts the commands issued by the domain model against the mapping into back end database retrieval and SQL statements. Mapping allows an application to deal seamlessly with several different database models, or even databases.
  • 5. The LINQ Project Standard Query Operators DLinq (ADO.NET) XLinq (System.Xml) .NET Language Integrated Query C# VB Others… Objects <book> <title/> <author/> <year/> <price/> </book> XML SQL WinFS
  • 6. Data Access In APIs Today SqlConnection c = new SqlConnection(…); c.Open(); SqlCommand cmd = new SqlCommand( @&quot;SELECT c.Name, c.Phone FROM Customers c WHERE c.City = @p0&quot; ); cmd.Parameters.AddWithValue(&quot;@po&quot;, &quot;London&quot;); DataReader dr = c.Execute(cmd); while (dr.Read()) { string name = dr.GetString(0); string phone = dr.GetString(1); DateTime date = dr.GetDateTime(2); } dr.Close(); Queries in quotes Arguments loosely bound Results loosely typed Compiler cannot help catch mistakes
  • 7. Data Access with DLINQ public class Customer { public int Id; public string Name; public string Phone; … } Table<Customer> customers = db.Customers; var contacts = from c in customers where c.City == &quot;London&quot; select new { c.Name, c.Phone }; Classes describe data Tables are collections Query is natural part of the language The compiler helps you out
  • 8. DLinq For Relational Data public class Customer { … } public class Northwind: DataContext { public Table<Customer> Customers; … } Northwind db = new Northwind( … ); var contacts = from c in db.Customers where c.City == &quot;London&quot; select new { c.Name, c.Phone }; Accessing data with DLinq Classes describe data Strongly typed connection Integrated query syntax Strongly typed results Tables are like collections
  • 9. Architecture LINQ Query Objects SubmitChanges() SQL Query from c in db.Customers where c.City == &quot;London&quot; select new { c.Name, c.Phone } select Name, Phone from customers where city = 'London' Rows SQL or Stored Procs DLinq (ADO.NET) SQLServer Application Services: - Change tracking - Concurrency control - Object identity
  • 10. Key Takeaways Language integrated data access Maps tables and rows to classes and objects Builds on ADO.NET and .NET Transactions Mapping Encoded in attributes Relationships map to properties Manually authored or tool generated Persistence Automatic change tracking Updates through SQL or stored procedures DataContext Strongly typed database
  • 12. Key Takeaways Language Integrated Query Compile-time type checking, IntelliSense SQL-like query syntax With support for hierarchy and relationships Intelligent object loading Deferred or immediate
  • 14. Key Takeaways Auto-generated updates Using optimistic concurrency Transactions Integrates with System.Transactions SQL pass-through Returning objects from SQL queries
  • 15. DLinq Summary Allows access to relational data as objects Supports Language Integrated Query Works with existing infrastructure Unifies programming model for objects, relational and XML
  • 16. When to Use LINQ to SQL? The primary scenario for using LINQ to SQL is when building applications with a rapid development cycle and a simple one-to-one object to relational mapping against the Microsoft SQL Server family of databases. In other words, when building an application whose object model is structured very similarly to the existing database structure, or when a database for the application does not yet exist and there is no predisposition against creating a database schema that mirrors the object model
  • 17. When to Use LINQ to SQL? I want to… LINQ to SQL is applicable Use an ORM solution and my database is 1:1 with my object model Use an ORM solution with inheritance hierarchies that are stored in a single table Use my own plain CLR classes instead of using generated classes or deriving from a base class or implementing an interface Leverage LINQ as the way I write queries Use an ORM but I want something that is very performant and where I can optimize performance through stored procedures and compiled queries

Editor's Notes

  • #2: 09/13/09 07:13 ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • #3: 09/13/09 07:13 ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • #4: 09/13/09 07:13 ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • #5: 09/13/09 07:13 ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • #12: 09/13/09 07:13 ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • #13: 09/13/09 07:13 ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • #14: 09/13/09 07:13 ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • #15: 09/13/09 07:13 ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • #16: 09/13/09 07:13 ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • #17: 09/13/09 07:13 ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • #18: 09/13/09 07:13 ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.