I work currently in a DWH. A big part of my job is to move data from some OLTP Database to the DWH.
One practice that we do is:
-Create the new table that we need.
create table Mytable
(Column1 date,
Column2 varchar(8));
-Create a view for the new table (exactly the same)
create view Myview as select * from dummy
alter view Myview (
Column1
,Column2
) as
select
Column1
column2
from Mytable
-Read from that View
here come one procedure that use Myview and not Mytable. why?
I understand of course the functionality of Views for reducing complexity in a save querys or that they are good to protect parts of the table to some final users.
But I can not see why is a good practice to read from the view and not direct from the Table.
I mean of course the case where the View is exactly the same as the Table.
Thanks for your answers , Enrique
This question is dangerously close to asking for an opinion.
But, views are often recommended for such a system because they isolate users from the underlying data structure. In other words, you can maintain the data and not have to change queries in user applications.
In addition, views are a convenient way to add in computed columns. The computed columns often contain business rules. Having the logic in a single place prevents the proliferation of business logic -- and the errors and the inconsistencies that can arise over time.