Building REST API using SQL Server and JSON Functions

Slides:



Advertisements
Similar presentations
What Is Microsoft Marketplace DataMarket What Is Microsoft Marketplace DataMarket? Michael Stiefel
Advertisements

Yukon – What is New Rajesh Gala. Yukon – What is new.NET Framework Programming Data Types Exception Handling Batches Databases Database Engine Administration.
Single Page Apps with Breeze and Ruby.
1/7 ITApplications XML Module Session 8: Introduction to Programming with XML.
DB Relay An Introduction. INSPIRATION Database access is WAY TOO HARD The crux.
Query Methods (SQL). What is SQL A programming language for databases. SQL (structured Query Language) It allows you add, edit, delete and run queries.
Introduction to HTML5 Programming donghao. HTML5 is the New HTML Standard New Elements, Attributes. Full CSS3 Support Video and Audio 2D/3D Graphics Local.
Microsoft ® Official Course Client-Side SharePoint Development SharePoint Practice Microsoft SharePoint 2013.
© 2014 IBM Corporation Empowering the IBM ecosystem Introduction to Developing applications using node.js on Bluemix IBM Ecosystem Development Instructors.
INTRODUCTION The Group WEB BROWSER FOR RELATION Goals.
Copyright © 2003 Addison-Wesley Instructor Information Here.
Multiple Tiers in Action
DT228/3 Web Development Databases. Database Almost all web application on the net access a database e.g. shopping sites, message boards, search engines.
Securing Enterprise Applications Rich Cole. Agenda Sample Enterprise Architecture Sample Enterprise Architecture Example of how University Apps uses Defense.
-Uday Dhokale.  What is it ??? Prototype is a JavaScript Framework that aims to ease development of dynamic web applications.  Features a unique, easy-to-use.
Agenda What is AJAX? What is jQuery? Demonstration/Tutorial Resources Q&A.
INFM 603: Information Technology and Organizational Context Jimmy Lin The iSchool University of Maryland Wednesday, March 26, 2014 Session 8: Ajax and.
Introduction to MVC Adding Model Classes NTPCUG Tom Perkins, Ph.D.
JavaScript & jQuery the missing manual Chapter 11
Insert Presentation Title Heremm.dd.yy, City, ST SQL Reporting Services – Building the Report Kevin Ford Services Consaultant Accela, Inc.
DBA Developer. Responsibilities  Designing Relational databases  Developing interface layer Environment Microsoft SQL Server,.NET SQL Layer: Stored.
What is SQL and Who uses it? Presented by: John Deardurff Global McOWL Internal Sales Training October 24, 2014.
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
M1G Introduction to Database Development 6. Building Applications.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
Web Services Brenton Lovett Wizard Information Services.
Introduction to ADO Y.-H. Chen International College Ming-Chuan University Fall, 2004.
PHP PDO & PHP SOAP Introduce. Agenda What is PHP PDO and PHP SOAP? Setup PHP PDO to connect database, query database and close the connection. Setup SOAP.
JSON and A Comparison of Scripts. JSON: JavaScript Object Notation Based on a subset of the JavaScript Programming Language provides a standardized data.
Rails & Ajax Module 5. Introduction to Rails Overview of Rails Rails is Ruby based “A development framework for Web-based applications” Rails uses the.
Pragmatic Mash-Ups Andrew Filev Microsoft Certified Architect Murano Software Building POC of Web 2.0 application in one day with AJAX, Virtual Earth and.
Ajax for Dynamic Web Development Gregory McChesney.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
INT213 INT213 – Managing Windows with VBScript VBScript Variables ASP State Management.
AJAX. Ajax  $.get  $.post  $.getJSON  $.ajax  json and xml  Looping over data results, success and error callbacks.
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
Power BI for Developers Rui Romano SQLSaturday.com
How to consume a RESTful service using jQuery. Introduction  In this post we see how to consume the RESTful service described in the post Design a RESTful.
JQuery, JSON, AJAX. AJAX: Async JavaScript & XML In traditional Web coding, to get information from a database or a file on the server –make an HTML form.
Course Agenda Deep Dive into the Building Blocks and Services of the SharePoint Platform Module 1: Developing Advanced Workflow Scenarios in Office 365.
AJAX. Objectives Understand and apply AJAX Using AJAX in DOJO library.
Data in Windows 10 UWP Andy Wigley XML, JSON, SQLite or EF Core ?
Phonegap Bridge – Storage CIS 136 Building Mobile Apps 1.
Taking Analysis Services Tabular to Enterprise Levels Stacia Varga Data Inspirations
Introduction to Mongo DB(NO SQL data Base)
Jim Fawcett CSE686 – Internet Programming Summer 2010
Web API - Introduction AJAX, Spring Data REST SoftUni Team Web API
Developing modern applications with Temporal Tables and JSON
DBAs vs Developers: JSON in SQL Server
AJAX and REST.
Overview of Data Access
SQL Server Data Tools for Visual Studio Part I: Core SQL Server Tools
Asynchronous Java script And XML Technology
Twitter & NoSQL Integration with MVC4 Web API
AJAX.
SQL Server 2016 JSON Support FOR Data Warehousing
Overview of Data Access
Meet JSON In SQL Server 2016 Russ Loski Preparations:
Asynchronous Javascript And XML
Entity Framework Core.
DBAs vs Developers: JSON in SQL Server
A JSON’s Journey through SQL Server
HTML5 AJAX & JSON APIs
JSON for the Data Mortal
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
Integrating REST API and SQL Server JSON Functions
TechEd /22/2019 9:22 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Introduction into the Power BI REST API Jan Pieter Posthuma
Computer Network Information Center, Chinese Academy of Sciences
Presentation transcript:

Building REST API using SQL Server and JSON Functions

Jovan Popovic Program Manager Projects Microsoft Development Center Serbia Program Manager JSON T-SQL language Temporal In-memory technologies Intelligent Database.  Projects

JSON Support in SQL Server Building REST API using SQL Server Agenda JSON Support in SQL Server Building REST API using SQL Server

JSON Support in SQL Server Combining relational and semi-structured data

JSON in SQL Database

Combine relational and JSON data ID Name Type Price Tags Data 1 Bike 399.99 [“promo”] {“Gears”:20, “Weight”:9.5,”Gender”:”M”} 2 Helmet 7 120.99 [“promo”,”sales”] {“Visor”:true, “WxDxH”: [32,26.4,22]} 3 Car 6 29,500 {“Doors”:4, “Seats”:5, “MPG”:29} 8 299.99 [“sales”] {“Tyres”:[“300c”,”35C”],Weight”:9.5,”Gender”:”M”} 9 {“Doors”:2, “Seats”:2, “MPG”:35} SELECT ProductID, Name, Tags, JSON_VALUE(Data, '$.Weight') FROM Product WHERE Type=1 AND JSON_VALUE(Data, '$.Gender') = 'F' ORDER BY Price, CAST(JSON_VALUE(Data, '$.Weight') as float)

Optimizing JSON Queries select JSON_VALUE(Data, '$.Type') as Type, Color, AVG( cast(JSON_VALUE(Data, '$.ManufacturingCost') as float) ) as Cost from Product group by JSON_VALUE(Data, '$.Type'), Color having JSON_VALUE(Data, '$.Type') is not null order by JSON_VALUE(Data, '$.Type')

Index on JSON Data select JSON_VALUE(Data, '$.Type') as Type, Color, AVG( cast(JSON_VALUE(Data, '$.ManufacturingCost') as float) ) as Cost from Product group by JSON_VALUE(Data, '$.Type'), Color having JSON_VALUE(Data, '$.Type') is not null order by JSON_VALUE(Data, '$.Type') alter table product add Type AS JSON_VALUE(Data, '$.Type'), ManufacturingCost AS cast(JSON_VALUE(Data, '$.ManufacturingCost') as float) create index json_index on Product(Type, Color) include (ManufacturingCost)

Index on JSON Data select JSON_VALUE(Data, '$.Type') as Type, Color, AVG( cast(JSON_VALUE(Data, '$.ManufacturingCost') as float) ) as Cost from Product group by JSON_VALUE(Data, '$.Type'), Color having JSON_VALUE(Data, '$.Type') is not null order by JSON_VALUE(Data, '$.Type')

SQL results as JSON SELECT ProductID, Name, Price, Tags = JSON_QUERY(Tags), Data = JSON_QUERY(Data) FROM Product FOR JSON PATH ID Name Price Tags Data 15 Bike 100 […] {…} 16 Car 29000 17 BB Ba… 29,99 18 Blade 18.50 19 Helmet 41.99 [ {"ProductID":15,"Name":“Bike","Price":100,"Data":{"Type":"Part","MadeIn":“SRB"}}, {"ProductID":16,"Name":“Car","Price":29000,"Tags":["promo"],"Data":{"Cost":11.67,"Type":"Part"}}, {"ProductID":17,"Name":"BB Ball Bearing","Price":28.99,"Data":{"Cost":21.162700,"Type":"Part"}}, {"ProductID":18,"Name":"Blade","Price":18.50,"Tags":["new"],"Data":{}}, {"ProductID":19,"Name":"Helmet","Price":41.99,"Tags":["promo"],"Data":{"Cost":30.65}} ]

JSON to result set [ {"ProductID":15,"Name":“Bike","Price":100,"Data":{"Type":"Part","MadeIn":“SRB"}}, {"ProductID":16,"Name":“Car","Price":29000,"Tags":["promo"],"Data":{"Cost":11.67,"Type":"Part"}}, {"ProductID":17,"Name":"BB Ball Bearing","Price":28.99,"Data":{"Cost":21.162700,"Type":"Part"}}, {"ProductID":18,"Name":"Blade","Price":18.50,"Tags":["new"],"Data":{}}, {"ProductID":19,"Name":"Helmet","Price":41.99,"Tags":["promo"],"Data":{"Cost":30.65}} ] ID Name Price Tags Data 15 Bike 100 […] {…} 16 Car 29000 17 BB Ba… 29,99 18 Blade 18.50 19 Helmet 41.99 SELECT * FROM OPENJSON (@p) WITH ( ProductID int, Name nvarchar(50), Price money, Type nvarchar(max) AS JSON, Data nvarchar(max) AS JSON)

Building REST API using SQL Server Exchanging JSON data with client applications

Built for Web Applications Web Browser Web Server Initial request </> Database AJAX T-SQL JSON

REST API REST End-point Get data from SQL Database

Returning JSON results Id Title Data Tags 1 Bike {….} […] 2 Helmet { } View Model ORM { }

Importing JSON objects Id Title Data Tags 1 Bike {….} […] 2 Helmet { } DTO ORM { }

SQL Server Samples on GitHub Product Catalog REST API

Data Access Component var pipe = new QueryPipe(“connection string”); await pipe.Stream(“SELECT …. FOR JSON PATH”, Response.Body); var mapper = new QueryMapper(“connection string”); var json = await mapper.GetStringAsync(“SELECT …. FOR JSON PATH”); var cmd = new Command(“connection string”); await cmd.ExecuteNonQuery(“UPDATE …”); Lightweight and simple Handles connection Error handling Asynchronous library .BeginReaderAsync() .WriteAsync() Callbacks Open source

DEMO

Questions? Jovan Popovic jovanpop@microsoft.com @jovanpop_msft