How to create a database for multiple domains?

How to create a database and organize data if I have two or more domains and one database? All sites for e-commerce and one product can be sold on each site. Therefore, I have only two ideas:

  • I need to create another field (site_id) in almost every table and duplicate the data.
  • I need to create one table with site_id information for all other fields from other tables.

Both ideas have huge cons. Any ideas? Thanks.

+3
source share
5 answers

, , . site_id, .

( ) , Customers, Invoices , site_id . site_id Customer.

+2

. , :

  • (site_id ) , . , (.. ).

  • . , .

. :

  • ORM.
  • . 70 000 , , 70 000 .
  • SQL.
+4

, , Wordpress Drupal, - :

dom1_Customers
dom2_Customers

, , site_id. , , ( ).

0

, . , 1, 2 .. . ! SiteID ProductID, ProductID . , , " " . , , , ! , , , . SiteID , , . , SiteID , ... -. 5 SiteID ! , !

As for the horizontal partitioning into separate tables with similar names ... use SQL Server 2005 and above. It has functions for partitioning, so the problem with data size is no longer a problem.

0
source

There can be a question with multiple databases? It seems to be the simplest and cleanest, you cannot mess up one dannant of data with another. You will need one primary database for tenant information and one dB for each tenant.

0
source

Source: https://habr.com/ru/post/1710809/


All Articles