I am using MYSQL Database.I have created a schema for my application , but my problem is that my application will host data of many different companies . I wonder if I have have to duplicate the same schema for each companies or is there a way to use the same schema to host data for all companies. Thanks in advance
Asked
Active
Viewed 118 times
3 Answers
0
Have a column named company_name and insert name of company there

Jonathan
- 2,700
- 4
- 23
- 41
-
yes of course @jNg ,I know already this technic , thanks to confirm that I am doing the right thing...thanks – Gneto Dominique Page Home Jun 16 '17 at 21:44
0
Look, generally speaking if you have unstructured and unpredictable data structure going to no sql will be the best option but hard to maintain your code. But if you're willing to go for schema based dbs like mysql, you should have one schema for all the companies. You might have a schema for the common companies attributes and one field for the unpredictable attributes. You may have attribute called "company_data" with a json data type (have a look here https://dev.mysql.com/doc/refman/5.7/en/json.html)
your companies table might look like
-----------------------------------------------------------------------
| title | address | company_data |
-----------------------------------------------------------------------
| IBM | 15, miami str,... | {"space": 122, "num_of_employess": 1000}|
-----------------------------------------------------------------------
| Google| sillicon valley | {"number_of_products": 122,"traffic": 12|
-----------------------------------------------------------------------

Alaa Attya Mohamed
- 78
- 4
0
This technique is called muti-tenant database. you can check this question for better understanding

Alaa Attya Mohamed
- 78
- 4