SlideShare a Scribd company logo
1 of 23
Download to read offline
AWS Simple DB:,[object Object],Vantaggi/Svantaggi, corretto uso ed esempi,[object Object],Gennaro Varriale,[object Object],XiWeb.it,[object Object]
Introduzione,[object Object],AWS SimpleDB è un servizio web per la gestione di una base dati non relazionale.,[object Object],   (nessuno schema di Database, nessuna Join tra tabelle ),[object Object],I dati sono memorizzati come oggetti con chiave/valore.,[object Object],Gli oggetti sono partizionati in domini. ,[object Object],Le principali operazioni sono Put, Get, Delete e Query,[object Object],Richieste tramite REST e risposte in XML,[object Object]
Modello Dati,[object Object],Domini :  (Fogli) simile alle tabelle ,[object Object],Elementi: (Righe) rappresentano oggetti,[object Object],Attributi: (Colonne) categorie di dati ,[object Object],Valori:  (Celle) dati (anche valori multipli),[object Object]
Esempio,[object Object],Elementi diversi (Film, Libri, CD),[object Object],I valori possono essere multipli (Attori),[object Object],Gli attributi non presenti non sono memorizzati,[object Object],item_01 :  titolo =>Pulp Fiction, attore=> J.Travolta,  attore => S.Jackson , ...,[object Object],Item_o2 : titolo=>Marina,  categoria =>libro, autore=>C.Zafòn ,[object Object],Item_03 : titolo =>Thriller,  categoria =>cd,[object Object]
Vantaggi,[object Object],Facile da utilizzare (set di API),[object Object],Flessibile : Nessuno schema per il database.,[object Object],Scalabile : non ci sono limiti (banda e dati) e performance costante,[object Object],Affidabile : i dati sono memorizzati, replicati e indicizzati.,[object Object],Integrazione con sistemi scalabili : Amazon EC2 e Amazon S3 ,[object Object],Economico: Si paga solo per quello che si usa,[object Object]
Svantaggi,[object Object],Problemi di Latenza,[object Object],    - Aggiornamento dei dati attraverso i vari server,[object Object],    - Richieste : max 250 risultati e token sequenziali,[object Object],Maggior lavoro di programmazione,[object Object],    - tecniche di caching dei dati ed elaborazione,[object Object],Limiti ,[object Object],   - max 256 attributi per elemento,[object Object],   - max 1024 byte per valori,[object Object]
Corretto uso,[object Object],I dati sono stringhe ( codifica UTF-8)  con ordinamento lessicografico,[object Object],  - zero padding ,[object Object],           10 “è minore di”  2     =>    0010  “è maggiore di” 0002             (padding 4) ,[object Object],  - offset per numeri negativi ,[object Object],          -700, -400, 100            =>     0300 , 0600, 1100                           (offset 1000),[object Object],  - formatare i campi data  ,[object Object],YYYY-MM-DDThh:mm:ss                                                                        (formato ISO 8601),[object Object],Gli elementi chiave  devono essere univoci nel dominio.,[object Object],    Es.   Id_utente,   codice fiscale,   (Timestamp)_(random number),[object Object]
Amazon ScratchPad,[object Object]
Create Domain,[object Object]
Put Attributes,[object Object]
Get Attributes,[object Object]
Select,[object Object]
Xml di risposta,[object Object],Xml con i dati di risposta,[object Object]
NextToken,[object Object],Dati,[object Object],Token,[object Object]
Esempio di Query,[object Object],select * fromcollezionewherecategoria= ‘film’,[object Object],select* fromcollezionewherepagine> ‘0120‘ andcategoria= ‘libro’,[object Object],select * fromcollezionewhereautorelike ‘%Zafòn‘,[object Object],select* fromcollezionewhere year between '1998' and'2004‘,[object Object],select* fromcollezionewherecategoriais not null  orderbycategoria,[object Object],selectcount(*) fromcollezionewherecategoria= ‘libro',[object Object]
Librerie di programmazione,[object Object],PHP,[object Object],Java,[object Object],Object C (Iphone),[object Object],C#,[object Object],Perl,[object Object],Ruby,[object Object]
PHP,[object Object], libreria sdb.php,[object Object],         http://sourceforge.net/projects/php-sdb/,[object Object],<?php,[object Object],    require_once('sdb.php');$simpleDB= newSimpleDB($accessKey, $secretKey);,[object Object],?>,[object Object]
Gestione Domini,[object Object],Creare un dominio :    $simpleDB ->createDomain(‘collezione');  ,[object Object],Lista dei domini   $listaDomini= $simpleDB >listDomains() ; ,[object Object],Eliminazione di un dominio    $simpleDB->deleteDomain($nomeDominio) ; ,[object Object]
Inserimento dati,[object Object],<?php,[object Object],  $dati['categoria']['value']=‘film';,[object Object],     //$dati['categoria'][replace ']=false;  //inserimento,[object Object],  $dati['titolo']['value']=‘Pulp Fiction';,[object Object],  $dati['attore']['value'][]=‘J.Travolta';,[object Object],  $dati['attore']['value'][]=‘S.Jackson';,[object Object], $simpleDB->putAttributes(‘collezione‘,   'item_01',  $dati  );,[object Object],?> ,[object Object],Valori Multipli,[object Object]
Aggiornamento,[object Object],<?php,[object Object],    $dati['autore']['value']='C.Zafòn';  $dati[‘autore’][‘replace’]=true;  //aggiorna,[object Object],$simpleDB- >putAttributes (‘collezione‘, 'item_2', $dati);,[object Object]
Cancellazione,[object Object],<?php,[object Object],    $simpleDB- >deleteAttributes(‘collezione', ‘item_02’);,[object Object]
Prelievo Dati,[object Object],$item=  $simpleDB->getAttributes(‘collezione‘,   'item_01‘);,[object Object],echo   $item[‘Attributes’][‘titolo’]; ,[object Object],print_r(  $item );                           ,[object Object],Pulp Fiction,[object Object],Array ( [Name] => ‘item_01’,,[object Object],             [Attributes] => Array ( ,[object Object],                                        [titolo] => ‘Pulp Fiction’,,[object Object],                                        [categoria] => ‘Film’,,[object Object],                                        [attore] => array( 0 =>‘J.Travolta’, ,[object Object],                                                                       1 => ‘S.Jackson’,[object Object],                                                                    )     ,[object Object],                                ),[object Object], ) ,[object Object]
Select,[object Object],$token =null;,[object Object],do{,[object Object],   $query = 'select * from collezione';,[object Object],   $primoSet= $db->select(‘collezione', $query ,$token) );,[object Object],  // max 250 elementi + token,[object Object],   foreach ($primoSet as $item){,[object Object],// chiave in  $item[Name‘]                              ,[object Object],//  valori  in   $item[‘Attributes’]  ,[object Object],   }  ,[object Object],} while ($token!=null); ,[object Object]

More Related Content

Viewers also liked

Brighter Marketing
Brighter MarketingBrighter Marketing
Brighter MarketingSiobhanLees
 
Project management
Project managementProject management
Project managementLuda Ludka
 
Ek Blogging Case
Ek Blogging CaseEk Blogging Case
Ek Blogging Casemashindra24
 
Presentation skills
Presentation skillsPresentation skills
Presentation skillsLuda Ludka
 
Unit 1 (lesson 2)
Unit 1 (lesson 2)Unit 1 (lesson 2)
Unit 1 (lesson 2)Phiat Fuen
 

Viewers also liked (7)

Brighter Marketing
Brighter MarketingBrighter Marketing
Brighter Marketing
 
Project management
Project managementProject management
Project management
 
Ek Blogging Case
Ek Blogging CaseEk Blogging Case
Ek Blogging Case
 
Presentation skills
Presentation skillsPresentation skills
Presentation skills
 
Unit 1 (lesson 2)
Unit 1 (lesson 2)Unit 1 (lesson 2)
Unit 1 (lesson 2)
 
Unit 5a
Unit 5aUnit 5a
Unit 5a
 
Unit 5a
Unit 5aUnit 5a
Unit 5a
 

Aws Simple DB

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.