Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unless of course if you have <em>two</em> databases located on <em>two</em> different DB servers, why don't you simply create a table <code>articles</code> and a table <code>stock</code> referencing it. You could add the <em>shop</em> (ideally the <code>shop_id</code>) as an extra column of that latter. Something like that:</p> <pre><code>CREATE TABLE articles(id int primary key not null, name char(20) not null); CREATE TABLE stock(article_id int not null, shop ENUM('M', 'S') not null, qty int not null, FOREIGN KEY(article_id) REFERENCES articles(id), UNIQUE(article_id, shop)); </code></pre> <p>Please see <a href="http://sqlfiddle.com/#!2/e6eca/5" rel="nofollow">http://sqlfiddle.com/#!2/e6eca/5</a> for a live example.</p> <p>If you really need to restrict creation of items on table <code>articles</code> to <em>shop M</em> that could be achieved by creating different users for your DB (*user_m*, *user_s*) and using <code>REVOKE</code> and/or <code>GRANT</code> to setup the various access rights.</p> <hr> <p><strong>EDIT:</strong> If the two servers are on distant sites, you would probably be able to use <a href="http://dev.mysql.com/doc/refman/5.0/en/replication.html" rel="nofollow">MySQL replication</a> capabilities to keep one or many tables in sync between the two sites. This will require a network access between the two sites. As of myself, for obvious reasons, I would consider using a secure tunnel between the two sites. Finally you still probably have to set-up permissions at DB-level to only allow insert from one site and not the other. </p> <p>As a "poor's man" solution, you finally have the possibility to backup on regular basis the required tables from one server to update the tables on the second server. A combination of mysqldump + cronjob would be good starting point.</p> <p>As of myself, I would though push to <em>MySQL replication</em>. The setup is probably more complex. But this will perform better, scale better and have lower latency.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload