The idea that web services are small bits of functionality or data that are bundled together and encapsulated as small, stand-alone entities is pretty clear, and makes good sense. But how do services relate to databases that they use or provide an interface for?
Web服务是小功能或数据捆绑在一起并封装为小型独立实体的想法非常清楚,并且很有意义。但是,服务如何与他们使用或提供接口的数据库相关?
For example, when moving from a monolithic, 2-tier architecture with a massive database that handled everything to a services-based architecture, how is the database affected? Is the database chunked into smaller databases and each one interfaced with via a service, or does each service simply interact with the original massive database?
例如,当从一个单层的2层架构迁移到一个处理所有内容的大型数据库到基于服务的架构时,数据库如何受到影响?数据库是否分成较小的数据库,每个数据库是通过服务连接的,还是每个服务只是与原始的海量数据库进行交互?
Also, if the database get's split up into, say, a service for user authentication and one for product information, where would the many-to-many entity that tracked product views per user in the original massive database end up?
此外,如果将数据库拆分为例如用于用户身份验证的服务和用于产品信息的服务,那么跟踪原始海量数据库中每个用户的产品视图的多对多实体最终会在哪里?
3 个解决方案
#1
13
Simply put, "it doesn't matter".
简单地说,“没关系”。
Do whichever suits you.
做任何适合你的人。
At the Service API level, the DB "doesn't exist", and it's simply an implementation detail.
在Service API级别,DB“不存在”,它只是一个实现细节。
If the API is done properly, the implementation of the database should not "seep through" the API layer to the clients.
如果API正确完成,则数据库的实现不应该将API层“渗透”到客户端。
Once you've accomplished that at the API level, you can choose to leave the DB "as is" (if it's functional, performs, maintainable, etc.), or you can start breaking it all apart all at once, or incrementally.
在API级别完成后,您可以选择“按原样”保留数据库(如果它是正常的,执行的,可维护的等),或者您可以一次性或逐步地将它们全部分开。
Obviously, breaking the DB up is going to have its own challenges and issues.
显然,打破DB会有自己的挑战和问题。
So, I'd start with the services and their APIs, and making sure you and your clients are happy with those. That process alone may make your decision for you.
因此,我将从服务及其API开始,并确保您和您的客户对这些服务感到满意。仅此过程可能会让您做出决定。
#2
5
I think Martin Fowler has an interesting take on this very subject in his Database Thaw article (a must-read I would say!):
我认为Martin Fowler在他的Database Thaw文章中对这个主题有一个有趣的看法(我会说必读!):
If you switch your integration protocol from SQL to HTTP, it now means you can change databases from being IntegrationDatabases to ApplicationDatabases. This change is profound. ... If you integrate through HTTP it no longer matters how an application stores its own data, which in turn means an application can choose a data model that makes sense for its own needs.
如果将集成协议从SQL切换到HTTP,现在意味着您可以将数据库从IntegrationDatabases更改为ApplicationDatabases。这种变化是深刻的。 ...如果通过HTTP进行集成,则应用程序如何存储自己的数据不再重要,这反过来意味着应用程序可以选择对其自身需求有意义的数据模型。
So the switch "from DB to WS" would let you care more about your data. There's no need to first tailor everything to fit into the relational model, but you could use other models as well like a key/value store, a graph database or a document oriented approach. - Whatever is the best fit for the domain at hand. It could of course be a combination of different models in many cases.
因此,从“数据库到WS”的切换将让您更加关注您的数据。没有必要首先定制适合关系模型的所有内容,但您可以使用其他模型,如键/值存储,图形数据库或面向文档的方法。 - 无论什么是最适合手头的域名。在许多情况下,它当然可以是不同模型的组合。
#3
0
My take on it is that Will Hartung's answer is almost perfect, but I'd include the special case of ETL (Extraction, Transform and Load).
我对它的看法是Will Hartung的答案几乎是完美的,但我将包括ETL(提取,转换和加载)的特殊情况。
This integration pattern is sometimes used in the context of WS's, and involves a WS call (sometimes routed or orchestrated by an Enterprise Service Bus (ESB)), to extract data directly from a DB.
此集成模式有时在WS的上下文中使用,并涉及WS调用(有时由企业服务总线(ESB)路由或编排),以直接从数据库中提取数据。
#1
13
Simply put, "it doesn't matter".
简单地说,“没关系”。
Do whichever suits you.
做任何适合你的人。
At the Service API level, the DB "doesn't exist", and it's simply an implementation detail.
在Service API级别,DB“不存在”,它只是一个实现细节。
If the API is done properly, the implementation of the database should not "seep through" the API layer to the clients.
如果API正确完成,则数据库的实现不应该将API层“渗透”到客户端。
Once you've accomplished that at the API level, you can choose to leave the DB "as is" (if it's functional, performs, maintainable, etc.), or you can start breaking it all apart all at once, or incrementally.
在API级别完成后,您可以选择“按原样”保留数据库(如果它是正常的,执行的,可维护的等),或者您可以一次性或逐步地将它们全部分开。
Obviously, breaking the DB up is going to have its own challenges and issues.
显然,打破DB会有自己的挑战和问题。
So, I'd start with the services and their APIs, and making sure you and your clients are happy with those. That process alone may make your decision for you.
因此,我将从服务及其API开始,并确保您和您的客户对这些服务感到满意。仅此过程可能会让您做出决定。
#2
5
I think Martin Fowler has an interesting take on this very subject in his Database Thaw article (a must-read I would say!):
我认为Martin Fowler在他的Database Thaw文章中对这个主题有一个有趣的看法(我会说必读!):
If you switch your integration protocol from SQL to HTTP, it now means you can change databases from being IntegrationDatabases to ApplicationDatabases. This change is profound. ... If you integrate through HTTP it no longer matters how an application stores its own data, which in turn means an application can choose a data model that makes sense for its own needs.
如果将集成协议从SQL切换到HTTP,现在意味着您可以将数据库从IntegrationDatabases更改为ApplicationDatabases。这种变化是深刻的。 ...如果通过HTTP进行集成,则应用程序如何存储自己的数据不再重要,这反过来意味着应用程序可以选择对其自身需求有意义的数据模型。
So the switch "from DB to WS" would let you care more about your data. There's no need to first tailor everything to fit into the relational model, but you could use other models as well like a key/value store, a graph database or a document oriented approach. - Whatever is the best fit for the domain at hand. It could of course be a combination of different models in many cases.
因此,从“数据库到WS”的切换将让您更加关注您的数据。没有必要首先定制适合关系模型的所有内容,但您可以使用其他模型,如键/值存储,图形数据库或面向文档的方法。 - 无论什么是最适合手头的域名。在许多情况下,它当然可以是不同模型的组合。
#3
0
My take on it is that Will Hartung's answer is almost perfect, but I'd include the special case of ETL (Extraction, Transform and Load).
我对它的看法是Will Hartung的答案几乎是完美的,但我将包括ETL(提取,转换和加载)的特殊情况。
This integration pattern is sometimes used in the context of WS's, and involves a WS call (sometimes routed or orchestrated by an Enterprise Service Bus (ESB)), to extract data directly from a DB.
此集成模式有时在WS的上下文中使用,并涉及WS调用(有时由企业服务总线(ESB)路由或编排),以直接从数据库中提取数据。