Printer Friendly Version      Send     
Click to Rate and Give Feedback
MSDN
MSDN Library
 SSDS Data Model Overview (Authoriti...
SSDS
SSDS Data Model Overview (Authorities, Containers, Entities and Flexible Entities)
[This document supports a preliminary release of a software product that may be changed substantially prior to final commercial release. This document is provided for informational purposes only.]

Organizations are seeing a confluence of factors stretching IT organizations. These factors include massive increase in digital data, the need to process transactions and to support random queries over this vast amount of data, and the explosion of Internet traffic. IT organizations have to deal with issues such as the following:

  • Running out of capacity
  • Needing more servers
  • Needing more rack space
  • Operating the servers
  • Planning for future needs

Providing extra capacity and getting the service up and running to the desired level takes time. The cost of maintaining infrastructure goes up, as well. IT organizations often use standby capacity as needed, adding further to IT costs. Although hardware costs show a downward trend, the amount of digital data is increasing dramatically, which requires more hardware and storage. Significant increases in the amount of software and maintenance are also adding to costs.

As the market place evolved, so did the Microsoft® data platform. The platform provided server-based offerings for all kinds of data, including simple blobs, relational structured data, and XML. Today the platform also offers a rich feature set, including query services, reporting services, and synchronization services. With the marketplace evolution, data services are now added to this picture.

With the introduction of Microsoft SQL Server™ Data Services (SSDS), data platform customers can store data in cloud, complementing our on-premises offering.

SSDS Key features and benefits

The core value proposition of SSDS is providing data as utility service. Your data is available at anywhere, any time. The service delivers the following key benefits:

  • Application agility
    • Easy-to-use service
    • Quicker application development
    • Industry standard and well-known protocol support (REST and SOAP)
  • Scalability
    • Scales as you grow
    • Capacity you need will always be there
    • No wait time for server provisioning
    • Pay as you grow
  • Business-ready SLA
    • Built on robust Microsoft SQL Server and Windows technologies
    • Highly reliable and available

SSDS is currently in invitation-only beta. To explore the service, you need to register at http://www.microsoft.com/sql/dataservices/default.mspx. After registration, you will receive an invitation to sign up and explore the service.

SSDS offers a simple, easy-to-understand data model. SSDS is a Web 2.0–friendly data service that supports open wire formats such as SOAP and REST. A quick SSDS overview below covers the following topics:

  • Data model
  • Service interface
  • URI space and query support
  • Security model

Data Model

The data model includes the concepts of authority, container, and entity, with flexible schema, a core concept in SSDS. The following topics explain the data model concepts:

  • Three-Level Containment Model (the "ACE" Concept)
  • Homogeneous vs. Heterogeneous Containment
  • Flexible Entity

Three-Level Containment Model (the "ACE" concept)

The SSDS data model offers a three-level containment model that includes authorities, containers and entities.

Authority

At the top level of this containment hierarchy is an authority. After you sign up for the data service, you begin by creating an authority. An authority is represented by a DNS name. For example:

mydomain.data.beta.mssds.com

Where mydomain is an authority and data.beta.mssds.com refers to the service. You can own more than one authority. Additional authorities can be created at any time. The DNS name of an authority resolves to an IP address that maps to a specific data center: an authority and the data beneath it are located in a single data center. An authority, then, is the unit of geo-location.

Container

An authority is a collection of containers. Each authority can have zero or more containers stored within it. Each container has a unique id within an authority. A container stores data (entities). You create a container and then immediately begin storing entities of various kinds without having to worry about any container schema.

A container can store zero or more entities, but nested containers (containers within a container) are not supported.

A container is also the largest domain for search and update. In this beta release, cross-container queries are not supported.

Because each authority is in one geo-location, all containers in an authority are located in the same data center.

Entity

Each entity inside a container can store any number of user-defined properties and corresponding values.

An entity is the smallest object that can be updated, that is, you can retrieve an entire entity; add, update, delete properties; and then replace the original entity with the updated one. Partial updates are not supported.

Note:
A container can store zero or more entities, but nested containers (containers within a container) are not supported.

This hierarchical structure of authorities, containers, and entities forms a three-level containment model. This containment model is illustrated in the diagram below:

Blobs

Blobs in SSDS are entities. These blob entities can only have metadata properties.

Homogeneous vs. Heterogeneous Containment

Depending on your application needs, you container can be a homogeneous or heterogeneous.

In the homogeneous model, a container stores entities of the same kind. In this model, a container is like a table in a database. Some of the examples of homogeneous containers are as follows:

  • In an Employee table, you store employee records. These are all records of the same kind. In SSDS, you would create an Employee container that stores Employee entities. These entities can have different properties, but they are all Employee entities.
  • In a sample authority, books-docsamples (DNS name books-docsamples.data.beta.mssds.com), you can create containers such as ChildrensBooks and TechnicalBooks. You then store book entities in appropriate containers.

In a heterogeneous containment model, a container is like a database that stores entities of all kinds. For example, a database can have Orders, Employees, and OrderDetails tables. In SSDS, you can create a single container to store orders, employees, and order details entities. The advantage in this case is that you can query across heterogeneous entities within the same container.

Flexible Entity

In SQL Server Data Services, the flexible entity is a key concept. Each of these entities is a set of metadata properties and a bag of flexible properties.

You can think of flexible entities as sparse tables in the relational data model or an XML fragment with one element per property value. Each property has a name and a value. The value can only be a simple scalar type. The simple scalar types supported in this release are string, binary, Boolean, decimal, and datetime.

Whether you use the REST or SOAP interface discussed below, the XML payload format uses the following standard XSD types to encode scalar values:

  • string
  • base64Binary
  • boolean
  • decimal
  • dateTime
Metadata Properties

Each flexible entity carries a fixed set of properties (Id, Version, and Kind) A blob entity has additional Content property. These are called metadata properties. The Id property uniquely identifies a flexible entity. The Version property acts like a timestamp. The Kind property value is user-defined and identifies the entity type. The Content blob property describes the blob.

Flexible Properties

In addition to the metadata properties, an entity can also have zero or more additional flexible properties. These flexible properties can have any name and any scalar value of one of the above scalar types.

NOTE In the current implementation, there are limits to using the user-defined and metadata properties. For details, see Guidelines and Limitations.

Service Interface (API)

SSDS is a Web 2.0–friendly data service. It supports both the SOAP and REST interfaces so that developers can use almost any language or Web development environment.

The URI Space and Query Support

The discussion of querying for the flexible entities (authorities, containers and entities) discusses the following:

  • The URI Space
  • Query Support

The URI Space

When you program with SSDS, there are four kinds of URIs that you will work with if you are using the REST head. These URI types are described in the following table.

URI type Description

Service

Used only during the authority creation process.

Authority

Used while creating and querying containers. In addition, the authority URI is used to retrieve metadata regarding a particular authority.

Container

Used while creating and querying entities. In addition, the container URI is used to retrieve metadata regarding a particular container or to delete a particular container.

Entity

Used while retrieving, updating, and deleting a particular entity.

You can think of these URIs as setting a scope over which a set of operations can be performed. URI examples are given in the following sections.

Service URI

The following service URI is used when creating an authority. In the URI, v1 refers to version of service interface to be used. For this beta release, the value of version must always be v1.

https://data.beta.mssds.com/v1/
Authority URI

An authority URI is the service URI preceded by the authority id.

https://<authority_id>.data.beta.mssds.com/v1/ 

The authority URI fetches a single entity containing the authority metadata (id, version). A sample authority metadata is shown below:

<s:Authority xmlns:s="http://schemas.microsoft.com/sitka/2008/03/" 
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
             xmlns:x="http://www.w3.org/2001/XMLSchema">
  <s:Id>books-docsamples</s:Id>
  <s:Version>2</s:Version>
</s:Authority>

You can optionally append a query to the authority URI in which you are querying for containers in it.

https://<authority_id>.data.beta.mssds.com/v1/q='<your query>' 

An empty query string returns metadata for all containers within the specified authority. For details about queries, see Querying SQL Server Data Services.

Container URI

A container URI is the authority URI followed by a container id.

https://<authority_id>.data.beta.mssds.com/v1/<container_id>

The container URI fetches a single entity that conatins container metadata. A sample container metadata is shown below:

<s:Container xmlns:s="http://schemas.microsoft.com/sitka/2008/03/" 
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
             xmlns:x="http://www.w3.org/2001/XMLSchema">
  <s:Id>UsedBooks</s:Id>
  <s:Version>1</s:Version>
</s:Container>

A container URI followed by a query returns entities that meet the query criteria from the specified container.

https://<authority_id>.data.beta.mssds.com/v1/<container_id>?q='<your query>'
Entity URI

An entity URI is a container URI followed by entity id. It returns a specific entity, as shown in the following example.

https://<authority_id>.data.beta.mssds.com/v1/<container_id>/<entity_id>

The result includes all the metadata properties (id, version, and kind) and any user-defined flexible properties. A sample book entity is shown below:

<UsedBookKind xmlns:s="http://schemas.microsoft.com/sitka/2008/03/"        
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
              xmlns:x="http://www.w3.org/2001/XMLSchema">
  <s:Id>MySampleBook</s:Id>
  <s:Version>1</s:Version>
  <Title xsi:type="x:string">My Book</Title>
  <ISBN xsi:type="x:string">1-57880-066-36</ISBN>
  <Author xsi:type="x:string">Mr. Author</Author>
  <Publisher xsi:type="x:string">Mr. Publisher</Publisher>
  <InPrint xsi:type="x:boolean">false</InPrint>
  <NumberOfCopiesSold xsi:type="x:decimal">250</NumberOfCopiesSold>
  <PublicationDate xsi:type="x:dateTime">2004-01-27T00:00:00</PublicationDate>
  <CoverPhoto xsi:type="x:base64Binary">AQID</CoverPhoto>
</UsedBookKind>

Query Support

SSDS supports simple text based queries. The general syntax supported in this release is as follows:

from e in entities [where condition] select e

The query iterates over the set of flexible entities in the specified scope and returns only those that satisfy the specified condition in the optional where clause. In the optional where clause, you can specify simple or compound conditions (multiple conditions that are combined by using logical operators). The following table lists the operators that are supported in this release.

Comparison Operators

>, >=, <, <=, ==, !=

Logical operators

&& (and), || (or),! (not)

The query expression can be compared to the C# foreach or LINQ (Language Integrated Query) constructs:

  • C# foreach construct.
    foreach entity e in entities
    {
       if (e satisfies a condition)
       {           yield return e;
       }
    }
  • C# LINQ constructs.
    IEnumerable<FlexibleEntities> results = from e in scope.Entities where condition select e;

The three-level containment model, discussed earlier, influences how we specify the query. The appropriate authority, container, or entity must be in scope during the query. For example:

  • When you query for containers in an authority, the specific authority must be in scope.
  • When you query for entities in a container, the specific container must be in scope.

Here are some query examples:

  • Find an entity given an Id value. In the query, Id is a metadata property, and so the query uses the "." notation.
    from e in entities 
    where e.Id=="MySampleBook1"
    select e
  • Find books where the number of copies sold is less than 1000. This query shows use of a comparison operator.
    from e in entities 
    where e["NumberOfCopiesSold"] < 1000 
    select e
  • For a given publisher, find all books that are out of print. This query illustrates the use of the AND operator (&&).
    from e in entities 
    where e["InPrint"] == false && e["Publisher"] == "Mr. Publisher" 
    select e

Security Model

In this implementation, every authority has a single owner (single user name and password). Once authorized to a specific authority end point, you get full control over the authority and the data stored within it. The accounts are secured by SSDS issued user credentials. Support for HTTPS is present in the service and is available so that applications can communicate with the service in a more secure manner.

          
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker