# xSQL Sample Shards

> This sample demonstrates a simple distributed in-memory database working with 2 shards; each shard holds only part of the database.

> The config files look like the following:

> `shard1.cfg`

>         #
>         #  Simple In-Memory configuration
>         #
>         database_name : imdb,
>         database_size    :  20m,

>         runtime_configuration : {
>             debug_library : false,
>             disk_support : false,
>             shared_memory : false,
>             transaction_manager : mursiw
>           },
>         schema : "
>         #define uint2     unsigned<2>

>         declare database  locatedb;

>         class Employee
>         {
>           string name;
>           uint2 dept_no;

>           unique tree<name> Iname;
>           tree<dept_no>     Idept;
>         };
>         ",
>         db_params: {
>             mem_page_size : 512
>         },

>         sql_trace : false,
>         sql_port : 5500

> `shard2.cfg`

>         #
>         #  Simple In-Memory configuration
>         #
>         database_name : imdb,
>         database_size    :  20m,

>         runtime_configuration : {
>             debug_library : false,
>             disk_support : false,
>             shared_memory : false,
>             transaction_manager : mursiw
>          },
>         schema : "
>         #define uint2     unsigned<2>

>         declare database  locatedb;

>         class Employee
>         {
>           string name;
>           uint2 dept_no;

>           unique tree<name> Iname;
>           tree<dept_no>     Idept;
>         };
>         ",
>         db_params: {
>             mem_page_size : 512
>         },

>         sql_trace : false,
>         sql_port : 5501

> `client.cfg`

>         {
>             remote_client : [ "127.0.0.1:5500", "127.0.0.1:5501"],
>             sql_statements : "
>         1:INSERT INTO Employee(name, dept_no) VALUES('Luke Skywalker', 1);
>         1:INSERT INTO Employee(name, dept_no) VALUES('Han Solo', 1);
>         2:INSERT INTO Employee(name, dept_no) VALUES('Darth Vader', 2);
>         "
>         }

> Note that section `schema` defines the database with inline DDL text and the `sql_statements` section specifies the SQL statements to be executed once the database has been created.

> This sample can be run in 3 separate Console windows from directory `samples\xsql\configs\shards` with the following command:

>         ..\..\..\..\target\bin\xsql -c shard1.cfg -i

> And

>         ..\..\..\..\target\bin\xsql -c shard2.cfg -i

> And

>         ..\..\..\..\target\bin\xsql -c client.cfg -i

> With xSQL started in interactive mode, we can now execute SQL statments. For example:

>         XSQL>select * from Employee;
>         name    dept_no
>         ------------------------------------------------------------------------------
>         Darth Vader     2
>         Han Solo        1
>         Luke Skywalker  1

>         Selected records: 3