Quantcast
Channel: Griffith's blog
Viewing all articles
Browse latest Browse all 4

SimpleDB

$
0
0

Amazon SimpleDB is another service from Amazon that uses its Dynamo technology. With SimpleDB, Amazon has at last incorporated database as part of the company's web services. SimpleDB is currently available to the public as a beta service, with several technical limitations, including:
A single query will timeout after 5 seconds.
Only strings are available as data type.
Data query, write, retrieval are type casted into strings.
Strings cannot have more than 1,024 characters.
An item can have a maximum of 256 attributes.
In open beta testing, a SimpleDB domain is capped at 10GB capacity.

SimpleDB is not RDBMS (relational database management system), but it rather operates in a far simpler fashion. Amazon SimpleDB's data are stored as Domain → PKeys, PKeys → Attributes, and within each attribute, Key → Value. For instance:

Key:1
Attributes:
Category: Company
Name: Cellopoint
Website: http://www.cellopoint.com

Being a database, SimpleDB comes with its own querying API.

Installing the PHP Library for Amazon SimpleDB:
1. Download PHP Library for Amazon SimpleDB at Amazon Web Services (AWS) website.
2. Extract the file.
3. Request and retrieve Access Key ID and Secret Access Key from AWS.

Client connection testing:
1. cd to PHP Library for Amazon SimpleDB directory.
2. vim test_client.php
<?php
$AWS_ACCESS_KEY_ID = …
$AWS_SECRET_ACCESS_KEY = …

require_once('Amazon/SimpleDB/Mock.php');
$service = new Amazon_SimpleDB_Mock();

require_once('Amazon/SimpleDB/Client.php');
$service = new Amazon_SimpleDB_Client($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY);
?>
3. Run test_client.php

Inserting data:
1. PHP aplication
$domain= “MyDomain”;
$item = “Product01”;

$attr1 = new Amazon_SimpleDB_Model_ReplaceableAttribute();
$attr1->withName('Category')->withValue('Device');

$attr2 = new Amazon_SimpleDB_Model_ReplaceableAttribute();
$attr2->withName('Name')->withValue('D01');

$attrArr = array($attr1, $attr2);

$request = new Amazon_SimpleDB_Model_PutAttributesRequest();
$request->withDomainName($domain)->withItemName($item)->setAttribute($attrArr);

invokePutAttributes($service, $request);
2. Service response

Service Response
==============================
PutAttributesResponse
ResponseMetadata
RequestId
...
BoxUsage

Retrieving data:
1. PHP application
$request = new Amazon_SimpleDB_Model_QueryRequest();
$request->setDomainName('MyDomain');
$request->setQueryExpression(“['Category' = 'Device']”);

invokeQuery($service, $request);
2. Service response
GetAttributesResponse
GetAttributesResult
Attribute
Name
Category
Value
Device

ResponseMetadata
RequestId

BoxUsage
..  read more »


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images