拥有“关系数据库”安全吗?
我只是想知道拥有两个彼此相关的数据库是否安全,而不是数据库内的表彼此相关? (不要误会我的意思,表格仍然是相关的)
I just want to know if it's safe to have two databases that are relational to one another, rather then the tables inside the database being relational to one another? (don't get me wrong the tables will still be relational)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实际关系通常由使用数据库的应用程序强制执行。因此,如果您有一个从数据库 A 到数据库 B 的关系,那么您可以像在应用程序中那样实现它。
当然,通过拥有两个不同的数据库,您无法获得通常从数据库系统获得的关系的内部支持。例如,您无法指定外键并基于它们添加规则。
The actual relations are usually enforced by the application that is using the database. So if you have a relation that goes from database A to database B, then you can just implement it like that in your application.
Of course by having two different databases, you can't get the internal support for relations you usually get from the database system. So for example you can't specify foreign keys and add rules based on them.
你可以这样做,但这可能不是一个好主意。为了保持一个数据库中的表与另一个数据库中的表之间的关系完整性,您需要使用某种涵盖这两个数据库的分布式事务。这比跨单个数据库的事务要复杂得多。
You could do it but it's probably not a good idea. To keep relational integrity between a table in one database and tables in another you would need to use some sort of distributed transaction which covers both databases. This is far more complicated than a transaction spanning a single DB.
这取决于你所说的“安全”是什么意思。如果您的表是 InnoDB,则可以在同一服务器中跨数据库进行事务。外键约束显然也有效。
强制执行其中任何一个我认为跨多个服务器是不可能的。
It depends what you mean by "safe." If your tables are InnoDB, you can do transactions across databases in the same server. Foreign key constraints apparently also work.
Enforcing either of these across more than one server is, I believe, not possible.