net database programmability and extensibility in microsoft sql server
DESCRIPTION
.NET Database Programmability and Extensibility in Microsoft SQL Server. José A. Blakeley, Mat Henaire, Christian Kleinerman, Isaac Kunen, Adam Prout, Vineet Rao. Introduction. Authors are all Microsoft employees This paper is part 2 of a series of papers - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: NET Database Programmability and Extensibility in Microsoft SQL Server](https://reader036.vdocument.in/reader036/viewer/2022062810/56815ccc550346895dcadad6/html5/thumbnails/1.jpg)
.NET Database Programmability and
Extensibilityin Microsoft SQL Server
José A. Blakeley, Mat Henaire, Christian Kleinerman, Isaac Kunen,
Adam Prout, Vineet Rao
![Page 2: NET Database Programmability and Extensibility in Microsoft SQL Server](https://reader036.vdocument.in/reader036/viewer/2022062810/56815ccc550346895dcadad6/html5/thumbnails/2.jpg)
Introduction
• Authors are all Microsoft employees• This paper is part 2 of a series of papers
o 1st paper described the architecture and design principles of the integration of the CLR in SQL Server
o This paper is going to present newer aspects using SQL Server 2008
• Topicso User-defined Types/Functionso CLR integration with SQL Server 2008o LINQ with .NETo Performance results
![Page 3: NET Database Programmability and Extensibility in Microsoft SQL Server](https://reader036.vdocument.in/reader036/viewer/2022062810/56815ccc550346895dcadad6/html5/thumbnails/3.jpg)
.NET & SQL Server• The Microsoft .NET Framework is a software technology that is
available with several Microsoft Windows operating systems• Microsoft SQL Server is a relational database management system
(RDBMS) produced by Microsoft. Its primary query languages are MS-SQL and T-SQL.
• Common Language Runtime = Java Virtual Machine
![Page 4: NET Database Programmability and Extensibility in Microsoft SQL Server](https://reader036.vdocument.in/reader036/viewer/2022062810/56815ccc550346895dcadad6/html5/thumbnails/4.jpg)
...from terabytes to petabytes andexabytes• Data volumes are:
o EXPLODINGo HEAVY
• Why move something heavy?
![Page 5: NET Database Programmability and Extensibility in Microsoft SQL Server](https://reader036.vdocument.in/reader036/viewer/2022062810/56815ccc550346895dcadad6/html5/thumbnails/5.jpg)
Basic Concepts
The ability to run application code inside the database in areliable, secure, scalable, and efficient manner adds significantflexibility to the design of applications
SQL Server acts as the operating system for the CLR when it is hosted inside the SQL Server process
![Page 6: NET Database Programmability and Extensibility in Microsoft SQL Server](https://reader036.vdocument.in/reader036/viewer/2022062810/56815ccc550346895dcadad6/html5/thumbnails/6.jpg)
User-Defined Functions (UDFs)
CLR user-defined functions (UDFs) provide a mechanism forextending SQL Server with new scalar and table-valued routines written in .NET languages
T-SQL UDFs vs. CLR UDFs:1.T-SQL is more constraining• T-SQL interperated vs. CLR compiled• T-SQL prevents multi-threading
![Page 7: NET Database Programmability and Extensibility in Microsoft SQL Server](https://reader036.vdocument.in/reader036/viewer/2022062810/56815ccc550346895dcadad6/html5/thumbnails/7.jpg)
Tabled-Value Functions (TVFs)
CLR TVFs provide a mechanism forconverting raw data (e.g., in a text/binary file or on the network) into a relation.
![Page 8: NET Database Programmability and Extensibility in Microsoft SQL Server](https://reader036.vdocument.in/reader036/viewer/2022062810/56815ccc550346895dcadad6/html5/thumbnails/8.jpg)
User-Defined Types (UDTs)
SQL Server 2005 introduced user-defined types (UDTs) as amechanism to extend the scalar type system of SQL
UDTs allow users to define a type using the .NET framework, and to deploy and use these types within the database
Since CLR UDTs are simply CLR classes with some additional restrictions, they can be instantiated on a managed client as well as in the server
See Example 4.9
![Page 9: NET Database Programmability and Extensibility in Microsoft SQL Server](https://reader036.vdocument.in/reader036/viewer/2022062810/56815ccc550346895dcadad6/html5/thumbnails/9.jpg)
User-Defined Aggregates (UDAs)
CLR user-defined aggregates (UDAs) give users the ability to write their own aggregates to suite their own specific needs.
An example aggregate for calculating population covariance (a measure of how two sets of data vary together) is shown to highlight the different parts of the UDA contract
The contract consists of four methods: • Init(),• Accumulate(),• Merge()• Terminate()
![Page 10: NET Database Programmability and Extensibility in Microsoft SQL Server](https://reader036.vdocument.in/reader036/viewer/2022062810/56815ccc550346895dcadad6/html5/thumbnails/10.jpg)
Data Access In Routines
Microsoft has recently introduced new Language Integrated Query (LINQ) technologies that extend .NET languages natively with query expressions to further reduce, and for some scenarios completely eliminate, the impedance mismatch for applications.
![Page 11: NET Database Programmability and Extensibility in Microsoft SQL Server](https://reader036.vdocument.in/reader036/viewer/2022062810/56815ccc550346895dcadad6/html5/thumbnails/11.jpg)
An Example
![Page 12: NET Database Programmability and Extensibility in Microsoft SQL Server](https://reader036.vdocument.in/reader036/viewer/2022062810/56815ccc550346895dcadad6/html5/thumbnails/12.jpg)
Questions?