Upload
maddox
View
14
Download
1
Tags:
Embed Size (px)
DESCRIPTION
Trends in Database Development: XML, .NET, WinFS. Alexander Vaschillo Microsoft. Database development. Relational model is working well Benchmarks Security Enhancements New models Hierarchical (XML) Object Ease of use New uses WinFS. New Directions in SQL Server. XML - PowerPoint PPT Presentation
Citation preview
Trends in Database Development: XML, .NET, WinFSTrends in Database Development: XML, .NET, WinFS
Alexander VaschilloMicrosoftAlexander VaschilloMicrosoft
Database developmentDatabase development
Relational model is working wellBenchmarksSecurityEnhancements
New modelsHierarchical (XML)Object
Ease of useNew uses
WinFS
Relational model is working wellBenchmarksSecurityEnhancements
New modelsHierarchical (XML)Object
Ease of useNew uses
WinFS
New Directions in SQL ServerNew Directions in SQL Server
XMLHierarchical, semi-structured data
Object oriented extensionsNew programming models.NET integration
ServerClient
New applicationsWinFS
XMLHierarchical, semi-structured data
Object oriented extensionsNew programming models.NET integration
ServerClient
New applicationsWinFS
Why new data modelsWhy new data models
Flat relational result is good to print reportsHierarchical result is ideal for Web PagesObject data model is for programming against
DatasetObjectspacesWeb Services
Flat relational result is good to print reportsHierarchical result is ideal for Web PagesObject data model is for programming against
DatasetObjectspacesWeb Services
Why XML?Why XML?
Presentation formatTransport formatPlatform independentText-based formatSchema with dataInternational standard not owned by any one company
Presentation formatTransport formatPlatform independentText-based formatSchema with dataInternational standard not owned by any one company
HTTP Access Via URLHTTP Access Via URLURL Queryhttp://server/vroot?sql=select+*+from+Customers+FOR+XML+Auto&root=root
XML Viewhttp://server/vroot/schema.xsd
/Customer[@ID='ALFKI']?params
Templatehttp://server/vroot/template.xml?params
URL Queryhttp://server/vroot?sql=select+*+from+Customers+FOR+XML+Auto&root=root
XML Viewhttp://server/vroot/schema.xsd
/Customer[@ID='ALFKI']?params
Templatehttp://server/vroot/template.xml?params
Loosely Coupled SystemsLoosely Coupled Systems
Scalable. Many to Many.Changes in Implementation do not break each other
Scalable. Many to Many.Changes in Implementation do not break each other
AppAppLogicLogic DataDataMappingMapping MappingMapping
Application SystemApplication System Data SystemData System
ObjectObject(XML)(XML)
Move data in a standardized format (XML)Move data in a standardized format (XML)
The Two WorldsThe Two Worlds
SQLSQLServerServer
RowSetRowSet
SQLSQL
Relational Relational worldworld
LanguageLanguage
Data Data storagestorage
Data Data outputoutput
XML XML worldworld
XMLXMLFilesFiles
XPathXPathXQueryXQuery
XML/XML/HTMLHTML
XMLXMLViewView
SQLXML SQLXML – –
Bringing Bringing worlds worlds
togethertogether
Three WorldsThree Worlds
SQLSQLServerServer
RowSetRowSet
SQLSQL
Relational Relational worldworld
XML XML worldworld
XMLXMLFilesFiles
XPathXPathXQueryXQuery
XML/XML/HTMLHTML
MapMapMemoryMemory
ObjectObject
C#,C++,C#,C++,VBVB
Object Object worldworld
MapMap
Different kinds of dataDifferent kinds of data
StructuredHighly regular, homogeneous structureRowsets, Comma delimited files
Semi-StructuredHeterogeneous structureSparse Occurrences of dataHTML and XML documents
UnstructuredDocuments/Content
StructuredHighly regular, homogeneous structureRowsets, Comma delimited files
Semi-StructuredHeterogeneous structureSparse Occurrences of dataHTML and XML documents
UnstructuredDocuments/Content
SQLXML From 10,000 FeetSQLXML From 10,000 FeetProvides a rich XML view of relational dataSemi-structured, hierarchical view of flat relational dataTwo-way view: query and updateMultiple access mechanisms (HTTP, ADO, ADO.NET, SOAP)Middle tier and Server sideXML: extensible, platform independent format for your data
Provides a rich XML view of relational dataSemi-structured, hierarchical view of flat relational dataTwo-way view: query and updateMultiple access mechanisms (HTTP, ADO, ADO.NET, SOAP)Middle tier and Server sideXML: extensible, platform independent format for your data
FOR XML QueryFOR XML Query
SQL Language ExtensionSELECT…FROM…WHERE…ORDER BY…FOR XML ( raw |
auto [, ELEMENTS] |nested [,
ELEMENTS] |explicit)
[, XMLData] [, BINARY base64])
SQL Language ExtensionSELECT…FROM…WHERE…ORDER BY…FOR XML ( raw |
auto [, ELEMENTS] |nested [,
ELEMENTS] |explicit)
[, XMLData] [, BINARY base64])
XML ViewsXML Views
Map between relational data and XMLDeclarativeNoninvasive
No changes to legacy data sourcesNo control over DB Server required
XML View is an XML SchemaXSD for SQLXML 2.0 and 3.0MSD for Yukon
Map between relational data and XMLDeclarativeNoninvasive
No changes to legacy data sourcesNo control over DB Server required
XML View is an XML SchemaXSD for SQLXML 2.0 and 3.0MSD for Yukon
XSD Mapping ExampleXSD Mapping Example<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:mapping-schema"> <xsd:element name="Customer" msdata:relation="Customers"> <xsd:complexType> <xsd:sequence> <xsd:element name="Order" msdata:relation="Orders"> <xsd:annotation><xsd:appinfo> <msdata:relationship
parent="Customers" parent-key="CustomerID" child="Orders" child-key="CustomerID" /> </xsd:appinfo></xsd:annotation> <xsd:complexType>
<xsd:attribute name="OrderDate" type="xsd:dateTime"/> </xsd:complexType> </xsd:element> </xsd:sequence> <xsd:attribute name="CustomerID" /> </xsd:complexType> </xsd:element></xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:mapping-schema"> <xsd:element name="Customer" msdata:relation="Customers"> <xsd:complexType> <xsd:sequence> <xsd:element name="Order" msdata:relation="Orders"> <xsd:annotation><xsd:appinfo> <msdata:relationship
parent="Customers" parent-key="CustomerID" child="Orders" child-key="CustomerID" /> </xsd:appinfo></xsd:annotation> <xsd:complexType>
<xsd:attribute name="OrderDate" type="xsd:dateTime"/> </xsd:complexType> </xsd:element> </xsd:sequence> <xsd:attribute name="CustomerID" /> </xsd:complexType> </xsd:element></xsd:schema>
XPath/XQuery
Use XPath/XQuery to query SQL Database as if it was an XML fileEach query translates into a SQL statementXPath
/Customer/Order[@OrderID=‘10692’]
XQueryFor $i in sql:table('Customers', 'CustomerID') Return <Customer
ID = {$i/@CustomerID} Name = {$i/@ContactName}
/>
XML data typeNative SQL typeUse for column, variable or parameter
CREATE TABLE docs (id INT PRIMARY KEY, xDoc XML NOT NULL)
Store un-typed or typed XML instancesWell-formed and validation checksOptional XML Schema enforcementXML instances stored as LOB (2GB)
Efficient binary representation
XML data typeNative SQL typeUse for column, variable or parameter
CREATE TABLE docs (id INT PRIMARY KEY, xDoc XML NOT NULL)
Store un-typed or typed XML instancesWell-formed and validation checksOptional XML Schema enforcementXML instances stored as LOB (2GB)
Efficient binary representation
Native XML StoreXML Data TypeNative XML StoreXML Data Type
Native XML StoreXML IndexNative XML StoreXML Index
Create XML index on XML columnCREATE XML INDEX idx_1 ON docs (xDoc)
Creates indexes on tags, values & pathsSpeeds up queries
Entire query is optimizedSame industry leading cost based optimizer
Indexes are used as available
Create XML index on XML columnCREATE XML INDEX idx_1 ON docs (xDoc)
Creates indexes on tags, values & pathsSpeeds up queries
Entire query is optimizedSame industry leading cost based optimizer
Indexes are used as available
XML Schema SupportXML Schema Support
XML Schema (W3C standard)Rich mechanism for type definitions and validation constraintsCan be used to constrain XML documents
Benefits of typed data Guarantees shape of dataAllows storage and query optimizations
XML type systemStore XML schemas in system meta-data
XML Schema (W3C standard)Rich mechanism for type definitions and validation constraintsCan be used to constrain XML documents
Benefits of typed data Guarantees shape of dataAllows storage and query optimizations
XML type systemStore XML schemas in system meta-data
XQuery: query XML documents and dataStandards-based: W3C working draft
In document 123, return section heading of section 3 and laterSELECT id, xDoc::query('
for $s in /doc[@id = 123]//sec[@num >= 3]
return <topic>{data($s/heading)}</topic>')
FROM docs
XQuery: query XML documents and dataStandards-based: W3C working draft
In document 123, return section heading of section 3 and laterSELECT id, xDoc::query('
for $s in /doc[@id = 123]//sec[@num >= 3]
return <topic>{data($s/heading)}</topic>')
FROM docs
XML QueryXML Query
Insert, update, and delete XQuery extensionsXML sub-tree modification:
Add or delete XML sub-treesUpdate values
Add a new section after section 1:UPDATE docs SET xDoc::modify('insert<section num=''2''> <heading>Background</heading> </section>after /doc/section[@num=1]')
Insert, update, and delete XQuery extensionsXML sub-tree modification:
Add or delete XML sub-treesUpdate values
Add a new section after section 1:UPDATE docs SET xDoc::modify('insert<section num=''2''> <heading>Background</heading> </section>after /doc/section[@num=1]')
XML Data ModificationXML Data Modification
XML View: Unification ModelXML View: Unification Model
SQL Server “Yukon” XML data typeUse XQuery
Relational columnsUse SQL
XML View hides representationUse XQuery against any data
SQL Server “Yukon” XML data typeUse XQuery
Relational columnsUse SQL
XML View hides representationUse XQuery against any data
CustomerID
ContactName
Street City XML data type
XML ViewXML ViewXQuery andXQuery and
UpdatesUpdatesCustomer Table
Choice of XML TechnologyChoice of XML TechnologyNative XML Technology
Very simple way of storing XML dataXML schema is optionalDocument order is importantQuery and modify XML dataIndex XML data
XML View TechnologyXML-centric programming model over tablesSchema for XML data requiredOrder not importantBulk load XML data; decompose into tables
Native XML TechnologyVery simple way of storing XML dataXML schema is optionalDocument order is importantQuery and modify XML dataIndex XML data
XML View TechnologyXML-centric programming model over tablesSchema for XML data requiredOrder not importantBulk load XML data; decompose into tables
.NET Integration.NET Integration
Server side: SQLCLR.NET hosted inside the databaseWrite stored procedures in C#Use ADO programming model on the server the same way as on the client sideCreate UDTs
Client sideWeb ServicesDatasetObjectspaces
Server side: SQLCLR.NET hosted inside the databaseWrite stored procedures in C#Use ADO programming model on the server the same way as on the client sideCreate UDTs
Client sideWeb ServicesDatasetObjectspaces
SQLCLRSQLCLRComponent reuseMainstream development experienceFamiliar choice of programming languages and constructsLeverage existing libraries and componentsSeamless debugging and deploymentDeep integration with the engine
Component reuseMainstream development experienceFamiliar choice of programming languages and constructsLeverage existing libraries and componentsSeamless debugging and deploymentDeep integration with the engine
SQLCLR DevelopmentSQLCLR Development
VS .NET VS .NET ProjectProject
Assembly: “TaxLib.dll”
VB, C#, …VB, C#, … BuildBuild
SQL ServerSQL Server
SQL Data Definition: SQL Data Definition: create create assembly … assembly … create function … create function … create create procedure … procedure … create trigger … create trigger … create create type …type …
SQL Queries: SQL Queries: select select sum(sum(tax(sal,state)tax(sal,state) ) ) from Emp where county from Emp where county = ‘King’= ‘King’
Runtime hosted inside
SQL
SQL or SQLCLRSQL or SQLCLR
Why SQLSet-oriented queries Large data sets
Why CLRComputationally intensiveComplex behaviorsReusable components with rich behaviorsRich types (polygon)
Why SQLSet-oriented queries Large data sets
Why CLRComputationally intensiveComplex behaviorsReusable components with rich behaviorsRich types (polygon)
Design GuidelinesDesign GuidelinesT-SQL is best suited for data access
Relational programming modelStatic compilation modelOptimized for data access
SLQCLR is for procedural programming and computation
IL compiled to x86 code at runtime, easily outperforms interpreted T-SQLCompute-intensive business logic encapsulated as functions
Moving computation to where the data isData shipping cost goes awayServer CPU now used for user processing
T-SQL is best suited for data accessRelational programming modelStatic compilation modelOptimized for data access
SLQCLR is for procedural programming and computation
IL compiled to x86 code at runtime, easily outperforms interpreted T-SQLCompute-intensive business logic encapsulated as functions
Moving computation to where the data isData shipping cost goes awayServer CPU now used for user processing
Web Services OverviewWeb Services Overview
Natural client side programming modelTurn your existing Stored Procedures into web ServicesMessaging done according to SOAP 1.1 standardChoose how to model results
XMLObjectsDataset
Can run on database server or mid-tierIntegrated with Visual Studio
Natural client side programming modelTurn your existing Stored Procedures into web ServicesMessaging done according to SOAP 1.1 standardChoose how to model results
XMLObjectsDataset
Can run on database server or mid-tierIntegrated with Visual Studio
SOAP And Web ServicesSOAP And Web Services
WSDL file describing each template and stored proc exposedTool to choose which templates and stored procedures to expose
WSDL file describing each template and stored proc exposedTool to choose which templates and stored procedures to expose
SQLSQLServerServer
IIS/ISAPIIIS/ISAPI
MessageMessageSPSP
TemplateTemplate
ClientClient SOAPSOAP
MessageMessage
WSDLWSDL
Easy Programming ModelEasy Programming Model
SQLXML generates WSDL automaticallyVisual Studio.NET recognizes a DatasetRetrieve results of a Stored Procedure and load into a Dataset in 1 line of code!
Dim Service As New MyHost.MyWebService()Dim retval As IntegerDataSet ds = Service.GetCustomer(Name)
SQLXML generates WSDL automaticallyVisual Studio.NET recognizes a DatasetRetrieve results of a Stored Procedure and load into a Dataset in 1 line of code!
Dim Service As New MyHost.MyWebService()Dim retval As IntegerDataSet ds = Service.GetCustomer(Name)
Web Services – Decoupled ArchitectureWeb Services – Decoupled Architecture
SQL ServerSQL ServerSQLXMLSQLXMLApplicationApplicationMethod callMethod call SQL querySQL query
RowsetRowsetXmlReaderXmlReader
ClientClient Mid-TierMid-Tier ServerServer
User User viewview
DBA DBA viewview
Levels of AbstractionLevels of Abstraction
Abstract the data source – XML ViewAbstract the data access – HTTP queriesAbstract programming model – SQL Server Web Services
Abstract the data source – XML ViewAbstract the data access – HTTP queriesAbstract programming model – SQL Server Web Services
Data Model TransparencyData Model Transparency
XML Views – treat your relational data as if it was XML FileUse XML Query LanguagesPerform XML UpdatesNo need to be a DBA, learn SQL, or database programming APIs/logic
XML Views – treat your relational data as if it was XML FileUse XML Query LanguagesPerform XML UpdatesNo need to be a DBA, learn SQL, or database programming APIs/logic
Data Access TransparencyData Access Transparency
Access your data from any platformHTTP queries - platform independent protocolXML results – standard representation of dataUse SQL or XPath to query
Access your data from any platformHTTP queries - platform independent protocolXML results – standard representation of dataUse SQL or XPath to query
Programming Model TransparencyProgramming Model Transparency
Web servicesUse from any platformCall methods – get XML data returned
SQL Server stored procedure or XML Template is calledResults are transformed into XML form as needed
SQLCLR: programming model is the same on the server and on the client
Loosely coupled architecture
Web servicesUse from any platformCall methods – get XML data returned
SQL Server stored procedure or XML Template is calledResults are transformed into XML form as needed
SQLCLR: programming model is the same on the server and on the client
Loosely coupled architecture
WinFS: Structured Data StorageWinFS: Structured Data Storage
Files vs. DatabasesNTFS
Part of Operating SystemBackupWin32 APIsSimple
DatabaseOptimized for queryingReliabilitySecurityTransactions, multi-user, concurrency
Files vs. DatabasesNTFS
Part of Operating SystemBackupWin32 APIsSimple
DatabaseOptimized for queryingReliabilitySecurityTransactions, multi-user, concurrency
WinFSWinFS
System FilesExeDllSwap…
User FilesDocumentsPicturesMessages…
System FilesExeDllSwap…
User FilesDocumentsPicturesMessages…
User FilesUser FilesUnstructured data
Not really unstructured – proprietary structure
Data broken into filesOne level of granularity (HTML, Powerpoint)Easy manipulation?
Proprietary formatsNeed particular application to interpret filesNo Sharing (Import/Export)No relationships
Duplication of DataCompatibility of data (Emails, Contacts,…)
Unstructured dataNot really unstructured – proprietary structure
Data broken into filesOne level of granularity (HTML, Powerpoint)Easy manipulation?
Proprietary formatsNeed particular application to interpret filesNo Sharing (Import/Export)No relationships
Duplication of DataCompatibility of data (Emails, Contacts,…)
WinFSWinFSDatabase
Reliability, Concurrency, Speed, query optimization
Understanding schemasUniform SearchNew APIs
SQLObjects
Old APIsWill be supported
Old files still workWant to enable richer integration – provide translations mechanisms
DatabaseReliability, Concurrency, Speed, query optimization
Understanding schemasUniform SearchNew APIs
SQLObjects
Old APIsWill be supported
Old files still workWant to enable richer integration – provide translations mechanisms
WinFS SchemasWinFS Schemas
Unification on some levelBase schemas shipped with Windows
Play by the rules – all applications will be enabled with your data
Use extensions for your proprietary data
Convenient programming modelShell supports librariesNavigation (relationships)Integration (Email body is a document)
Unification on some levelBase schemas shipped with Windows
Play by the rules – all applications will be enabled with your data
Use extensions for your proprietary data
Convenient programming modelShell supports librariesNavigation (relationships)Integration (Email body is a document)
WinFS Data ModelWinFS Data ModelItems
Person, Document, Message, Meeting, etc.
RelationshipsAuthor, Attachment, Meeting participant
Nested typesAddress
ExtensionsProprietary dataMultityping
Inheritance
ItemsPerson, Document, Message, Meeting, etc.
RelationshipsAuthor, Attachment, Meeting participant
Nested typesAddress
ExtensionsProprietary dataMultityping
Inheritance
Audio Videos Images Games. . .
Principals LocationsCalendar EventsCoreMessage (Email)
The Windows SchemasThe Windows Schemas
WinFSTypesMeta BaseFile SyncShellSubscriptions. . .
System Tasks Explorer Config NaturalUI Programs
Services SecurityHelp Device. . .
System
User DataDocumentsAnnotationsMedia NotesPerson Tasks
Infrastructure
My favorite queryMy favorite query
What do I know about “John Smith”Documents by/about himEmails from himHis addressPhone calls from himAnnotations he added to my papersMeetings with him
What do I know about “John Smith”Documents by/about himEmails from himHis addressPhone calls from himAnnotations he added to my papersMeetings with him
Creating API for a SchemaCreating API for a SchemaCreate WinFS schema in XML formatSchema compiler generates API assemblyYou can add your own “helper” membersThe assemblies are installed into a WinFS store
WinFS types are registered as UDTs
Views and other database objects are created
Create WinFS schema in XML formatSchema compiler generates API assemblyYou can add your own “helper” membersThe assemblies are installed into a WinFS store
WinFS types are registered as UDTs
Views and other database objects are created
WinFSSchema
CLR Complier
Code for Helper
Members
WinFSSchemaCompiler
Code for Standard
APIAPI
Classes
WinFS API ExampleWinFS API Example
using (ItemContext ic = new ItemContext())
{ic.Open();
Contact c = (Contact) ic.FindItem( typeof(System.Storage.Contact.Person),
“DisplayName == ‘Bob Smith’”);
c.DisplayName = ‘Robert Smith’;c.BirthDate = ‘01/04/1982’;ic.Update();
}
using (ItemContext ic = new ItemContext())
{ic.Open();
Contact c = (Contact) ic.FindItem( typeof(System.Storage.Contact.Person),
“DisplayName == ‘Bob Smith’”);
c.DisplayName = ‘Robert Smith’;c.BirthDate = ‘01/04/1982’;ic.Update();
}
WinFS foldersWinFS folders
Every Item must be in at least one folderItem organizationLifetime managementOne file can be in multiple folders (reference counting)User can add custom fields to folders
Every Item must be in at least one folderItem organizationLifetime managementOne file can be in multiple folders (reference counting)User can add custom fields to folders
Body- Preference
WinFS Message Schema (Example)WinFS Message Schema (Example)
Message-Subject-Time sent-Type-Status
Contact-Name-Address-Email-Photo
Document-Title-Size-Type-
Document-Title-Size-Type-
Account-Name-Quota-Type-Server
Participant-DisplayName-Type-Address
Component
Database IntegrationDatabase Integration
XMLObject storageProgramming modelDevelopment environmentWebFile systemApplications
XMLObject storageProgramming modelDevelopment environmentWebFile systemApplications
ReportsReports
Example of table report and HTML report. Sales by quarter.Example of table report and HTML report. Sales by quarter.
WinFS Data model exampleWinFS Data model example
List of schema inheritanceList of schema inheritance
ContactsContacts
A common concept shared by everybodyA common concept shared by everybody
Web servicesWeb services
4 slides. Mention server side support4 slides. Mention server side support
DemoDemo
SQLXML HTTPSQLXML HTTP
New mappingNew mapping
SQLCLR SummarySQLCLR Summary
Richer programming model in database
Any .NET language, selected .NET frameworksTight integration with VS.NET
Deep integration SQL and .NET Runtime
Basis for security, reliability, scalability, performance
ADO.NET provider inside SQLCommon middle- and server-tier data access
Manageable and serviceableScripts, metadata, profiler events, performance counters
Richer programming model in database
Any .NET language, selected .NET frameworksTight integration with VS.NET
Deep integration SQL and .NET Runtime
Basis for security, reliability, scalability, performance
ADO.NET provider inside SQLCommon middle- and server-tier data access
Manageable and serviceableScripts, metadata, profiler events, performance counters
Debugging SQL Server “Yukon”Debugging SQL Server “Yukon”
Seamlessly step cross-languageT-SQL and SQL/CLR code
Set breakpoints anywhereBoth local and remote debuggingInspect anything
SQL typesUDTsManaged objects
Seamlessly step cross-languageT-SQL and SQL/CLR code
Set breakpoints anywhereBoth local and remote debuggingInspect anything
SQL typesUDTsManaged objects
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
.NET Framework IntegrationKey Features
.NET Framework IntegrationKey Features
Server-side programming environment for:User Defined Functions, Stored Procedures, TriggersUser Defined Types, user defined Aggregates
In-Proc Data Access (ADO.NET V2 - Whidbey)Common ADO .NET Programming Model
Both Mid-tier/data tier
SecurityIntegration of SQL and CLR securityThree levels of code access security
Safe, External-Access (verifiable), Unsafe
Tight integration with Visual StudioAuthoring, debugging, deployment, & profiling
Server-side programming environment for:User Defined Functions, Stored Procedures, TriggersUser Defined Types, user defined Aggregates
In-Proc Data Access (ADO.NET V2 - Whidbey)Common ADO .NET Programming Model
Both Mid-tier/data tier
SecurityIntegration of SQL and CLR securityThree levels of code access security
Safe, External-Access (verifiable), Unsafe
Tight integration with Visual StudioAuthoring, debugging, deployment, & profiling
Authoring/Debugging/DeployingAuthoring/Debugging/Deploying
New Visual Studio project type in “Whidbey” for “Yukon” managed codeServer debug integration
Full debugger visibilitySet breakpoints anywhere
Single step support: Between languages: T-SQL, C#, VB, & C++Between deployment tiers:
E.g. ASP.NET, through SQL Server stored proc call, & back to mid-tier
New Visual Studio project type in “Whidbey” for “Yukon” managed codeServer debug integration
Full debugger visibilitySet breakpoints anywhere
Single step support: Between languages: T-SQL, C#, VB, & C++Between deployment tiers:
E.g. ASP.NET, through SQL Server stored proc call, & back to mid-tier
.NET IntegrationKey Theme: Choice & Control.NET IntegrationKey Theme: Choice & Control
Choice of where to run logicDatabase, for logic that runs close to dataMid-tier, for logic that scales outSymmetric programming model
Leverage skills mid-tier & server
Safe extended stored proc replacement Choice of programming language
C#, VB.NET, & Managed C++, for a safe, modern execution environmentT-SQL enhancements continue
Right choice for data-intensive procedures
Choice of where to run logicDatabase, for logic that runs close to dataMid-tier, for logic that scales outSymmetric programming model
Leverage skills mid-tier & server
Safe extended stored proc replacement Choice of programming language
C#, VB.NET, & Managed C++, for a safe, modern execution environmentT-SQL enhancements continue
Right choice for data-intensive procedures
XML ScenariosSemi-structured storage…XML ScenariosSemi-structured storage…
XML DatatypeLoosely structured dataData with a dynamic schema
XML ViewsMixed data – structured/unstructuredXML stores w/o relational support challenged
XML DatatypeLoosely structured dataData with a dynamic schema
XML ViewsMixed data – structured/unstructuredXML stores w/o relational support challenged
First Name
Last Name
Address Phone XML data type
XML ViewsOverviewXML ViewsOverview
Default XML view of relational dataUser-defined XML views
Specified using schema mapping
Decouples mapping from domain specific schemas
Default XML view of relational dataUser-defined XML views
Specified using schema mapping
Decouples mapping from domain specific schemas
First Name
Last Name
Address Phone XML data type
XML ViewBulk
load
XQuery,Updates
Middle-Tier XML Views Middle-Tier XML Views
SQL Server “Yukon” XML data typeSparse (semi-structured) data
XML ViewsMixed data – structured/unstructured
XML View hides representation
SQL Server “Yukon” XML data typeSparse (semi-structured) data
XML ViewsMixed data – structured/unstructured
XML View hides representation
CustomerID
ContactName
Street City XML data type
XML ViewXML ViewXQuery andXQuery and
UpdatesUpdatesCustomer Table
Middle-Tier XML ViewsMiddle-Tier XML ViewsDeclarative syntax for mapping between XML and relational dataSupport for common database design patterns
Stored proc supportExtensibility mechanism with SQL queries.
XQuery over XML Viewsfor $i in
map:view(“nwind.msd”)//Customer where $i/CustomerID = “ALFKI” return $iIdentical mapping technology used by ADO.NET Objectspaces for objects
Declarative syntax for mapping between XML and relational dataSupport for common database design patterns
Stored proc supportExtensibility mechanism with SQL queries.
XQuery over XML Viewsfor $i in
map:view(“nwind.msd”)//Customer where $i/CustomerID = “ALFKI” return $iIdentical mapping technology used by ADO.NET Objectspaces for objects
XML View ExampleXML View ExampleCustomer Table
CustomerID
ContactName
Street
City
CustomerID
Customer
name
Street
CityCountry
Country
XSD - XML Schema Definition
MSD - Mapping Schema Definition
RSD - Relational Schema Definition
<ItemType Name="Person” BaseType="Core.Contact" ... > <Property Name="PersonalNames” Type="MultiSet“ MultiSetOfType="FullName“ Nullable="true"> <Property Name="AddressLine“ Type="WinFS.String"
Nullable="true"> <RelationshipType Name="Employment“ BaseType="WinFS.Relationship“ AllowsHolding="true“ AllowsEmbedding="false“ AllowsReference="true"> <Property Name=“IrisScan” Type=“WinFS.FileStream” …/></ItemType>
WinFS Schema
<ItemType Name="Person” BaseType="Core.Contact" ... > <Property Name="PersonalNames” Type="MultiSet“ MultiSetOfType="FullName“ Nullable="true"> <Property Name="AddressLine“ Type="WinFS.String" Nullable="true"> <RelationshipType Name="Employment“ BaseType="WinFS.Relationship“ AllowsHolding="true“ AllowsEmbedding="false“ AllowsReference="true"> <Property Name=“IrisScan” Type=“WinFS.FileStream” …/></ItemType>
WinFS Schema
ItemId Name Addresses
Street City State Zip
Street City State Zip
Street City State Zip
IrisScan
FirstName LastName
Table View of Person
NTFS stream
ExampleExample public partial class Person_t : Item { private String _AddressLine; private PersonalNames _Name; public String AddressLine { get { return _AddressLine; } set { _AddressLine = value; } } public Relationship Employment {get { …} // cached or select statement set { …} private FileStream_IrisScan;…}
CLR Assembly public partial class Person_t : Item { private String _AddressLine; private PersonalNames _Name; public String AddressLine { get { return _AddressLine; } set { _AddressLine = value; } } public Relationship Employment {get { …} // cached or select statement set { …} private FileStream_IrisScan;…}
CLR Assembly
ItemId Name Addresses
Street City State Zip
Street City State Zip
Street City State Zip
IrisScan
FirstName LastName
Table View of Person
NTFS stream
ExampleExample
API ExamplesAPI Examples
VB Managed APIDim personItem As PersonFor Each personItem In Person.FindAll(context, “PersonalNames.Surname=’Smith’)
...Next
VB Managed APIDim personItem As PersonFor Each personItem In Person.FindAll(context, “PersonalNames.Surname=’Smith’)
...Next
T-SQLselect p._Item from [System.Storage.Contacts.Store].[Person] p
where exists (select * from unnest (p.PersonalNames) n
where n.Surname=‘Smith')
T-SQLselect p._Item from [System.Storage.Contacts.Store].[Person] p
where exists (select * from unnest (p.PersonalNames) n
where n.Surname=‘Smith')
WinFS ServicesFilesystem WinFS ServicesFilesystem
“File-backed” ItemsItems with traditional filestream parts withinUses real NTFS streams and file handlesAny file can be imported into WinFS as a File-back Item
WinFS is backwards compatible with Win32
“File-backed” ItemsItems with traditional filestream parts withinUses real NTFS streams and file handlesAny file can be imported into WinFS as a File-back Item
WinFS is backwards compatible with Win32
Fram
ework
Models
Core WinFS ItemsItems
RelationshipsRelationships
ExtensionsExtensionsFilesystem Srvcs (Handlers, …)Filesystem Srvcs (Handlers, …)
OperationsOperations
Data Model
NTFSNTFS
Relational EngineRelational Engine
ServicesPeoplePeople
DocumentsDocuments
……InfoAgent (Rules, …)InfoAgent (Rules, …)
Synchronization(WinFS, …)Synchronization(WinFS, …)
Schemas
XMLXMLAPIs
T/SQLT/SQLObjectsObjects
Finding Items In WinFSFinding Items In WinFS
OPathSimple query language in the object domainUses paradigm familiar to OO programmers
SupportsSimple equalitiesWild cards‘IN’, ‘LIKE’ operatorsDate expressionsTraverse relationshipsGrouping expressionsSimple math expressions (+, -)
Example“(DisplayName = ‘Sean Chai’) || (DisplayName like ‘K%’ )”
OPathSimple query language in the object domainUses paradigm familiar to OO programmers
SupportsSimple equalitiesWild cards‘IN’, ‘LIKE’ operatorsDate expressionsTraverse relationshipsGrouping expressionsSimple math expressions (+, -)
Example“(DisplayName = ‘Sean Chai’) || (DisplayName like ‘K%’ )”
User BenefitsUser BenefitsFind my stuff
“The big presentation I got from Toby I was working on last week”
One view of dataIM Toby, Hotmail Toby, Corporate Toby, …
Exposing relationships Doc authors, Meeting attendees, Meeting Locations, Location occupants…
Find my stuff“The big presentation I got from Toby I was working on last week”
One view of dataIM Toby, Hotmail Toby, Corporate Toby, …
Exposing relationships Doc authors, Meeting attendees, Meeting Locations, Location occupants…
Developer BenefitsDeveloper Benefits
Populated, well-defined data definitions (types)You don’t have to build your own store or APIApplications can create and share dataThe storage subsystem is Extensible
It’s much easier to build a smart connected applicationApplications can create and share types
Populated, well-defined data definitions (types)You don’t have to build your own store or APIApplications can create and share dataThe storage subsystem is Extensible
It’s much easier to build a smart connected applicationApplications can create and share types
Metadata HandlersMotivationMetadata HandlersMotivation
PromotionEnd-users don’t need to re-tag their content with metadata
WinFS automatically pulls it out of filesExisting applications continue to write to files
Appropriate metadata surfaces in WinFS items
DemotionWinFS apps use one API to write pure WinFS and file-backed items
WinFS demotes metadata back to filesAllows interop between legacy and new applicationsProvides fidelity of metadata through moves/copies
PromotionEnd-users don’t need to re-tag their content with metadata
WinFS automatically pulls it out of filesExisting applications continue to write to files
Appropriate metadata surfaces in WinFS items
DemotionWinFS apps use one API to write pure WinFS and file-backed items
WinFS demotes metadata back to filesAllows interop between legacy and new applicationsProvides fidelity of metadata through moves/copies
Data Requirements in Next Generation ApplicationsData Requirements in Next Generation ApplicationsModel complex objects
Complex structureInheritanceUnstructured, XML and Structured data
Rich RelationshipsValue-based Link basedWinFS provides a built in model with more services for complex objects
Rich and Common QueryCommon across client and serverCommon across different typed of data – SQL, Objects, XML
Granular operationsCopy, MoveBackup/RestoreSecurity
Rich organization Hierarchical Namespace
Active Notifications and Data SynchronizationIntegrated Business logic
Optimistic concurrency control and API mapping
Model complex objectsComplex structureInheritanceUnstructured, XML and Structured data
Rich RelationshipsValue-based Link basedWinFS provides a built in model with more services for complex objects
Rich and Common QueryCommon across client and serverCommon across different typed of data – SQL, Objects, XML
Granular operationsCopy, MoveBackup/RestoreSecurity
Rich organization Hierarchical Namespace
Active Notifications and Data SynchronizationIntegrated Business logic
Optimistic concurrency control and API mapping
Schema compilation processSchema compilation process
WinFS schemas are defined using XML syntax The WinFS schema compilation process generates C# code from the WinFS Schema fileThe C# source files are compiled into assembliesThe assemblies are installed into a WinFS store
WinFS types are registered as UDTs
Views and other database objects are created
WinFS schemas are defined using XML syntax The WinFS schema compilation process generates C# code from the WinFS Schema fileThe C# source files are compiled into assembliesThe assemblies are installed into a WinFS store
WinFS types are registered as UDTs
Views and other database objects are createdWinFS
SchemaCLR
Complier
WinFSSchemaCompiler
C# code for UDTs
SchemaAssemblies
WinFSStore
Data Model Mapping OverviewData Model Mapping Overview
A WinFS schema is mapped to a SQL schemaA CLR class is generated for each Item, Nested, Extension Relationship typeThe classes are registered as SQL User Defined Types (UDTs)Search views are provided for each Item, Extension and Relationship typeUpdates are enabled through the WinFS Update API operations
CreateItem, CreateRelationship, CreateExtensionUpdateItem, UpdateRelationship, UpdateExtensionDeleteRelationship, DeleteExtension
A WinFS schema is mapped to a SQL schemaA CLR class is generated for each Item, Nested, Extension Relationship typeThe classes are registered as SQL User Defined Types (UDTs)Search views are provided for each Item, Extension and Relationship typeUpdates are enabled through the WinFS Update API operations
CreateItem, CreateRelationship, CreateExtensionUpdateItem, UpdateRelationship, UpdateExtensionDeleteRelationship, DeleteExtension
WinFS Data ModelWinFS Data Model
The WinFS Data Model describes the shape of the data stored in WinFSthe constraints on the dataassociations between data
WinFS world is comprised of items, relationships and extensionsItems are the primary objects that applications work onItems can be associated with other items via relationshipsItems can be extended with extensions (or subclass)
The WinFS Data Model describes the shape of the data stored in WinFSthe constraints on the dataassociations between data
WinFS world is comprised of items, relationships and extensionsItems are the primary objects that applications work onItems can be associated with other items via relationshipsItems can be extended with extensions (or subclass)
WinFS Type ExampleWinFS Type Exampleusing Contact =
System.Storage.Contact;using Core = System.Storage.Core;using Base = System.Storage;
type Contact.Address : Base.NestedType {string Street;string City;string Zip;…
}type Contact.Person : Core.Contact
{datetime BirthDate;binary[] Picture;Address BirthAddress;MultiSet<Address> Addresses;…
}type Contact.Organization :
Core.Contact {string OrganizationName;…
}
using Contact = System.Storage.Contact;
using Core = System.Storage.Core;using Base = System.Storage;
type Contact.Address : Base.NestedType {string Street;string City;string Zip;…
}type Contact.Person : Core.Contact
{datetime BirthDate;binary[] Picture;Address BirthAddress;MultiSet<Address> Addresses;…
}type Contact.Organization :
Core.Contact {string OrganizationName;…
}
Contact
OrganizationPerson
Item
SQL OR Extensions - Smart SerializationSQL OR Extensions - Smart Serialization
SQLCLR types leverage a custom serialization library (SL)
Efficient access to properties of embedded objects
Avoids object construction or method invocations for simple property getters and settersProperty and field access translates to compiled field accessors
New structured serialization formatUnderstands inheritance, embedded types, collection typesInternal to SQL
Provides “record like” performance for accessing object properties
SQLCLR types leverage a custom serialization library (SL)
Efficient access to properties of embedded objects
Avoids object construction or method invocations for simple property getters and settersProperty and field access translates to compiled field accessors
New structured serialization formatUnderstands inheritance, embedded types, collection typesInternal to SQL
Provides “record like” performance for accessing object properties
SQL OR Extensions - Smart SerializationSQL OR Extensions - Smart Serialization
Example:
SELECT FirstName, LastName, …FROM [System.Storage.Contact.Store].Contact cWHERE BirthAddress.City = ‘Seattle’
Fetching HomeAddress.City does not require the materialization of the Address objectProperties retrieved by directly “cracking” the serialized form
Example:
SELECT FirstName, LastName, …FROM [System.Storage.Contact.Store].Contact cWHERE BirthAddress.City = ‘Seattle’
Fetching HomeAddress.City does not require the materialization of the Address objectProperties retrieved by directly “cracking” the serialized form
SQL OR Extensions - CollectionsSQL OR Extensions - Collections
SQL supports a generic collection type MULTISET<T>Properties can be declared using collectionsTreated from SQL as “nested table”Queryable using UNNEST table valued function
SELECT c.FirstName, c.LastName, A.addr.City, A.addr.ZipFROM [System.Storage.Contact.Store].Contact cCROSS APPLY UNNEST(c.Addresses) AS A(addr)
Current investigating replacing the MultiSet collection with IList<T> (to support ordering)
SQL supports a generic collection type MULTISET<T>Properties can be declared using collectionsTreated from SQL as “nested table”Queryable using UNNEST table valued function
SELECT c.FirstName, c.LastName, A.addr.City, A.addr.ZipFROM [System.Storage.Contact.Store].Contact cCROSS APPLY UNNEST(c.Addresses) AS A(addr)
Current investigating replacing the MultiSet collection with IList<T> (to support ordering)
Media SchemasMedia Schemas
...Record:AudioRecord ◄TrackAlbum.Album
Audio.CachedAlbum
...Habits:ListeningHabits ◄ListenedTrack.Track
Audio.Track
...
Audio.PlayList
...
Audio.PlatterTrack
...Contact:Contact ►ContactsInPicture.PictureOtherVersion:Picture ◄►PictureOtherVersions.Picture
Image.Picture
...Metadata:CachedTrack ►SuggestedMetadata.RecordAlbum:CachedAlbum ►TrackAlbum.Record
Audio.AudioRecord
...
Video.RecordedTV
...Record:AudioRecord ◄SuggestedMetadata.Metadata
Audio.CachedTrack
...Distributor:Contact ►ContentDistributor.DocumentArt:Document ►EffectiveBackCoverArt.DocumentArt:Document ►EffectiveFrontCoverArt.DocumentLogo:Document ►MetadataProviderLogo.Document
Media.Document
...Location:Location ►PhotoLocation.Photo
Image.Photo
...Clip:VideoClip ►Clips.Video
Video.VideoRecord