Единственный или несколько баз данных

Кажется, что много людей запутывается способом, которым объекты передаются функциям и что передача ссылочными средствами. Переменные объекта все еще передаются значением, его просто значение, которое передается в PHP5, является ссылочным дескриптором. Как доказательство:

value = $value;
    }

    public function getValue() {
        return $this->value;
    }
}

function swap($x, $y) {
    $tmp = $x;
    $x = $y;
    $y = $tmp;
}

$a = new Holder('a');
$b = new Holder('b');
swap($a, $b);

echo $a->getValue() . ", " . $b->getValue() . "\n";

Выводы:

a, b

К передача ссылкой средства мы можем изменить переменные, которые замечены вызывающей стороной. Который ясно выше не делает код. Мы должны изменить функцию подкачки на:

getValue() . ", " . $b->getValue() . "\n";

Выводы:

b, a

для передачи ссылкой.

5
задан Tom H 8 July 2010 в 15:07
поделиться

5 ответов

This question and thus my answer may be close to the gray line of subjective, but at the least I think it would be common practice to separate out the 'admin' tables into their own db for what it sounds like you're doing. If you can tie a client to a specific server and db instance then by having separate db instances, it opens up some easy paths for adding servers to add clients. A single db would require you to monkey with various clustering approaches if you got too big.

[править] Построение идеи о том, что каждый клиент получает свою собственную базу данных, просто задает тон тому, как вы разрабатываете, когда легко вносить структурные и организационные изменения. Через 2 года вы обнаружите, что вам нужно это делать, и это станет намного более болезненным. В прошлом я много раз работал с split dbs, и с ним действительно нетрудно справиться, если вы можете получить некоторое представление о контексте. Похоже, у вас уже есть представление о том, что клиент - это контекст.

Только мои два цента, как я уже сказал, вы можете быть близки к субъективным по этому поводу.

4
ответ дан 14 December 2019 в 04:41
поделиться

Single Database Pros

  • One database to maintain. One database to rule them all, and in the darkness - bind them...
  • One connection string
  • Can use Clustering

Separate Database per Customer Pros

  • Support for customization on per customer basis
  • Security: No chance of customers seeing each others data

Conclusion

The separate database approach would be valid if you plan to support per customer customization. I don't see the value if otherwise.

4
ответ дан 14 December 2019 в 04:41
поделиться

You can use link to connect the databases. Your architecture is smart.

If you can't use a link, you can always replicate critical data to the website database from the users database in a read only mode.

concerning security - The best way is to have a service layer between ASP (or other web lang) and the database - so your databases will be pretty much isolated.

0
ответ дан 14 December 2019 в 04:41
поделиться

If you expect to have to split the databases across different hardware in the future because of heavy load, I'd say split it now. You can use replication to push copies of some of the tables from the main database to the site management databases. For now, you can run both databases on the same instance of SQL Server and later on, when you need to, you can move some of the databases to a separate machine as your volume grows.

0
ответ дан 14 December 2019 в 04:41
поделиться

Imagine we have infinitely fast computers, would you split your databases? Of course not. The only reason why we split them is to make it easy for us to scale out at some point. You don't really have any choice here, 100MB-1000MB per client is huge.

0
ответ дан 14 December 2019 в 04:41
поделиться
Другие вопросы по тегам:

Похожие вопросы: