The Fabric sharding implementation requires you to provide the sharding key explicitly while executing a query. To define sharding over a set of tables using the sharding mechanism built into Fabric, it is important to understand two concepts and how they relate.
A shard mapping serves to bring a database object (a database table) into the Fabric sharding system. The mapping is a way of informing Fabric that we want a particular sharding scheme (range, hash, list, and so forth.) to be used on a database table, using a value in a particular column. Create a shard mapping as follows:
Define a shard mapping, to tell Fabric the kind of sharding mechanism to use.
Add a relation between the mapping and a database object, to register the database table and a column in the table with the shard mapping.
Once these operations have been completed, we can describe how the shard mapping should split the tables. This is done while creating the shards.
These are the partitions on the table. Since sharding is done on a database table, using an attribute (column) in the table, the values in the column influence how the shards are created. To explain this further, assume that we have two tables we wish to shard.
Assume further that both tables are to be sharded by the employee ID that is part of their columns. Where a row is placed is based on the value in the employee ID column. Hence, in a range-based sharding scheme, a shard is nothing but a range of employee ID values.