简体   繁体   English

2个数据库,而不是1个?

[英]2 databases, vs 1?

I have a database of all countries and cities, I would like to use ajax to use it to give suggesstions in the country cities fields in forms, I have a lot of tables in my db related to the inner workings of the site. 我有一个所有国家和城市的数据库,我想使用ajax来以表格的形式在“国家城市”字段中提出建议,我的数据库中有很多与网站内部工作相关的表。 Is it ok if I put this in a different database (just this world map database)? 如果将其放在其他数据库(仅此世界地图数据库)中可以吗? I rather put it in a different db so it's more organized and I wouldnt really be connecting to it on the same pages that I connect to the main database. 我宁愿将其放在不同的数据库中,以便使其更有条理,而且我真的不会在与主数据库连接的同一页面上将其连接。 basically a small php page that will suggest strings with json. 基本上是一个小的php页面,将建议使用json字符串。 I was wondering if a seperate db means sharing the db pooll and decrease of performance!?? 我想知道单独的数据库是否意味着共享数据库pooll并降低性能!

I should add that these new tables are and sql script on geobytes.com and I don't know how good they are or if I am gonna use them down the path! 我应该在geobytes.com上添加这些新表和sql脚本,但我不知道它们有多好,或者我是否会沿途使用它们! I hope to find something better with a uptodate list of ip tables! 我希望通过ip表的最新列表找到更好的东西! like ip2location 像ip2location

Avoid premature optimization. 避免过早优化。 IF you're trying to keep things separate (for architectural reasons), then that's fine. 如果您试图将各个部分分开(出于架构原因),那很好。 If you're trying to increase performance, then how do you know that this will even increase performance at all? 如果您想提高性能,那么您怎么知道这甚至可以提高性能? You'll have the overhead of additional data files, possibly with more overhead on your database server to manage multiple databases. 您将拥有其他数据文件的开销,而数据库服务器上用于管理多个数据库的开销可能更大。

At best it's probably a performance wash. 充其量它可能是性能的提升。

I don't quite understand why you'd want to do this. 我不太明白为什么要这么做。 It complicates things in terms of: 它使事情变得复杂:

  1. managing 2 databases - eg backups and restores. 管理2个数据库-例如备份和还原。
  2. managing 2 connection configurations + connection pools. 管理2个连接配置+连接池。
  3. future potential referential integrity (eg at some stage will you have entities tied to cities/countries?) 未来潜在的参照完整性(例如,在某个阶段,您是否将实体与城市/国家绑定在一起?)

I would leave these tables where they are for the moment. 我现在将这些表保留在原处。 Pull them out if/when they cause you a performance problem. 如果它们引起性能问题,请将它们拉出。

There's nothing particularly wrong with that. 这没有什么特别的错误。 I dont know if its necessary - if its just a table or two I cant see why it'd matter much performance or security wise, either way. 我不知道它是否必要 -如果只是一个表或两个表,我看不出为什么无论哪种方式对性能或安全性都至关重要。 If you are concerned about the script accessing those additional tables, you can use a different database user name for your json script and set that to read only so that if it does get exploited somehow, it cant alter your other tables. 如果您担心脚本访问这些其他表,则可以为json脚本使用不同的数据库用户名,并将其设置为只读,以便如果确实以某种方式被利用,则无法更改其他表。

Honestly I think your best bet is to keep it in one db for now, but write your script flexible enough that you can point it at a separate database should the need ever arise. 老实说,我认为最好的选择是暂时将其保存在一个数据库中,但是编写脚本要足够灵活,以便在需要时可以将其指向一个单独的数据库。

If you ever need to scale out, your app would already have them split, so it would be easier. 如果您需要扩展,则您的应用程序已经将它们拆分了,因此会更容易。 You could put the second database on a second machine if it becomes a performance issue. 如果第二个数据库出现性能问题,则可以将其放在第二台计算机上。

If you have a many core database server, having them on a single machine shouldn't be a problem for most apps. 如果您有许多核心数据库服务器,则对于大多数应用程序来说,将它们放在一台计算机上不是问题。

Sounds like this geographical reference data is your own, whereas your website has a lot of other 'inner workings'. 听起来这个地理参考数据是您自己的,而您的网站还有许多其他“内部工作方式”。

Is your website a CMS or similar from a 3rd party - Drupal/Joomla/etc? 您的网站是CMS还是来自第三方的类似软件-Drupal / Joomla / etc?

If so, keep your own data out of there. 如果是这样,请保留您自己的数据。 If you're planning on exposing this geographical data to a web service, it stands by itself. 如果您打算将此地理数据公开给Web服务,则它本身就是独立的。

If this site is your own, consider how much normalization is between the other tables in that database to your geographic reference tables. 如果此站点是您自己的,请考虑该数据库中其他表与地理参考表之间的标准化程度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM