You are previewing Amazon SimpleDB Developer Guide.
O'Reilly logo
Amazon SimpleDB Developer Guide

Book Description

Scale your application's database on the cloud using Amazon SimpleDB

  • Offload the time, effort, and capital associated with architecting and operating a simple, flexible, and scalable web database

  • A complete guide that covers everything from installation to advanced features aimed at optimizing your application

  • Examine SimpleDB and the relational database model and review the Simple DB data model

  • Packed with examples in Java, PHP, and Python and screenshots to illustrate key concepts allowing you to focus application development

  • In Detail

    SimpleDB is a highly scalable, simple-to-use, and inexpensive database in the cloud from Amazon Web Services. But in order to use SimpleDB, you really have to change your mindset. This isn't a traditional relational database; in fact it's not relational at all. For developers who have experience working with relational databases, this may lead to misconceptions as to how SimpleDB works.

    This practical book aims to address your preconceptions on how SimpleDB will work for you. You will be quickly led through the differences between relational databases and SimpleDB, and the implications of using SimpleDB. Throughout this book, there is an emphasis on demonstrating key concepts with practical examples for Java, PHP, and Python developers.

    You will be introduced to this massively scalable schema-less key-value data store: what it is, how it works, and why it is such a game-changer. You will then explore the basic functionality offered by SimpleDB including querying, code samples, and a lot more. This book will help you deploy services outside the Amazon cloud and access them from any web host.

    You will see how SimpleDB gives you the freedom to focus on application development. As you work through this book you will be able to optimize the performance of your applications using parallel operations, caching with memcache, asynchronous operations, and more.

    Gain in-depth understanding of Amazon SimpleDB with PHP, Java, and Python examples, and run optimized database-backed applications on Amazon's Web Services cloud

    Table of Contents

    1. Amazon SimpleDB Developer Guide
      1. Amazon SimpleDB Developer Guide
      2. Credits
      3. Foreword
      4. About the Authors
      5. About the Reviewers
      6. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Errata
          2. Piracy
          3. Questions
      7. 1. Getting to Know SimpleDB
        1. Experimenting with SimpleDB
        2. How does SimpleDB work?
          1. Domain
          2. Item
          3. Attributes
          4. Values
        3. How do I interact with SimpleDB?
        4. How is SimpleDB priced?
          1. Free tier
        5. Why should I use SimpleDB?
          1. Make your applications simpler to architect
          2. Build flexibility into your applications
          3. Create high-performance web applications
          4. Take advantage of lower costs
          5. Scale your applications on demand
          6. Architect for the cloud
        6. Summary
      8. 2. Getting Started with SimpleDB
        1. Creating an AWS account
        2. Enabling SimpleDB service for AWS account
        3. Query API and authentication
        4. SimpleDB libraries
        5. SDBtool — Firefox plugin
        6. Sample outline — performing basic operations
        7. Basic operations with Java
          1. Exploring SimpleDB with Java
          2. Creating a domain with Java
          3. Listing domains with Java
          4. Manipulating items with Java
          5. Deleting a domain with Java
        8. Basic operations with PHP
          1. Exploring SimpleDB with PHP
          2. Creating a domain with PHP
          3. Listing domains with PHP
          4. Manipulating items with PHP
          5. Deleting a domain with PHP
        9. Basic operations with Python
          1. Introducing boto
          2. Exploring SimpleDB with Python
          3. Creating a domain with Python
          4. Retrieving a domain with Python
          5. Creating items with Python
        10. Summary
      9. 3. SimpleDB versus RDBMS
        1. No normalization
        2. No joins
        3. No schemas
        4. Simpler SQL
        5. Only strings
        6. Eventual consistency
          1. Flash: February 24, 2010 — consistent read added
        7. Scalability
        8. Low maintenance
        9. Advantages of the SimpleDB model
        10. Disadvantages of the SimpleDB model
        11. Summary
      10. 4. The SimpleDB Data Model
        1. Domains
          1. Domains with Java
          2. Domains with PHP
          3. Domains with Python
        2. Exploring the metadata for a domain and costs
          1. Retrieving domain metadata
            1. Retrieving domain metadata with Java
            2. Retrieving domain metadata with PHP
            3. Retrieving domain metadata with Python
          2. Components of a domain's metadata
          3. SimpleDB domain constraints
        3. Items
          1. Adding attributes to an item with Java
          2. Adding attributes to an item with PHP
          3. Adding attributes to an item with Python
          4. Constraints on SimpleDB items
        4. Attributes
          1. Attributes with Java
          2. Attributes with PHP
          3. Attributes with Python
          4. Constraints on SimpleDB item attributes
        5. Values
          1. Storing multiple values in a single attribute with Java
          2. Storing multiple values in a single attribute with PHP
          3. Storing multiple values in a single attribute with Python
          4. Constraints on values of a SimpleDB item
        6. Consistent Read and Conditional Put / Delete announcement
          1. ConsistentRead = true for getAttributes and Select
          2. Conditional Put / Delete
        7. Summary
      11. 5. Data Types
        1. What is lexicographical comparison?
        2. Storing numeric values
          1. Storing numeric values with Java
          2. Storing numeric values with PHP
          3. Storing numeric values with Python
        3. Storing date values
          1. Storing date values with Java
          2. Storing date values with PHP
          3. Storing date values with Python
        4. Storing Boolean values
          1. Storing Boolean values with Java
          2. Storing Boolean values with PHP
          3. Storing Boolean values with Python
        5. XML-restricted characters
          1. Using base64 values with Java
          2. Using base64 values with PHP
          3. Using base64 values with Python
        6. Summary
      12. 6. Querying
        1. Sample data
          1. Loading the sample data
            1. Importing the sample data with Java
            2. Importing the sample data with PHP
            3. Importing the sample data with Python
          2. Using Select
            1. Simple select with Java
            2. Simple select with PHP
            3. Simple select with Python
          3. Quoting values in Select expressions
          4. Predicates in Select expressions
            1. Simple predicate query with Java
            2. Simple predicate query with PHP
            3. Simple predicate query with Python
        2. Comparison operators
        3. Queries with Select
          1. Comparison operators
          2. Greater than
          3. LIKE
          4. NOT LIKE
          5. BETWEEN
          6. IN
          7. IS NULL
          8. IS NOT NULL
          9. EVERY()
        4. Combining expressions
          1. INTERSECTION
          2. NOT
          3. OR
        5. Sorting
        6. Counting the results
          1. COUNT()
        7. Queries on multi-valued attributes
        8. Querying for multi-valued attributes
          1. getAttribute
            1. getAttributes in Java
            2. getAttributes in PHP
            3. getAttributes in Python
        9. Summary
      13. 7. Storing Data on S3
        1. Amazon S3
          1. Buckets
          2. Objects
          3. Keys
        2. Pricing for S3
        3. Plan of action
          1. Creating an S3 bucket
            1. Creating an S3 bucket with Java
            2. Creating an S3 bucket with PHP
            3. Creating an S3 bucket with Python
          2. Creating additional metadata
            1. Creating additional metadata with Java
            2. Creating additional metadata with PHP
            3. Creating additional metadata with Python
          3. Uploading the songs to S3
            1. Uploading the songs to S3 with Java
            2. Uploading the songs to S3 with PHP
            3. Uploading the songs to S3 with Python
          4. Retrieving the files from S3
            1. Retrieving the files from S3 with Java
            2. Retrieving the files from S3 with PHP
            3. Retrieving the files from S3 with Python
        4. Summary
      14. 8. Tuning and Usage Costs
        1. BoxUsage
          1. Computing costs using BoxUsage
          2. Usage reports
          3. BoxUsage — Java
            1. Cost of Select
          4. BoxUsage — PHP
            1. Cost of NextToken
            2. Cost of Select
            3. Cost of creating a domain
            4. Cost of creating items
          5. BoxUsage — Python
        2. Partitioning
        3. Summary
      15. 9. Caching
        1. Caching
        2. Memcached
        3. Memcached and security
        4. Installing memcached
        5. Installing memcached client
          1. Memcached client in Java
          2. Memcached client in PHP
          3. Memcached client in Python
        6. Storing and retrieving data from memcached
          1. Storing and retrieving data from memcached in Java
          2. Storing and retrieving data from memcached in PHP
          3. Storing and retrieving data from memcached in Python
        7. Cache_Lite
        8. Logic flow for using caching with SimpleDB
          1. Using memcached with SimpleDB in Java
          2. Using Cache_Lite with SimpleDB in PHP
          3. Using memcached with SimpleDB in Python
        9. Summary
      16. 10. Parallel Processing
        1. BatchPutAttributes
          1. BatchPutAttributes in Java
          2. BatchPutAttributes in PHP
          3. BatchPutAttributes in Python
        2. Serialized SimpleDB requests
        3. Parallelizing SimpleDB requests
          1. Parallelizing SimpleDB requests in Java
          2. Parallelizing SimpleDB requests in PHP
          3. Parallelizing SimpleDB requests in Python
          4. Simple threading
          5. Threading with queues
          6. Threading with workerpool
        4. Concurrency and SimpleDB
        5. Summary