Jan*_*ück 5 database foreign-keys microservices
我对微服务和数据库设计有疑问。情况:我有一个Service AircraftsService,可以处理有关飞机,飞机类型等的所有数据。我有一个Service FlightsService,可以处理有关航班的所有数据。我必须把飞机和飞机联系起来。通常,我会在链接飞机的飞行表中创建一个外键。但是在微服务架构中,我了解到我拥有域和独立的数据库。所以我的问题是我怎么代表这个问题。
My first thought was that i have a database for all aircrafts and a database for all flights. the flights table becoms a 'indirect' foreign key to the aircraft. When i call the flight service the flight service call the aircraft service with the id from the flight table, then build the response. That promised that i do not call the aircraft database direct from the flight service.
Is my solution correct? What is the best practice in this use case?
After i thought about the problem, what is when i delete an aircraft i have to tell the flight service that an specified aircraft not exist any more and the flight service have to update the 'indirect' foreign key.
Can somebody help me?
Thanks
在处理微服务时,最佳数据库实践有多种方式,它可能因所使用的实体的领域以及应用程序使用的范围而异。
\n\n微服务中数据库设计的最佳实践很少,首先列出其中的一些。
\n\n1 - Private-tables-per-service \xe2\x80\x93 each service owns a set of tables that must only be accessed by that service\n2 - Schema-per-service \xe2\x80\x93 each service has a database schema that\xe2\x80\x99s private to that service\n3 - Database-server-per-service \xe2\x80\x93 each service has it\xe2\x80\x99s own database server.\n
Run Code Online (Sandbox Code Playgroud)\n\n您可以根据您的数据大小和数据数量混合和匹配这些。
\n\n我希望您参考并浏览此页面以获得完美的示例。
\n\n\n\n确定您将拥有的每项服务的负载。负载可以通过两种方式计算。
\n\n然后你就可以决定方法了。
\n 归档时间: |
|
查看次数: |
220 次 |
最近记录: |