data access design patterns: navigating the data access maze michael pizzo software architect...
TRANSCRIPT
Data Access Design Patterns: Navigating the Data Access Maze
Michael PizzoSoftware ArchitectMicrosoft Corporation
Session Code: ARC404
AgendaAgenda
Whidbey Data AccessSystem.Data NamespaceData Access SolutionsSample Application
Whidbey Data Access SolutionsDataSets and Data ProvidersObjectSpacesSQLXML
Related TechnologiesWinFS, MBF, and ObjectSpacesObjectSpaces and Typed DataSets
Summary
Whidbey Data AccessSystem.Data NamespaceData Access SolutionsSample Application
Whidbey Data Access SolutionsDataSets and Data ProvidersObjectSpacesSQLXML
Related TechnologiesWinFS, MBF, and ObjectSpacesObjectSpaces and Typed DataSets
Summary
Tools
Client Application Model
Avalon Windows Forms
Web & Service Application Model
ASP.NET / Indigo Win FSCompact
FrameworkYukon Mobile PC Optimized
System.HelpSystem.Help
System.DrawingSystem.Drawing
System.NaturalLanguageServicesSystem.NaturalLanguageServices
Data Systems Application Model
Presentation Data
Mobile PC & Devices Application Model
Communication
Command Line
NT Service
DataSetDataSet
MappingMapping
ObjectSpacesObjectSpaces
ObjectSpaceObjectSpace
QueryQuery
SchemaSchema
ItemItem
RelationshipRelationship
MediaMedia
AudioAudio
VideoVideo
ImagesImages
System.MessagingSystem.Messaging System.DiscoverySystem.Discovery
System.DirectoryServicesSystem.DirectoryServices
System.RemotingSystem.Remoting
System.Runtime.RemotingSystem.Runtime.Remoting
ActiveDirectoryActiveDirectory
UddiUddi
System.Web.ServicesSystem.Web.Services
Web.ServiceWeb.Service
DescriptionDescription
DiscoveryDiscovery
ProtocolsProtocols
System.MessageBusSystem.MessageBus
TransportTransport
PortPort
ChannelChannel
ServiceService
QueueQueue
PubSubPubSub
RouterRouter
System.TimersSystem.Timers
System.GlobalizationSystem.Globalization
System.SerializationSystem.Serialization
System.ThreadingSystem.Threading
System.TextSystem.Text
System.DesignSystem.Design
Base & Application Services
Fundamentals
System.ComponentModelSystem.ComponentModel
System.CodeDomSystem.CodeDom
System.ReflectionSystem.Reflection
System.EnterpriseServicesSystem.EnterpriseServices
System.TransactionsSystem.Transactions
Security
System.Windows.TrustManagementSystem.Windows.TrustManagement
System.Web.SecuritySystem.Web.Security
System.MessageBus.SecuritySystem.MessageBus.Security
AuthorizationAuthorization
AccessControlAccessControl
CredentialsCredentials
CryptographyCryptography
System.Web.ConfigurationSystem.Web.Configuration
System.MessageBus.ConfigurationSystem.MessageBus.Configuration
System.ConfigurationSystem.Configuration
System.ResourcesSystem.ResourcesSystem.ManagementSystem.Management
System.DeploymentSystem.Deployment
System.DiagnosticsSystem.Diagnostics
Configuration Deployment/Management
System.WindowsSystem.Windows System.WindowsSystem.WindowsSystem.Windows.FormsSystem.Windows.Forms
System.ConsoleSystem.Console
System.ServiceProcessSystem.ServiceProcess
System.Windows.FormsSystem.Windows.Forms System.WebSystem.Web System.StorageSystem.Storage System.Data.SqlServ
erSystem.Data.SqlServer
AnimationAnimation
ControlsControls
ControlControl
DesignDesign
PanelPanel
ControlsControls
DialogsDialogs
SideBarSideBar
NotificationNotification
System.WindowsSystem.Windows
DocumentsDocuments
Text ElementText Element
ShapesShapes
ShapeShape
InkInk
UI ElementUI Element ExplorerExplorer MediaMedia
System.Windows.FormsSystem.Windows.Forms
FormsForms
ControlControl
Print DialogPrint Dialog
DesignDesign
System.Web.UISystem.Web.UI
PagePage
ControlControl
HtmlControlsHtmlControls
MobileControlsMobileControls
WebControlsWebControls
AdaptorsAdaptors
DesignDesign
PortsPorts
InteropServicesInteropServices
System.RuntimeSystem.Runtime
System.IOSystem.IO
System.CollectionsSystem.Collections
GenericGeneric
System.SearchSystem.Search
AnnotationsAnnotations
MonitoringMonitoring
LoggingLogging
RelevanceRelevance
System.DataSystem.Data
SqlClientSqlClient
SqlTypesSqlTypes
SqlXMLSqlXML
OdbcClientOdbcClient
OleDbClientOleDbClient
OracleClientOracleClient
CoreCore
ContactContact
LocationLocation
MessageMessage
DocumentDocument
EventEvent
System.StorageSystem.Storage
System.WebSystem.Web
PersonalizationPersonalization
CachingCaching
SessionStateSessionState
System.XmlSystem.Xml
SchemaSchema
SerializationSerialization
XpathXpath
QueryQuery
PermissionsPermissions
PolicyPolicy
PrincipalPrincipal
TokenToken
System.SecuritySystem.Security
System.CollaborationSystem.Collaboration
RealTimeEndpointRealTimeEndpoint
TransientDataSessionTransientDataSession
SignalingSessionSignalingSession
MediaMedia
ActivitiesActivities
HttpWebRequestHttpWebRequest
FtpWebListenerFtpWebListener
SslClientStreamSslClientStream
WebClientWebClient
System.NetSystem.Net
NetworkInformationNetworkInformation
SocketsSockets
CacheCache
System.WebSystem.Web
AdministrationAdministration
ManagementManagement
NavigationNavigation
Peer GroupPeer Group
PolicyPolicy
SerializationSerialization
CompilerServicesCompilerServices
RecognitionRecognition
System.SpeechSystem.Speech
SynthesisSynthesis
SqlClientSqlClient
ObjectSpacesObjectSpacesSqlXMLSqlXML
DataSetDataSet
What’s New In System.DataWhat’s New In System.Data
Enhancements to System.DataFeatures added to relational APIs
ADO.NET with ObjectSpacesExtending the programming model to support objects over SQL Server
ADO.NET with SQLXML Extending the programming model to support XMLAbility to query and update SQL Server as XML documents via XML Views
Enhancements to System.DataFeatures added to relational APIs
ADO.NET with ObjectSpacesExtending the programming model to support objects over SQL Server
ADO.NET with SQLXML Extending the programming model to support XMLAbility to query and update SQL Server as XML documents via XML Views
Selecting a SolutionSelecting a SolutionYou are part of the answer… …your skills…your background…your familiarityWhat are you doing with the data?
Does it contain business logic?What tools are you using with it?
What is the destination of the data?Are you exchanging it with other partners?
What type of project are you working on?
Self-contained app versus enterprise framework
You are part of the answer… …your skills…your background…your familiarityWhat are you doing with the data?
Does it contain business logic?What tools are you using with it?
What is the destination of the data?Are you exchanging it with other partners?
What type of project are you working on?
Self-contained app versus enterprise framework
ADO.NET Data Access SupportADO.NET Data Access Support
DataSet and DataSet and DataReaderDataReaderin ADO.NETin ADO.NET
ObjectSpacObjectSpaces in es in ADO.NETADO.NET
Technology Strengths Use if… Technology Strengths Use if…
SQLXML SQLXML ininADO.NETADO.NET
•Business level objectsBusiness level objects•Relational mapping via Relational mapping via metadatametadata•Decoupled from database Decoupled from database schemaschema•Smaller working set than Smaller working set than other object abstractionsother object abstractions•Interoperability. Format Interoperability. Format for the Web – B2B, A2Afor the Web – B2B, A2A•Sparse (semi-structured) Sparse (semi-structured) data data •XML Services e.g. XQuery, XML Services e.g. XQuery, XSDXSD•Relational mapping via Relational mapping via metadatametadata•Decoupled from database Decoupled from database schemaschema
•Relational (tabular) modelRelational (tabular) model•Highest performanceHighest performance•Explicit controlExplicit control•Fully exposes database Fully exposes database functionalityfunctionality
•You need a strong You need a strong business object layerbusiness object layer•You know the shape of You know the shape of the results you want to the results you want to work withwork with
•You need to query data from You need to query data from XML data sources e.g. XML Web XML data sources e.g. XML Web ServicesServices•You use vertical industry XML You use vertical industry XML schemas for content publishing schemas for content publishing e.g. XBRL, RIXML, FinXMLe.g. XBRL, RIXML, FinXML•You need to load XML You need to load XML documents into database tablesdocuments into database tables•You are using UI bound You are using UI bound controls for XMLcontrols for XML
•You are comfortable with You are comfortable with the relational modelthe relational model•You require maximum You require maximum control/performance/functioncontrol/performance/functionalityality•You are using UI bound You are using UI bound controlscontrols
Data is relational is objects is XML is DataData is relational is objects is XML is Data
ReferenceNews
TradesPositions
CustomersAccounts
NewsLoader(Windows Service)
StockInformation
(Web App)
CustomerReporting
(Web App)
TradeResolution/
History(Windows App)
PortfolioManager(Web App)
Sample ApplicationSample Application
XML
HTML
XML
XML
ObjectSpaces
DataReader
DataSet
AgendaAgenda
Whidbey Data AccessSystem.Data NamespaceData Access SolutionsSample Application
Whidbey Data Access SolutionsDataSets and Data ProvidersObjectSpacesSQLXML
Related TechnologiesWinFS, MBF, and ObjectSpacesObjectSpaces and Typed DataSets
Summary
Whidbey Data AccessSystem.Data NamespaceData Access SolutionsSample Application
Whidbey Data Access SolutionsDataSets and Data ProvidersObjectSpacesSQLXML
Related TechnologiesWinFS, MBF, and ObjectSpacesObjectSpaces and Typed DataSets
Summary
DataSets And Data ProvidersDataSets And Data Providers
OverviewArchitectureScenariosDemo
OverviewArchitectureScenariosDemo
DataSets And Data Providers: OverviewDataSets And Data Providers: Overview
Goal: Integrate manipulation of relational data with the .NET Framework
Accessing a Relational Store (.NET Data Providers)
Connecting, Executing Commands, Retrieving Results
Common in-memory representation for tabular data (DataSet)
Container of tables, columns, relations, constraintsMay be populated from any store, application, XMLConnectionless, provider-independent
Explicit ArchitecturePredictable behavior, semanticsOptimized performance
Goal: Integrate manipulation of relational data with the .NET Framework
Accessing a Relational Store (.NET Data Providers)
Connecting, Executing Commands, Retrieving Results
Common in-memory representation for tabular data (DataSet)
Container of tables, columns, relations, constraintsMay be populated from any store, application, XMLConnectionless, provider-independent
Explicit ArchitecturePredictable behavior, semanticsOptimized performance
.NET Data Provider
DataReader
CommandConnection
DataSet And Data Providers:Architecture
DataSet And Data Providers:Architecture
DataSet
DataAdapter
DataSets And Data Providers: ScenariosDataSets And Data Providers: Scenarios
Work with data as relational tablesRetrieve a single value from the databaseExecute a command and process the results as a streamBind tabular results to a Windows ClientCache a set of results in memoryRemote a collection of recordsCombine results from multiple stores
Bulk load query results into SqlServer
Work with data as relational tablesRetrieve a single value from the databaseExecute a command and process the results as a streamBind tabular results to a Windows ClientCache a set of results in memoryRemote a collection of recordsCombine results from multiple stores
Bulk load query results into SqlServer
DataSets And Data Providers
Carl PerryProgram ManagerWebData
Positions Table
System.Data Demo ArchitectureSystem.Data Demo Architecture
Account Table
Customer Information
ASP.Net Page
Reader (Paging)
Command
Trade Resolution/History
Windows Form App
Data Set
Connection
Customers TableCustomer InformationAccount Number
ConnectionData Adapter
ObjectSpacesObjectSpaces
OverviewArchitectureScenariosDemo
OverviewArchitectureScenariosDemo
ObjectSpaces: OverviewObjectSpaces: Overview
Access and manipulate data as domain objects: Customer, Order, Address
Not as tables, columns, and rowsAny CLR object of your choice can be persisted
No need to inherit from our classes
Provides a separation between business logic and data access logic
We handle the CRUD operations
Declarative mapping between objects and relational tables
Natural, easy-to-use query language: OPathSingle method call to persist a graph
Access and manipulate data as domain objects: Customer, Order, Address
Not as tables, columns, and rowsAny CLR object of your choice can be persisted
No need to inherit from our classes
Provides a separation between business logic and data access logic
We handle the CRUD operations
Declarative mapping between objects and relational tables
Natural, easy-to-use query language: OPathSingle method call to persist a graph
ObjectSpaces: ArchitectureObjectSpaces: Architecture
ObjectSpace/ObjectEngine
.NET Framework Data Provider
DataSource
ObjectSet
BusinessObject
BusinessObject
BusinessObject
ObjectReader
BusinessObject
BusinessObject
ObjectSpaces: ScenariosObjectSpaces: Scenarios
Work with a common set of data classes across development organization
Query results in terms of data classesRetrieve results as data classesWork with a set of data classes
Add new objectsMake changes to existing objectsDelete ObjectsSubmit changes back to database
Work with a common set of data classes across development organization
Query results in terms of data classesRetrieve results as data classesWork with a set of data classes
Add new objectsMake changes to existing objectsDelete ObjectsSubmit changes back to database
ObjectSpaces
Dinesh KulkarniProgram ManagerWebData
Trades Table
Positions Table
System.Data.ObjectSpaces Demo ArchitectureSystem.Data.ObjectSpaces Demo Architecture
Accounts Table
ObjectReader
ObjectSpace
Customers TableCustomer Information
Managed Provider
Query Update
TradeBusiness Objects
ASP.Net Page
SQLXMLSQLXML
OverviewArchitectureScenariosDemo
OverviewArchitectureScenariosDemo
SQLXML: OverviewSQLXML: Overview
Growing number of applications unifying under XML based interfaces
Loose couplingCoping with decentralized dataManaging sparse (semi-structured) data
SQLXML supports XML over SQLServerXML programming model for queries and updates XQuery - Full fledged XML query languageXML Views
Mapping technology to expose logical XML views of SQL Server relational tablesXML Views provide XQuery support over SQL Server.
Growing number of applications unifying under XML based interfaces
Loose couplingCoping with decentralized dataManaging sparse (semi-structured) data
SQLXML supports XML over SQLServerXML programming model for queries and updates XQuery - Full fledged XML query languageXML Views
Mapping technology to expose logical XML views of SQL Server relational tablesXML Views provide XQuery support over SQL Server.
ADO.NET With SQLXMLADO.NET With SQLXML
SQL Server database
DataSet
Data Reader
XPathDocument
XmlAdapter
XmlReader
DataAdapter
XmlViewSchema
SqlCommand XQueryProcessor (Command)
XML data sourceSQL Server database
DataSet
Data Reader
XPathDocument
XmlAdapter
XmlReader
DataAdapter
XmlViewSchema
SqlCommand XQueryProcessor (Command)
XML data source
SQLXML: ScenariosSQLXML: Scenarios
Represent data as XMLSource and sink for XML
Content management systems, B2B scenariosQueries and updates against XML Views
Loading large XML data setsBulk load data into existing relational table structure E.g. Catalog information
Transfer data as XML between databasesAgree on transfer formatApply mappings at either end
Represent data as XMLSource and sink for XML
Content management systems, B2B scenariosQueries and updates against XML Views
Loading large XML data setsBulk load data into existing relational table structure E.g. Catalog information
Transfer data as XML between databasesAgree on transfer formatApply mappings at either end
SQLXML
Alex LaskosProgram ManagerWebData
SQLXML: Demo ArchitectureSQLXML: Demo Architecture
Reference Tables
News XML FilesNews Query ASP
XQueryProcessor
XmlViewSchemaLoader Application
XmlBulkLoad
XmlViewSchema
News TableStockSymbol ArticleDateNewsXML
AgendaAgenda
Whidbey Data AccessSystem.Data NamespaceData Access SolutionsSample Application
Whidbey Data Access SolutionsDataSets and Data ProvidersObjectSpacesSQLXML
Related TechnologiesWinFS, MBF, and ObjectSpacesObjectSpaces and Typed DataSets
Summary
Whidbey Data AccessSystem.Data NamespaceData Access SolutionsSample Application
Whidbey Data Access SolutionsDataSets and Data ProvidersObjectSpacesSQLXML
Related TechnologiesWinFS, MBF, and ObjectSpacesObjectSpaces and Typed DataSets
Summary
Prescriptive Object model / Existing Storage
Prescriptive Object Model / Prescriptive Storage Model
Plain Old CLR Objects
WinFS, MBF, And ObjectSpacesWinFS, MBF, And ObjectSpaces
Programming Model
Gre
ater
Fle
xib
ility
Gre
ater
Fu
nct
ion
alit
y
ObjectSpaces
MBF
WinFS
ObjectSpaces And Typed DataSetsObjectSpaces And Typed DataSetsTyped DataSets: Strongly typed Relational
objectsCode-Gen classes for strongly typed access/navigation
ObjectSpaces: Persistence of your objectsMapping and Query Services
Typed DataSets: Strongly typed Relational objects
Code-Gen classes for strongly typed access/navigation
ObjectSpaces: Persistence of your objectsMapping and Query ServicesTyped DataSets ObjectSpaces
Work with relational data in a strongly typed manner
General object persistence
Types based on relational classes
Define your own business classes
Access to underlying datarows Encapsulates underlying dataPopulate using SQL Query in terms of ObjectsGenerated mapping in code Declarative mapping in fileIndividual application classes Shared classes across an
enterpriseVisual Studio designer experience
Explicit object modeling experience
SummarySummary
It’s all about Data…Understand the strengths of each technology
DataSet and Data ProvidersRelational ModelUltimate Performance, Control
ObjectSpacesObject ModelStrong Business Objects decoupled from storage
SQLXMLXML ModelInteroperable, self-describing format
Pick the technology appropriate to your scenarioHow results will be usedTools to be appliedYour knowledge/comfort level
It’s all about Data…Understand the strengths of each technology
DataSet and Data ProvidersRelational ModelUltimate Performance, Control
ObjectSpacesObject ModelStrong Business Objects decoupled from storage
SQLXMLXML ModelInteroperable, self-describing format
Pick the technology appropriate to your scenarioHow results will be usedTools to be appliedYour knowledge/comfort level
Related SessionsRelated Sessions
Wednesday10:00AM DAT402
Building Database Applications withSQL Server "Yukon": XQuery, XML Datatype
2:00PM ARC380.NET Framework: What's New in System.Xml for "Whidbey“
5:00PM DAT410.NET Framework: Developing Applications Using the New Object-Relational Technologies in "Whidbey“Caching Techniques for Scalable Enterprise Applications
Wednesday10:00AM DAT402
Building Database Applications withSQL Server "Yukon": XQuery, XML Datatype
2:00PM ARC380.NET Framework: What's New in System.Xml for "Whidbey“
5:00PM DAT410.NET Framework: Developing Applications Using the New Object-Relational Technologies in "Whidbey“Caching Techniques for Scalable Enterprise Applications
Other ResourcesOther Resources
“A First Look at ADO.NET and System.Xml V2” by Addison Wesley“A First Look at ADO.NET and System.Xml V2” by Addison Wesley
Questions?Questions?
SQL Server ResourcesSQL Server ResourcesWeek long SQL Server “Ask the Experts” lounge in:
Foyer outside Room 309
Support for SQL Server “Yukon” PDC Preview at SQLJunkieshttp://www.sqljunkies.com/forums
SQL Server “Yukon” FAQ Blog at SQLTeamhttp://yukonblog.sqlteam.com/
Other Key Resourceshttp://www.microsoft.com/sql/communityhttp://msdn.microsoft.com/sqlserver/34 world wide user groups,
http://msdn.microsoft.com/usergroups/find.asp
Our most active SQL Server newsgroups,Microsoft.public.sqlserver.programmingMicrosoft.public.sqlserver.serverMicrosoft.public.sqlserver.dtsMicrosoft.public.sqlserver.olapMicrosoft.public.sqlserver.setupMicrosoft.public.sqlserver.replicationMicrosoft.public.sqlserver.msde
Week long SQL Server “Ask the Experts” lounge in: Foyer outside Room 309
Support for SQL Server “Yukon” PDC Preview at SQLJunkieshttp://www.sqljunkies.com/forums
SQL Server “Yukon” FAQ Blog at SQLTeamhttp://yukonblog.sqlteam.com/
Other Key Resourceshttp://www.microsoft.com/sql/communityhttp://msdn.microsoft.com/sqlserver/34 world wide user groups,
http://msdn.microsoft.com/usergroups/find.asp
Our most active SQL Server newsgroups,Microsoft.public.sqlserver.programmingMicrosoft.public.sqlserver.serverMicrosoft.public.sqlserver.dtsMicrosoft.public.sqlserver.olapMicrosoft.public.sqlserver.setupMicrosoft.public.sqlserver.replicationMicrosoft.public.sqlserver.msde
© 2003-2004 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.