beyond-blockchain / bbc1

BBc-1, a trustable system of record keeping beyond blockchains
Other
80 stars 27 forks source link

When using MySQL, different domains store in same database. #102

Open r-tominaga opened 6 years ago

r-tominaga commented 6 years ago

MysqlAdaptor doesn't create database in each domain.

r-tominaga commented 6 years ago

I tried to fix it, when the database whose name is domain_id doesn't exist, create it. But there is another problem.

It is recommended that you do not use names that begin with Me or MeN, where M and N are integers. For example, avoid using 1e as an identifier, because an expression such as 1e+3 is ambiguous. Depending on context, it might be interpreted as the expression 1e + 3 or as the number 1e+3.

Be careful when using MD5() to produce table names because it can produce names in illegal or ambiguous formats such as those just described.

https://dev.mysql.com/doc/refman/5.6/en/identifiers.html

domain_id is result of MD5 hash function, therefore the head of domain_id collides '1e' probablistically.

r-tominaga commented 6 years ago

It can avoid to surround database name with backticks. But I cannot be assure that it is the best solution.

quvox commented 5 years ago

Thanks.

To avoid the probrem, I will modify data_handler.py to append a prefix string like "bbc".

quvox commented 5 years ago

Sorry, I answered wrongly. You can set DB for each domain by modifying config.json. 'db' entry in a target domain specifies what database you uses.

In the current implementation, the name of the database must be configured manually in the config.json. I'm not sure whether it is a good idea to determine the database name automatically (like "dom"+domain_id).