The essence and logic of the database

I have a question that has been around for several years. As all you know, Entity Framework is an ORM tool that tries to model a database into an Object Oriented Access Model. All the samples I've seen query the database tables directly. So what is the role of views in a database? Views were used for more convenient database modeling, i.e. Multiple physical tables, one logical table. This was great, for example, for hiding the complex relational model across stored procedures, since the query inside them was much easier than repeating the query joins over and over again in each stored procedure. So the question is, why is the entity structure so good if stored procedures cannot retrieve it?

I will try to explain it in a different way. You have a table called category. You have another table called items. Each item can be in multiple categories, and one category can contain multiple items. For each category, I want to calculate how many items (this is simple, but imagine this calculation has a very complex formula). And now the problem arises:

Choice 1: Create a VCategory view with this calculation. Choice 2: Include the table category in the entity framework, then extend the class to include the calculation.

Pros of choice 1: Calculation is available to everyone. Contrast selection 1: The preview is not refreshed.

Plus Choice 2: The table is updated Contras Choice 2: Calculation is available only for .NET compatible systems.

dubts on choice one 1: how to handle this update with entity framework ?. Importing a view and displaying inserts, updates, deletes using stored procedures ?.

dubts on choice one 2: Stored process cannot benefit from entity structure. What if one stored procedure in the database needs this computation ?.

+2


a source to share


1 answer


I don't understand what you mean ...



You can actually use your orm efficiently with views if they are updatable ... so how about using orm + procedures? You can still use your db views in your entity framework and you will end up with a "friendlier" model.

+1


a source







All Articles