0

I want to build a ER-model for companies. Some fields for companies are the same, like the name, legal_address and others, but some fields are defined based on the country, where the company is registered.

For example if we take Russia, the company should have fields like inn, ogrn, etc.. (don't matter the names). If we will take another country - the company will have another set of fields.

I need an advice of how to plan (architect) this.

Any ideas would be great.

At the moment I have this done:

[locations]
id
country
city
lat
lng
zip_code

[companies]
id
location_id
name
director
legal_address
actual_address

[company_russia]
id
company_id
inn
kpp
ogrn
stat_codes
reg_number_fss
reg_number_pfr

But I think there will be problems joining the tables and that each other country requires a separate table - is not a good approach.

Sergej
  • 2,030
  • 1
  • 18
  • 28
  • Depends on how're you going to use it, as usual: the number of countries? Lookups/updates frequency? Option to store all the additional data in another DB? You might want to look into schema-less approach with [JSON](https://stackoverflow.com/questions/33660866/native-json-support-in-mysql-5-7-what-are-the-pros-and-cons-of-json-data-type) datatype, for example. – raina77ow Mar 27 '19 at 10:40
  • [_More_](http://mysql.rjweb.org/doc.php/eav) on using JSON for an EAV schema design. – Rick James Apr 19 '19 at 05:50

0 Answers0