Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Thanks for your detailed answer. But then, in TPT, if I misunderstood, if I want to know the total cost, I have to do two queries, one to know the total costs of the products and another to know the total cost of the service? This is two trips to the database, or perhaps could I use a union query?
Really cost is not calculated. It is a value that the user set in each case. Anyway, calculated or not, which is the difference? At the end it is a value with the total cost. For example for a product, it is the price I pay for it to the provider. A service is the bill that I get from the person that does the service.
At first I would think for the first option, to run the two operations in one transaction. But How and where I could implement the second option, using the extra step? In the application layer? Could you show and example and how it could be implemented?