Hello:
I am new to T-SQL programing, and relativly new to SQL statements in
general, although I have a good understanding of database theory. I'm a
little confused as to the fundamental differences between a view and a
query, or rather, when it is more appropriate to use one vs. the other.
It seems to me that most select queries can be implemented as views, and I
can't see the downside to doing so.
I have a rather complicated database structure in terms of the relationships
between various tables, and to get the information that I need into the user
interface forms I have to use a number of nested queries (first to combine
tables together that have been normalized to place the related info in a
single table, then next to extract only the info that I require. In some
cases I would need a 3 level deep nested query to get to what I need. By
implementing the first step, that of combing the normalized tables back into
a single table as a view, it seems to me that I've completed the first step
at the database level, thus making my queries or stored procedures easier to
implement.
I would appreciate any comments which can help me to decide when it is or is
not appropriate to use a view in these circumstances. I should point out
that I don't plan on using the views as part of action queries since they
are made up of multiple tables, I'm primarily interested in using them to
output data which has been consiolidated from multiple tables.
Thanks in advance to any and all who take the time to reply.
I am new to T-SQL programing, and relativly new to SQL statements in
general, although I have a good understanding of database theory. I'm a
little confused as to the fundamental differences between a view and a
query, or rather, when it is more appropriate to use one vs. the other.
It seems to me that most select queries can be implemented as views, and I
can't see the downside to doing so.
I have a rather complicated database structure in terms of the relationships
between various tables, and to get the information that I need into the user
interface forms I have to use a number of nested queries (first to combine
tables together that have been normalized to place the related info in a
single table, then next to extract only the info that I require. In some
cases I would need a 3 level deep nested query to get to what I need. By
implementing the first step, that of combing the normalized tables back into
a single table as a view, it seems to me that I've completed the first step
at the database level, thus making my queries or stored procedures easier to
implement.
I would appreciate any comments which can help me to decide when it is or is
not appropriate to use a view in these circumstances. I should point out
that I don't plan on using the views as part of action queries since they
are made up of multiple tables, I'm primarily interested in using them to
output data which has been consiolidated from multiple tables.
Thanks in advance to any and all who take the time to reply.
Comment