Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Views....why?

Status
Not open for further replies.

shenlon

Programmer
Jul 9, 2003
47
0
0
US
Can someone explain to me the concept of views and why/when you want to use them compared to regular tables? It seems to me that views and tables are very similar, and perhaps my preference is just to use tables over views, but if I am misunderstanding something, I don't want to be cutting myself short if I can avoid it.
 
shenlon

For one view can contains fields from more than one table (providing they are related in some fashion).


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Think of a view as an "constructed one-the-fly" super-table, that, as Mike G. says, can contain information from many tables. They are flexible, take up no disk space, and preserve the "normalization" of a database. That last is just a fancy way of saying the primary rule of good database design: Don't store the same information in more than one place.

For example, how would you store an invoice with order items that have descriptions? Would you store the description of each order item in the orderitem table? No, you would store the item number, and when you wanted to print the invoice you would put together a view linking the orderitem table with the iteminventory table that contains the description, unit price, etc. The linking field is the item number.

Hope this helps.



Mike Krausnick
Dublin, California
 
Assume you have an customer and an orders table. You want to show all orders for a customer. A view is a nice way to do that. Use the view in a grid on the form and the data appears automatically when you move from record to record and refresh the form.

Views are nice in grids because they handle the adding, deleting, and updating for you. The scroll bar on the right side of the grid is accuate, unlike using a filter on a table.



Jim Osieczonek
Delta Business Group, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top