33
A Real World Web Site with SQL Data Services So Cal Code Camp January 24-25, 2009 James Johnson Inland Empire .NET User’s Group [email protected] www.iedotnetug.org

Sql Data Services

Embed Size (px)

DESCRIPTION

January 24, 2009 presentation to So Cal Code Camp at Cal State Fullerton - A real live web site with SQL Data Services.

Citation preview

Page 1: Sql Data Services

A Real World Web Site with SQL Data ServicesSo Cal Code Camp January 24-25, 2009James JohnsonInland Empire .NET User’s [email protected]

Page 2: Sql Data Services

About me

Founder and President, Inland Empire .NET User’s Group. Past 5 years in Riverside, San Bernardino Counties www.iedotnetug.org

Executive Director, Geeks Without Borders www.geeks-without-borders.org

My Blog www.duringlunch.com

Serial Netrepreneur Latringo.com, ElSalvadorArtwork.com, TourElSalvador.com,

0AAFFF.com, AzureBlueCoding, AnonymousTypes.com, etc. Last but not least

No bailar con monos borracho al comer su almuerzo.

Page 3: Sql Data Services

More stuff

Have been developing software since i286 days Educational CD-ROMs If a mistake, had to redo the entire run Started looking at ways to have dynamic data Web development

Cold Fusion (yuck), PHP (yikes), ASP.NET (the promised land)

Met David Robinson on Code Trip (Feb 08) The rest is history

Page 4: Sql Data Services

SQL Data Services - Introduction

Agenda

2. What is SDS

3. How to setup the development environment

Page 5: Sql Data Services

SQL Data Services - Introduction

1. SDS is a component of SQL Services

2. Integrated into the “cloud”

3. Provides database and querying

4. Flexibility

5. Scaling

6. Developer agility

Page 6: Sql Data Services

SQL Data Services - Introduction

SDS is built on SQL Server and Windows Server

2. Quickly build and extend applications

3. Low cost management with high scalability

4. Reliability, and security features

Page 7: Sql Data Services

SDS – Setting up the environment

Download Azure Services Training Kit www.microsoft.com/azure/trainingkit.mspx Contains Hands-on-labs (HOLs) for:

Windows Azure .NET Services Live Services SQL Services

Page 8: Sql Data Services

SDS – Setting up the environment

Sign up for the SDS Public CTP http://go.microsoft.com/fwlink/?LinkID=133905&clcid=0x409 Sign up is free, but will ask for CC for verification

Create a Solution Name and Password Name of solution is the username when logging into

system via code

Page 9: Sql Data Services

SDS – Setting up the environment

SDS Developer Center http://msdn.microsoft.com/en-us/sqlserver/dataservices/default.aspx Link to change password for solution

SDS Primer http://msdn.microsoft.com/en-us/library/cc512417.aspx

Getting Started Forum http://social.msdn.microsoft.com/forums/en-

US/ssdsgetstarted/threads/

Page 10: Sql Data Services

Authorities, Containers, Entities

Authorities, Containers and Entities, Oh My

2. SDS data model is based on this concept

3. Provides flexible schema

4. Easy to create data structures

Page 11: Sql Data Services

Authorities, Containers, Entities

Authorities

2. Topmost level of the hierarchy anontypes-01

3. DNS name https://anontypes-01.data.database.windows.net/v1

Maps to specific data center Is a unit of geo-location

Page 12: Sql Data Services

Authorities, Containers, Entities

Containers

2. Each container has unique id associated

3. Store the data contained in the application

4. Cannot be in a different geo-located Authority

5. Can contain homogeneous or heterogeneous data

Page 13: Sql Data Services

Authorities, Containers, Entities

Entities

2. Actual bits of data stored in container

3. Stores any number of user-defined properties/values

4. Retrieved, added, updated, deleted

5. Partial updates are not supported

6. Entire entity is replaced in container when updated

Page 14: Sql Data Services

Homogenous/Heterogeneous Data

Homogeneous data is similar to a database table, in which all entities are of the same kind

Books container stores “book” entities Highly structured applications should use

Heterogeneous data contains all types of entities MyOffice container stores “books”, “supplies”,

“furniture” Allows for querying across all entities in parent

container

Page 15: Sql Data Services

Flexible Entities

1. Key concept of SDS

2. XML fragment with one element per property value.

3. Value restricted to simple scalar type of string String, binary, Boolean, decimal, datetime

4. Fixed metadata properties – Id, Version, Kind1. Version. New version assigned with each update

2. Kind. User-defined, identifying the entity type

Page 16: Sql Data Services

Anonymous Types

A new podcasting website featuring the little known development geeks

Site runs on a hosted server Data is hosted on SQL Data Services Leads to differences in how we work with data When using REST, return types are XML Need to use LINQ

Page 17: Sql Data Services

Differences to remember

An Entity is like a property bag – keys/values Each Entity in a Container can have a different

structure Different paradigm than when working with

database tables There is no “primary key”, instead an “EntityID”

User defined value

Page 18: Sql Data Services

Containers

Can contain heterogeneous, homogeneous, or flexible entities

For this project decided to have four Containers at_page at_podcast at_podcastdata at_guest

Page 19: Sql Data Services

Site structure

Administer text data Upload and administer BLOB’s (podcasts)

Demo only shows uploading – not streaming down

Standard ASP.NET Membership, Roles, Authentication for Admin pages

Classes for different aspects of site functions Pages, Podcasts, Guests, Configuration, Utilities

Page 20: Sql Data Services

Using REST

POST (Insert, Create) PUT (Update) GET (Retrieve) DELETE (Delete)

Page 21: Sql Data Services

Page Administration

Insert, Save, Edit, Delete Page code creates XML passed to the class Methods

SelectPages() SelectPage() InsertPage() UpdatePage() DeletePage()

Make sure to HtmlEncode strings going in HTML chars will mess things up with validity of the XML

Page 22: Sql Data Services

Demo

Web site Page administration

Page 23: Sql Data Services

Uploading PodCasts (BLOBs)

Uploading of BLOBs is possible, but can only send the object, no other data

Create two XML strings PodCast

EntityId, Container, FilePath

PodCastData Meta and other data about the PodCast EntityId,Title, RunTime, Guest, Publish Date, etc.

Since two different containers, can have same EntityId

Page 24: Sql Data Services

Uploading PodCasts (BLOBs)

Two step process First insert the Meta data

Title, Guest, Description, etc.

If successful, upload the PodCast

Page 25: Sql Data Services

Demo

Page 26: Sql Data Services

Public facing side

One Master Page Navigation, PodCast List

One Content Page Page Content for different “pages”

Page 27: Sql Data Services

Demo

Setting Navigation

Page 28: Sql Data Services

Demo

Setting Page Content

Page 29: Sql Data Services

Demo

Get All PodCasts Uses Join between Containers so that we can get

data back on the Guests as well

Page 30: Sql Data Services

Demo

Get Single Uses Join between Containers Uses Where to get specific Pod Cast

Page 31: Sql Data Services

Questions

Page 32: Sql Data Services

Thank you

Email – [email protected] Inland Empire .NET User’s Group

www.iedotnetug.org 2nd Tuesday evenings of each month – Riverside

Geeks Without Borders www.geeks-without-borders.org

My Blog www.duringlunch.com

Please tip your wait staff PayPal address – [email protected]

Page 33: Sql Data Services

Thanks to our sponsors

We could not hold these code camps for you without our sponsors.

These Guys ROCK!