Beyond Relational SQL Server 2008

download Beyond Relational SQL Server 2008

of 31

Transcript of Beyond Relational SQL Server 2008

  • 5/27/2018 Beyond Relational SQL Server 2008

    1/31

    www.ExtremeExperts.comConnect with lifewww.connectwithlife.co.in

    Vinod KumarTechnology Evangelist | Microsoftwww.ExtremeExperts.comhttp://blogs.sqlxml.org/vinodkumar

    http://www.microsoft.com/india/msdnhttp://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    2/31www.ExtremeExperts.com

    Session Objectives And Takeaways

    SQL Server 2008 has added improvedsupport for a variety of non-relational datamanagement scenarios

    You will understand what SQL Server 2008will offer in addition to SQL Server 2005sfunctionality to

    Store and manage unstructured data

    Store and manage semistructured data

    You will better understand when to usewhich of the presented technologies

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    3/31www.ExtremeExperts.com

    Beyond Relational Data

    Pain

    Points

    Dealing with relational and non-relational dataplatforms

    Growth in application complexity & duplicatedfunctionality

    Compensating for unavailable services

    Reduce the cost of managing all types of data

    Simplify the development of applications which userelational and non-relational data

    Extend services currently available for relationaldata to non-relational data

    Goals

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    4/31www.ExtremeExperts.com

    SQL Server 2005 SQL Server 2008

    Large UDTs

    Sparse Columns

    Wide Tables

    Filtered Indices

    HierarchyID

    Relational

    Data

    User Defined Types

    Full Text IndexingDocuments &

    Multimedia

    Remote BLOB Store

    API

    FILESTREAM

    Integrated FTS

    Spatial

    Fully supported

    Geometry and

    Geography data types

    and Functions

    XML Data Type and

    Functions XML Upgrades

    XML

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    5/31www.ExtremeExperts.com

    Low cost per GB

    Streaming Performance

    Complex application

    development & deployment

    Integration with structured

    data

    Advantages

    Challenges

    Integrated management

    Data-level consistency

    Poor data streaming support

    File size limitations

    Highest cost per GB

    Lower cost per GB at scale

    Scalability & Expandability

    Complex application

    development & deployment

    Separate data management

    Enterprise-scales only

    Example Windows File Servers

    NetApp NetFiler

    EMC Centera

    Fujitsu Nearline

    SQL Server

    VARBINARY(MAX)

    Documents &

    Multimedia

    Use File Servers

    DB

    Application

    BLOBs

    Dedicated BLOB

    Store

    DB

    Application

    BLOBs

    Store BLOBs in

    Database

    DB

    Application

    BLOBs

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    6/31www.ExtremeExperts.com

    Remote BLOB Storage FILESTREAM StorageSQL BLOB

    Documents &

    Multimedia

    Dedicated BLOB Store

    DB

    Application

    BLOB

    Store BLOBs in

    Database

    DB

    Application

    BLOB

    Store BLOBs in DB +

    File System

    Application

    BLOB

    DB

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    7/31www.ExtremeExperts.com

    Storage Attribute on VARBINARY(MAX)Works with integrated FTS

    Unstructured data stored directly in the filesystem (requires NTFS)

    Dual Programming Model

    TSQL (Same as SQL BLOB)Win32 Streaming APIs with T-SQLtransactional semantics

    Data Consistency

    Integrated ManageabilityBack Up / Restore

    Administration

    Size limit is the file system volume size

    SQL Server Security Stack

    Documents &

    Multimedia

    Store BLOBs in

    DB + File System

    Application

    BLOB

    DB

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    8/31www.ExtremeExperts.com

    Applications can transparently support different BLOB storesEach BLOB Store vendor responsible for delivering their own providers

    Documents &

    Multimedia

    Applications

    Provider

    Library

    Provider

    Library

    Provider

    Library

    Remote BLOB Store API Client

    BLOB

    Store 1

    BLOB

    Store 2BLOB

    Store 3SQL Server

    Provider API

    Services

    Create

    Enumerate

    Fetch

    GC Delete

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    9/31www.ExtremeExperts.com

    Indexes stored outside SQL Server lead tomanageability challenges

    Mixed query performance suffers from

    having to pull over complete full-text resultset

    Scaling issues on big boxes

    Documents &

    Multimedia

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    10/31www.ExtremeExperts.com

    Full-Text Engine and Indexes fully integrated

    Catalog, index and stopword lists now inside thedatabase

    Better performance in many common scenariosMake mixed queries perform and scale

    Optimizer has knowledge about FT index

    Exposing the FT Index content and any given WBbehaviours

    New word breakers (WB)Better supportability tools

    From 23 to over 40 word breakers/locales

    SELECT * FROM candidates

    WHERE CONTAINS(resume,SQLServer)

    AND ZipCode = 98052

    Documents &

    Multimedia

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    11/31www.ExtremeExperts.com

    Large UDTs

    In SQL Server 2005, UDTs are limited to 8000bytes

    Fine for most objects, but some objects (like spatialobjects) could be quite large

    In SQL Server 2008, UDTs can be up to 2GB.Conceptually identical to varbinary(max)

    The size of a UDT is defined on the type

    Large UDTs can have a size of -1, meaning they are

    limited to our max LOB sizeThis size will be reflected as -1 in type metadata

    Will be converted to varbinary(max) or image fordownlevel clients

    CLR

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    12/31www.ExtremeExperts.com

    Storage and retrieval of spatial data usingstandard SQL syntax

    New Spatial Data Types (geometry,geography)

    New Spatial Methods (intersects, buffer, etc.)

    New Spatial Indexes

    Offers full set of Open Geospatial

    Consortium components (OGC/SQL MM,ISO 19125)

    Integration with Virtual Earth

    Spatial

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    13/31www.ExtremeExperts.com

    Improved XML Schema ValidationSupport for storing & validating Office 12 Document

    formats

    Support for lax validation

    Full xs:dateTime supportSupport for values without timezone

    timezone preservation

    Improved support for lists and union types

    Added support for let-clause in XQueryAdded fn:upper-case()/fn:lower-case()

    Added support insert sql:variable(@xml) into /a/b

    XML

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    14/31www.ExtremeExperts.com

    Semi-structured DataScenarios

    Property Bag Scenarios:Distinct Customized property sets associated with data

    Large number of unique properties, user annotations

    Examples

    Document Management systems (Sharepoint)Media stores

    Databases with Heterogeneous Record types in a tableType specific properties, Inherited properties in a type hierarchy

    Examples

    Product Catalogs (Commerce Server), Location/businessspecific properties(VE), etc..

    Relational

    Data

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    15/31www.ExtremeExperts.com

    Semi-structured DataCharacteristics

    Large number of sparsely populated propertiesDistinct Property Sets

    Heterogeneous structures

    Sets, nested structures

    Relational

    Data

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    16/31www.ExtremeExperts.com

    Semi-structured DataRequirements

    Efficient storage for sparse propertiesEfficient relational access to metadata properties:Query, DML, Indexing

    Ability to get/set metadata property sets

    genericallyIndex subsets of relevant properties for a propertyset

    Retrieve and Analyze Hierarchical data

    Relational

    Data

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    17/31www.ExtremeExperts.com

    Semi-structured DataSQL Server 2008 Features

    Sparse Columns: Optimized storage for sparsecolumns

    Column Sets/Wide Tables: Support thousands of

    sparse columns,

    Filtered Indexes: Ability to index a subset of rowsin a table

    Hierarchy ID: System CLR type for hierarchicalorganization of data

    XML: for fast dynamic evolution, lists and treeobjects

    Relational

    Data

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    18/31www.ExtremeExperts.com

    Sparse Columns

    Sparse as a storage attribute on a columnStorage Optimization: 0 bytes stored for a NULL value

    Co-location of data: performance benefits

    NULL Compression in the TDS layerNo change in Query/DML behavior

    // Sparse as a storage attibute in Create/Alter table statements

    Create Table Products(Id int, Type nvarchar(16),

    Resolution int SPARSE, ZoomLength int SPARSE);

    // No Change in Query/DML Behavior

    Select Id, Type, Resolution, ZoomLength from Products;

    Update Products set Resolution=3, ZoomLength = 105 where Id = 101;

    Relational

    Data

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    19/31www.ExtremeExperts.com

    Sparse Columns

    Wide Tables/Column SetsLarge number of sparse columns allowed in atable(30,000 Columns, 1000 indexes, 30,000 statistics)

    Requires defining a Sparse Column Set

    An un-typed XML column, with a published formatLogical grouping for all sparse columns in a table

    Select * returns all non-sparse-columns, sparse column set (XML)

    Allows generic retrieval/update of all sparse columns as a set

    // Create a sparse column set

    Create Table Products(Id int, Type nvarchar(16),

    Resolution int SPARSE, ZoomLength int SPARSE,

    Properties XML COLUMN_SET FOR ALL_SPARSE_COLUMNS);

    // Generic relational access to sparse column set.

    // Returns an aggregated XML fragment for all non-null sparse columns

    Select Id, Type, Properties from Products;

    4

    70

    // Generic updates through sparse column set. Similar to an XML updateUpdate Products set Type = Camera, Properties = @xml

    Relational

    Data

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    20/31www.ExtremeExperts.com

    Sparse Column Storage0 Bytes stored for NULL Values

    ~20% CPU overhead for non-null value access

    Additional 2- 4 bytes for non-null valuesSparse columns are beneficial when spacesavings >40%

    PK C1

    1 A (sc1,sc9)(1,9)

    2 B (sc2,sc4)(2,4)

    3 C (sc6,sc7)(6.7)

    4 D (sc1,sc5)(1,5)

    5 E (sc4,sc8)(4,8)

    6 F (sc3,sc9)(3,9)

    7 G (sc5,sc7)(5,7)

    8 H (sc2,sc8)(2,8)

    9 I (sc3,sc6)(3,6)

    sc

    1

    sc2 sc3 sc4 sc5 sc6 sc7 sc8 sc9

    PK c1 sc1 sc2 sc3 sc4 sc5 sc6 sc7 sc8 sc9

    1 A 1 9

    2 B 2 4

    3 C 6 7

    4 D 1 5

    5 E 4 8

    6 F 3 9

    7 G 5 7

    8 H 2 8

    9 I 3 6

    Non-sparse storage Sparse storage

    Relational

    Data

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    21/31

    www.ExtremeExperts.com

    Filtered Indexes

    Filtered Indexes and StatisticsIndexing a portion of the data in a table

    Filtered/co-related statistics creation and usage

    Query/DML Optimization to use Filtered indexes &

    StatisticsRestrictions

    Simple limited grammar for the predicate

    Only on non-clustered indexes

    BenefitsLower storage and maintenance costs for largenumber of indexes

    Query/DML Performance Benefits: IO only for

    qualifying rows

    Relational

    Data

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    22/31

    www.ExtremeExperts.com

    Filtered IndexesID Type Brand Zoom Resolution WaistSize Inseam Price ..

    1 Camera Canon 3x 5 Mb 300

    2 Pant Dockers 38 34 45

    3 Camera Nikon 5x 10mb 600

    4 Camera Pentax 3x 3mb 195

    5 Pant Polo 30 32 65

    6 Pant Dockers 40 32 45

    7 ..

    // Create a Filtered Indexes

    Create Index ZoomIdx on Products(ZoomLength) where Type = Camera;

    Create Index PlusSizeIdx on Products(WaistSize) where Type = Pant and

    WaistSize > 36

    // Optimizer will pick the filtered index when query predicates match

    Select ProductId, Type, Resolution, ZoomLengthwhere Type = Camera

    Select ProductId, Type, WaistLength, Inseam where Type = Pant and

    WaistLength > 38

    // DML operations need to maintain indexes only when needed.

    Insert into Products(ProductId, Type, waistLength, inseam) values (201,

    Pant, 30, 32);

    Relational

    Data

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    23/31

    www.ExtremeExperts.com

    Sparse Columns & Filtered

    Indexes

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    24/31

    www.ExtremeExperts.com

    Hierarchical DataScenarios

    Forum and mailing list threadsBusiness organization charts

    Content management categories

    Product categories

    Files/folders management

    SQL Server 2005:

    Parent/Child columnXML datatype

    New in SQL Server 2008:

    HierarchyID type

    Relational

    Data

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    25/31

    www.ExtremeExperts.com

    HierarchyIDKeyproperties

    A system data type with variablelength

    CLR UDT

    Microsoft.SqlServer.Types

    Varbinary encoding ( < 900 bytes)

    To represent position in a hierarchy

    Logically encodes the path from theroot of the tree to a node

    Rich built-in methods for manipulatinghierarchies

    Simplifies storage and querying ofhierarchical data

    Comparison a

  • 5/27/2018 Beyond Relational SQL Server 2008

    26/31

    www.ExtremeExperts.com

    static HierarchyId GetRoot()SqlInt16 GetLevel()

    HierarchyId reparent(HierarchyId oldroot, HierarchyIdnewroot)

    SqlBoolean IsDescendant(HierarchyId child)string ToString()

    HierarchyId Parse (SqlString input)

    HierarchyID Read (BinaryReader r)

    HierarchyID Write (BinaryWriter r)HierarchyId GetDescendant(HierarchyId child1,HierarchyId child2)

    HierarchyId GetAncestor(SqlInt16 AncesterLevel)

    Relational

    Data

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    27/31

    www.ExtremeExperts.com

    HierarchyID

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    28/31

    www.ExtremeExperts.com

    Summary

    SQL Server 2008 will make it easier tocreate information-centric applications thatrequire:

    Unstructured documents

    XML

    Semi-structured information

    combine the above with relational data

    byReducing the cost of managing all types of data

    Simplifying the development of applications whichuse relational and non-relational data

    Extending services currently available for relationaldata to non-relational data

    http://www.microsoft.com/india/msdnhttp://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    29/31

    www.ExtremeExperts.com

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    30/31

    www.ExtremeExperts.com

    Feedback / QnA

    Your Feedback is Important!Please take a few moments to fill out our online

    feedback form at:>

    For detailed feedback, use the form athttp://www.connectwithlife.co.in/vtd/helpdesk.aspx

    Or email us at [email protected]

    Use the Question Manager on LiveMeetingto ask your questions now!

    http://www.microsoft.com/india/msdn
  • 5/27/2018 Beyond Relational SQL Server 2008

    31/31

    2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

    The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market

    conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.

    MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

    http://www.microsoft.com/india/msdn