Creating a Domain

The first step in storing data within Amazon SimpleDB is to create one or more domains. Domains are similar to database tables, except that you cannot perform functions across multiple domains, such as querying multiple domains or using foreign keys. As a result, you should plan a Amazon SimpleDB data architecture that will meet the needs of your project.

All data that will be searched in a single query should be grouped using a single domain. For example, a web commerce application might contain a customer domain that contains all customer data (name, address, phone, and so on) and a products domain that contains all product information (name, description, price, cost, and so on).

[Note]Note

Although the Amazon SimpleDB API cannot perform queries across multiple domains, you can design your applications to perform queries across multiple domains.

The following sample code snippets demonstrate creation of the MyStore domain.

Java

To run the sample

  1. Open a clean copy of CreateDomainSample.java.

  2. Remove any comment marks from the invokeCreateDomain(service, request); line and add the following line after // @TODO: set request parameters here:

    request.withDomainName("MyStore");
    
  3. Complile and run the sample.

    The MyStore domain is created.

C#

To run the sample

  1. Open AmazonSimpleDBSamples.cs.

  2. Replace the Create Domain Action section with the following:

    CreateDomain createDomainAction = (new CreateDomain()).WithDomainName("MyStore");
    CreateDomainSample.InvokeCreateDomain(service, createDomainAction);
    
  3. Run the sample.

    The MyStore domain is created.

Perl

To run the sample

  1. Open a clean copy of CreateDomainSample.pl.

  2. Remove any comment marks from the invokeCreateDomain($service, $request); line and add the following line after the @TODO: set request line:

    my $request = Amazon::SimpleDB::Model::CreateDomain->new({DomainName => "MyStore"});
    
  3. Run the sample.

    The MyStore domain is created.

PHP

To run the sample

  1. Open a clean copy of CreateDomainSample.php.

  2. Remove any comment marks from the invokeCreateDomain($service, $request); line and add the following lines after the // @TODO: set request line:

    require_once ('Amazon/SimpleDB/Model/CreateDomain.php');
    $request = new Amazon_SimpleDB_Model_CreateDomain();
    $request->setDomainName('MyStore');
    
  3. Run the sample.

    The MyStore domain is created.

VB.NET

To run the sample

  1. Open AmazonSimpleDBSamples.vb.

  2. Replace the Create Domain Action section with the following:

    Dim createDomainAction As New CreateDomain()
    createDomainAction.DomainName = "MyStore"
    
    CreateDomainSample.InvokeCreateDomain(service, createDomainAction)
    
  3. Run the sample.

    The MyStore domain is created.

Scratchpad

To run the sample

  1. Open the scratchpad application with a web browser.

  2. Select Create Domain from the Explore API list box.

  3. Enter MyStore in the Create Domain field.

  4. Select from the following:

    • To invoke the request, click Invoke Request.

      Amazon SimpleDB returns a response.

    • To view the signed URL, click Display Signed URL. Then, copy and paste the signed URL into a browser.

      Amazon SimpleDB returns a response.

    • To view the string to sign, click Display String to Sign.