How can I shard database with multi table ??? (Multi tenancy )

Description

i has 2 table in my database : EMPLOYEE and DEPARTMENT like this picture --> Image

In table EMPLOYEE has column LOCATION and i want to shard this table by LOCATION :
Example : if employee has LOCATION " France " --> shard0 , "USA" --> shard1, "singapore" --> shard2 ....

Here is my code :
Code:
public ShardId getShardId(String _location)
{
int shardId = 0;

if(_location.equalsIgnoreCase("VietNam"))
shardId = 0;
else if(_location.equalsIgnoreCase("Singapore"))
shardId = 1;
else if(_location.equalsIgnoreCase("USA"))
shardId = 2;
else if(_location.equalsIgnoreCase("France"))
shardId = 3;

return new ShardId(shardId);
}

if i shard with 1 table EMPLOYEE , it run successfully, BUT, when i shard it with table DEPARTMENT , it is wrong . It doesn't shard by LOCATION.

It return a shard with DEPARTMENT. it mean : if I has 2 employee with different LOCATION and the same ID_DEP (same DEPARTMENT) , if i shard only 1 Table EMPLOYEE by LOCATION, 2 employee will insert into different shard, BUT if i shard with 2 table EMPLOYEE and DEPARTMENT by LOCATION, 2 employee will insert into same shard (.

Please help me. sr i has bad english (.

Environment

Hibernate3 , hibernate-shards-3.0.0.Beta2, mysql-5.5.14-win32

Status

Assignee

Max Ross

Reporter

Pham Hoang An

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

Yes, likely

Pull Request

None

backportDecision

None

backportReEvaluate

None

Time tracking

24h

Components

Affects versions

Priority

Major
Configure